59 lines
1.3 KiB
TypeScript
59 lines
1.3 KiB
TypeScript
import { FormDialog } from "@repo/shadcn-ui/components/form-dialog";
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
import { PersonForm } from "./person-form";
|
|
import { SiteForm } from "./site-form";
|
|
|
|
export function InventoryQuickCreateDialog({
|
|
companyId,
|
|
csrfToken,
|
|
kind,
|
|
onCreated,
|
|
onClose,
|
|
}: {
|
|
companyId: string;
|
|
csrfToken: string;
|
|
kind: "site" | "person";
|
|
onCreated: (id: string) => void;
|
|
onClose: () => void;
|
|
}) {
|
|
const { t } = useTranslation("companies");
|
|
const { t: assetTranslation } = useTranslation("assets");
|
|
return (
|
|
<FormDialog
|
|
cancelLabel={t("cancel")}
|
|
formActions
|
|
onOpenChange={(open) => {
|
|
if (!open) {
|
|
onClose();
|
|
}
|
|
}}
|
|
open
|
|
title={t(kind === "site" ? "newSite" : "newPerson")}
|
|
>
|
|
<p className="text-sm text-muted-foreground">{assetTranslation("relatedNotice")}</p>
|
|
{kind === "site" ? (
|
|
<SiteForm
|
|
companyId={companyId}
|
|
csrfToken={csrfToken}
|
|
onSaved={(id) => {
|
|
onCreated(id);
|
|
onClose();
|
|
}}
|
|
showTitle={false}
|
|
/>
|
|
) : (
|
|
<PersonForm
|
|
companyId={companyId}
|
|
csrfToken={csrfToken}
|
|
onSaved={(id) => {
|
|
onCreated(id);
|
|
onClose();
|
|
}}
|
|
requireActive
|
|
/>
|
|
)}
|
|
</FormDialog>
|
|
);
|
|
}
|