Sha256: 2c1cf3c62b013e682d0c36ecd33d50bcb35fa525aa43ec85756d5a3dec692005

Contents?: true

Size: 1.78 KB

Versions: 6

Compression:

Stored size: 1.78 KB

Contents

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

export default function Show({ <%= singular_table_name %>, flash }) {
  const onDestroy = (e) => {
    if (!confirm('Are you sure you want to delete this <%= human_name.downcase %>?')) {
      e.preventDefault()
    }
  }

  return (
    <>
      <Head title={`<%= human_name %> #${<%= singular_table_name %>.id}`} />

      <div className="mx-auto md:w-2/3 w-full px-8 pt-8">
        <div className="mx-auto">
          {flash.notice && (
            <p className="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block">
              {flash.notice}
            </p>
          )}

          <h1 className="font-bold text-4xl"><%= human_name %> #{<%= singular_table_name %>.id}</h1>

          <<%= inertia_component_name %> <%= singular_table_name %>={<%= singular_table_name %>} />

          <Link
            href={`<%= js_edit_resource_path %>`}
            className="mt-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
          >
            Edit this <%= human_name.downcase %>
          </Link>
          <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 className="inline-block ml-2">
            <Link
              href={`<%= js_resource_path %>`}
              onClick={onDestroy}
              as="button"
              method="delete"
              className="mt-2 rounded-lg py-3 px-5 bg-gray-100 font-medium"
            >
              Destroy this <%= human_name.downcase %>
            </Link>
          </div>
        </div>
      </div>
    </>
  )
}

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
inertia_rails-contrib-0.3.0 lib/generators/inertia_tw_templates/scaffold/templates/react/Show.jsx.tt
inertia_rails-contrib-0.2.2 lib/generators/inertia_tw_templates/scaffold/templates/react/Show.jsx.tt
inertia_rails-contrib-0.2.1 lib/generators/inertia_tw_templates/scaffold/templates/react/Show.jsx.tt
inertia_rails-contrib-0.2.0 lib/generators/inertia_tw_templates/scaffold/templates/react/Show.jsx.tt
inertia_rails-contrib-0.1.1 lib/generators/inertia_tw_templates/scaffold/templates/react/Show.jsx.tt
inertia_rails-contrib-0.1.0 lib/generators/inertia_tw_templates/scaffold/templates/react/Show.jsx.tt