Sha256: 8b8ba9985ebeed869fd9fe5bf049e8e6dfd4e4169a4c1d071bf86293dd70d7a7

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

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

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

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

      <h1>Editing <%= human_name.downcase %></h1>

      <Form
        <%= singular_table_name %>={<%= singular_table_name %>}
        onSubmit={(form) => {
          form.transform((data) => ({ <%= singular_table_name %>: data }))
<% if attributes.any?(&:attachments?) -%>
          form.post(`<%= js_resource_path %>`, {
            headers: { 'X-HTTP-METHOD-OVERRIDE': 'put' },
          })
<% else -%>
          form.patch(`<%= js_resource_path %>`)
<% end -%>
        }}
        submitText="Update <%= human_name %>"
      />

      <br />

      <div>
        <Link href={`<%= js_resource_path %>`}>Show this <%= human_name.downcase %></Link>
        {' | '}
        <Link href="<%= js_resources_path %>">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_templates/scaffold/templates/react/Edit.tsx.tt