Sha256: 7bdfcaa00b85bb01549e9bed5f6300f748d8fa3fcb924e44d9a46766dfe7b710

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

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

interface IndexProps {
  <%= plural_table_name %>: <%= inertia_model_type %>[]
  flash: { notice?: string }
}

export default function Index({ <%= plural_table_name %>, flash }: IndexProps) {
  return (
    <>
      <Head title="<%= human_name.pluralize %>" />

      {flash.notice && <p style={{ color: 'green' }}>{flash.notice}</p>}

      <h1><%= human_name.pluralize %></h1>
      <div>
        {<%= plural_table_name %>.map((<%= singular_table_name %>) => (
          <div key={<%= singular_table_name %>.id}>
            <<%= inertia_component_name %> <%= singular_table_name %>={<%= singular_table_name %>} />
            <p>
              <Link href={`<%= js_resource_path %>`}>Show this <%= human_name.downcase %></Link>
            </p>
          </div>
        ))}
      </div>

      <Link href="<%= js_new_resource_path %>">New <%= human_name.downcase %></Link>
    </>
  )
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
inertia_rails-3.5.0 lib/generators/inertia_templates/scaffold/templates/react/Index.tsx.tt