Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+39
-7
@@ -1,13 +1,15 @@
|
||||
// R-P6 (P6 CRM core, Variante A) — organisation detail route
|
||||
// (`/contacts/companies/:id`). Reuses the SAME loader/action/component as the
|
||||
// contact detail (Component-Extraktion, no .server re-export); only the back link
|
||||
// / breadcrumb root differs. Not visible / module off -> 404.
|
||||
// (`/contacts/companies/:id`). Reuses the SAME loader/action/screen as the contact
|
||||
// detail; only the back link / breadcrumb root differs (variant "companies"). Not
|
||||
// visible / module off -> 404. UI is the AD-28 interim KontaktDetailPage.
|
||||
|
||||
import { type ActionFunctionArgs, type LoaderFunctionArgs, useActionData, useLoaderData } from "react-router";
|
||||
import { type ActionFunctionArgs, type LoaderFunctionArgs, useActionData, useLoaderData, useNavigation, useSubmit } from "react-router";
|
||||
import { handleKontaktDetailAction, loadKontaktDetailData, type KontaktDetailLoaderData } from "~/utils/integrations/crm/crmDetailRoute.server";
|
||||
import { CRM_MODULE_KEY } from "~/utils/integrations/crm/crmRoutePaths";
|
||||
import KontaktDetailView from "~/components/crm/KontaktDetailView";
|
||||
import { KontaktDetailPage } from "~/components/screens/crm/KontaktDetailPage";
|
||||
import ServerError from "~/components/ui/errors/ServerError";
|
||||
import { appendCSRFToken } from "~/utils/csrf";
|
||||
import { useSaveToast } from "~/hooks/use-save-toast";
|
||||
|
||||
export const loader = async ({ request, params }: LoaderFunctionArgs) => {
|
||||
return Response.json(await loadKontaktDetailData({ request, params, variant: "companies" }));
|
||||
@@ -20,19 +22,49 @@ export const action = async ({ request, params }: ActionFunctionArgs) => {
|
||||
export default function CompanyDetailRoute() {
|
||||
const data = useLoaderData<KontaktDetailLoaderData>();
|
||||
const actionData = useActionData<{ error?: string }>();
|
||||
const submit = useSubmit();
|
||||
const navigation = useNavigation();
|
||||
useSaveToast(actionData);
|
||||
|
||||
if (data.detailVM.status !== "ready" || !data.detailVM.data) {
|
||||
return <main className="mx-auto max-w-4xl px-4 py-10" data-ui-id="ui.crm.detail" />;
|
||||
return <div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.crm.detail" />;
|
||||
}
|
||||
|
||||
return (
|
||||
<KontaktDetailView
|
||||
<KontaktDetailPage
|
||||
data={data.detailVM.data}
|
||||
activity={data.activityVM}
|
||||
allTags={data.allTags}
|
||||
tagsAdminHref={data.tagsAdminHref ?? undefined}
|
||||
customFieldDefs={data.customFieldDefs}
|
||||
ownerOptions={data.ownerOptions}
|
||||
backHref={data.backHref}
|
||||
listLabelKey={data.listLabelKey}
|
||||
submitting={navigation.state !== "idle"}
|
||||
errorKey={actionData?.error ?? null}
|
||||
clickToCall={{
|
||||
vm: data.clickToCallVM,
|
||||
busy: navigation.state !== "idle",
|
||||
onCall: (number, mode) => {
|
||||
if (mode === "tel-fallback") {
|
||||
window.location.assign(`tel:${number.e164}`);
|
||||
return;
|
||||
}
|
||||
const form = new FormData();
|
||||
form.set("intent", "startTelephonyCall");
|
||||
form.set("numberId", number.id);
|
||||
form.set("destination", number.e164);
|
||||
submit(appendCSRFToken(form), { method: "post" });
|
||||
},
|
||||
}}
|
||||
actions={{
|
||||
onSubmit: (intent, fields) => {
|
||||
const form = new FormData();
|
||||
form.set("intent", intent);
|
||||
if (fields) for (const [key, value] of Object.entries(fields)) form.set(key, value);
|
||||
submit(form, { method: "post" });
|
||||
},
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user