metis-desk/modules/companies/src/web/folders/folder-quick-editor.tsx
David 78c05eae6d refactor: improve folder mapping persistence and API integration
- Enhanced the folder mapping persistence mapper for better error handling and data validation.
- Updated the Sequelize folder mapping repository to streamline data loading and improve transaction handling.
- Refactored folder mapping schemas for clarity and consistency in validation.
- Improved folder API error handling and response data processing.
- Enhanced folder mapping form component with better state management and user feedback.
- Introduced a new quick editor component for creating profiles and needs within the folder mapping context.
2026-10-08 13:48:10 +02:00

67 lines
1.7 KiB
TypeScript

import { FormDialog } from "@repo/shadcn-ui/components/form-dialog";
import { useTranslation } from "react-i18next";
import type { AccessResponseDTO, CompanyDTO, WorkProfileDTO } from "../../common";
import { AccessForm } from "../access/access-form";
import { WorkProfileForm } from "../profiles/work-profile-form";
export function FolderQuickEditor({
kind,
company,
csrfToken,
data,
profile,
onClose,
onCreated,
}: {
kind: "profile" | "need";
company: CompanyDTO;
csrfToken: string;
data: AccessResponseDTO | undefined;
profile: WorkProfileDTO | undefined;
onClose: () => void;
onCreated: (field: "profileId" | "needId", id: string) => void;
}) {
const { t } = useTranslation("companies");
return (
<FormDialog
cancelLabel={t("cancel")}
formActions
onOpenChange={(open) => {
if (!open) {
onClose();
}
}}
open
title={t(kind === "profile" ? "profiles.new" : "folders.newNeed")}
wide
>
{kind === "profile" && (
<WorkProfileForm
allowQuickCreate={false}
company={company}
csrfToken={csrfToken}
onSaved={(id) => onCreated("profileId", id)}
/>
)}
{kind === "need" && data && profile && (
<AccessForm
allowQuickCreate={false}
csrfToken={csrfToken}
data={data}
initialValues={{ personId: profile.values.personId }}
kind="need"
lockedFields={["personId"]}
onSaved={(id) => {
if (id) {
onCreated("needId", id);
}
}}
people={company.people}
scope={company.id}
/>
)}
</FormDialog>
);
}