- Menu items can now list allergens (shared catalog + join table), shown on the menu grid and item detail pages when applicable, and editable from the admin menu item form. - Removed the top-nav "Help" link now that the footer links to it. - The item customization page's price now uses the sliding AnimatedNumber, matching the basket line price. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
39 lines
1.0 KiB
TypeScript
39 lines
1.0 KiB
TypeScript
import { createFileRoute, useNavigate } from '@tanstack/react-router'
|
|
|
|
import { MenuItemForm } from '#/components/admin/MenuItemForm.tsx'
|
|
import { withAdminGuard } from '#/lib/admin-guard.ts'
|
|
import {
|
|
createMenuItem,
|
|
getAllergenOptions,
|
|
getMachineTagOptions,
|
|
} from '#/server/menu-admin.ts'
|
|
|
|
const NewMenuItemRoute = () => {
|
|
const { machineTags, allergenOptions } = Route.useLoaderData()
|
|
const navigate = useNavigate()
|
|
|
|
return (
|
|
<section>
|
|
<h1>Add menu item</h1>
|
|
<MenuItemForm
|
|
machineTags={machineTags}
|
|
allergenOptions={allergenOptions}
|
|
submitLabel="Create item"
|
|
onSubmit={async (input) => {
|
|
await createMenuItem({ data: input })
|
|
await navigate({ to: '/admin/menu', viewTransition: false })
|
|
}}
|
|
/>
|
|
</section>
|
|
)
|
|
}
|
|
|
|
export const Route = createFileRoute('/admin/menu/new')({
|
|
loader: () =>
|
|
withAdminGuard(async () => ({
|
|
machineTags: await getMachineTagOptions(),
|
|
allergenOptions: await getAllergenOptions(),
|
|
})),
|
|
component: NewMenuItemRoute,
|
|
})
|