mirror of
https://github.com/Sea-Haven-Industries/seahaven-ap.git
synced 2026-10-06 19:21:56 +00:00
* feat(settings): add settings and approvals POC shells (AP-7) Add app shell nav plus mock settings CRUD routes and an approvals inbox so the POC demo path works without an API. * fix(build): generate router types before tsc CI failed because src/router.ts is gitignored and tsc ran before Vite created it.
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
import { Container } from "@mui/material";
|
|
import { useUpsertVendor } from "@/domain/vendors/use-vendors";
|
|
import { useNavigate } from "@/router";
|
|
import { SettingsFormShell, type SettingsFormField } from "@/settings/SettingsFormShell";
|
|
|
|
const fields: SettingsFormField[] = [
|
|
{ name: "name", label: "Name" },
|
|
{ name: "email", label: "Email", type: "email" },
|
|
{
|
|
name: "defaultPaymentMethod",
|
|
label: "Default payment method",
|
|
type: "select",
|
|
options: [
|
|
{ value: "check", label: "Check" },
|
|
{ value: "ach", label: "ACH" },
|
|
],
|
|
},
|
|
];
|
|
|
|
function createId(): string {
|
|
return `vendor-${crypto.randomUUID().slice(0, 8)}`;
|
|
}
|
|
|
|
export default function VendorNewPage() {
|
|
const navigate = useNavigate();
|
|
const upsert = useUpsertVendor();
|
|
|
|
return (
|
|
<Container maxWidth="md" sx={{ py: 4 }}>
|
|
<SettingsFormShell
|
|
title="New vendor"
|
|
testId="settings-vendor-form"
|
|
fields={fields}
|
|
initialValues={{ name: "", email: "", defaultPaymentMethod: "check" }}
|
|
onCancel={() => navigate("/settings/vendors")}
|
|
onSave={async (values) => {
|
|
await upsert.mutateAsync({
|
|
id: createId(),
|
|
name: values.name.trim(),
|
|
email: values.email.trim(),
|
|
defaultPaymentMethod: values.defaultPaymentMethod as "check" | "ach",
|
|
});
|
|
navigate("/settings/vendors");
|
|
}}
|
|
/>
|
|
</Container>
|
|
);
|
|
}
|