Sha256: 64eda320510773519ae44fa62a10302b7f5797bb72c111ae11256b35c9a9b540

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

import { Head, Link } from '@inertiajs/react'
import Form from './Form'
import { <%= inertia_model_type %> } from './types'

interface NewProps {
  <%= singular_table_name %>: <%= inertia_model_type %>
}

export default function New({ <%= singular_table_name %> }: NewProps) {
  return (
    <>
      <Head title="New <%= human_name.downcase %>" />

      <div className="mx-auto md:w-2/3 w-full px-8 pt-8">
        <h1 className="font-bold text-4xl">New <%= human_name.downcase %></h1>

        <Form
          <%= singular_table_name %>={<%= singular_table_name %>}
          onSubmit={(form) => {
            form.transform((data) => ({ <%= singular_table_name %>: data }))
            form.post('<%= js_resources_path %>')
          }}
          submitText="Create <%= human_name %>"
        />

        <Link
          href="<%= js_resources_path %>"
          className="ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
        >
          Back to <%= human_name.pluralize.downcase %>
        </Link>
      </div>
    </>
  )
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
inertia_rails-3.5.0 lib/generators/inertia_tw_templates/scaffold/templates/react/New.tsx.tt