Sha256: 0cfc3a3e72bf0ccc0082f5833b717960c091040f2cc94a82e5cc5036c9208c40

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

import { <%= inertia_model_type %> } from './types'

interface <%= inertia_component_name %>Props {
  <%= singular_table_name %>: <%= inertia_model_type %>
}

export default function <%= inertia_component_name %>({ <%= singular_table_name %> }: <%= inertia_component_name %>Props) {
  return (
    <div>
<% attributes.reject(&:password_digest?).each do |attribute| -%>
      <p>
        <strong><%= attribute.human_name %>:</strong>
<% if attribute.attachment? -%>
        {<%= singular_table_name %>.<%= attribute.column_name %> && (
          <a href={<%= singular_table_name %>.<%= attribute.column_name %>.url}>{<%= singular_table_name %>.<%= attribute.column_name %>.filename}</a>
        )}
      </p>
<% elsif attribute.attachments? -%>
      </p>
      {<%= singular_table_name %>.<%= attribute.column_name %>.map((file, i) => (
        <div key={i}>
          <a href={file.url}>{file.filename}</a>
        </div>
      ))}
<% else -%>
        {<%= singular_table_name %>.<%= attribute.column_name %>?.toString()}
      </p>
<% end -%>
<% end -%>
    </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/One.tsx.tt