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
+75
-10
@@ -1,14 +1,26 @@
|
||||
// R-P6 (P6 CRM core, Variante A) — contact browser route (`/contacts`). Loader
|
||||
// builds the KontaktListVM server-side (filter/sort/paginate, DoD 2); action runs
|
||||
// the bulk operations (archive/reassign/tag). Module off -> locked empty; missing
|
||||
// crm.read_own -> 404. UI is the shared KontaktListView (baseline inline UI; the
|
||||
// final optics arrive with David's D-CRM delta).
|
||||
// crm.read_own -> 404. UI is the AD-28 interim KontaktListPage (composed from
|
||||
// ~/ui); the route owns navigation (filter/sort/page) + the bulk POST and injects
|
||||
// them as action callbacks. Final optics arrive with David's D-CRM delta.
|
||||
|
||||
import { type ActionFunctionArgs, type LoaderFunctionArgs, useActionData, useLoaderData } from "react-router";
|
||||
import {
|
||||
type ActionFunctionArgs,
|
||||
type LoaderFunctionArgs,
|
||||
useActionData,
|
||||
useLoaderData,
|
||||
useFetcher,
|
||||
useNavigate,
|
||||
useSubmit,
|
||||
} from "react-router";
|
||||
import { handleKontaktListAction, loadKontaktListData, type KontaktListLoaderData } from "~/utils/integrations/crm/crmListRoute.server";
|
||||
import { kontaktListQueryToParams, type KontaktListQuery } from "~/utils/integrations/crm/kontaktListQuery";
|
||||
import { CRM_MODULE_KEY } from "~/utils/integrations/crm/crmRoutePaths";
|
||||
import KontaktListView from "~/components/crm/KontaktListView";
|
||||
import { KontaktListPage } from "~/components/screens/crm/KontaktListPage";
|
||||
import type { KontaktNewDuplicates } from "~/components/screens/crm/KontaktNewPage";
|
||||
import ServerError from "~/components/ui/errors/ServerError";
|
||||
import { useSaveToast } from "~/hooks/use-save-toast";
|
||||
|
||||
export const loader = async ({ request, params }: LoaderFunctionArgs) => {
|
||||
return Response.json(await loadKontaktListData({ request, params, variant: "contacts" }));
|
||||
@@ -21,18 +33,71 @@ export const action = async ({ request, params }: ActionFunctionArgs) => {
|
||||
export default function ContactsIndexRoute() {
|
||||
const data = useLoaderData<KontaktListLoaderData>();
|
||||
const actionData = useActionData<{ error?: string }>();
|
||||
const navigate = useNavigate();
|
||||
// Live duplicate check for the create dialog — posts to the create route, which
|
||||
// owns the `intent=checkDuplicates` branch (same contract as the standalone page).
|
||||
const dupFetcher = useFetcher<KontaktNewDuplicates>();
|
||||
const submit = useSubmit();
|
||||
useSaveToast(actionData);
|
||||
|
||||
const toHref = (query: KontaktListQuery): string => {
|
||||
const qs = kontaktListQueryToParams(query).toString();
|
||||
return qs ? `${data.baseHref}?${qs}` : data.baseHref;
|
||||
};
|
||||
|
||||
return (
|
||||
<KontaktListView
|
||||
moduleActive={data.moduleActive}
|
||||
variant="contacts"
|
||||
<KontaktListPage
|
||||
vm={data.vm}
|
||||
variant="contacts"
|
||||
moduleActive={data.moduleActive}
|
||||
query={data.query}
|
||||
tagOptions={data.tagOptions}
|
||||
ownerOptions={data.ownerOptions}
|
||||
query={data.query}
|
||||
baseHref={data.baseHref}
|
||||
canWrite={data.canWrite}
|
||||
canAdmin={data.canAdmin}
|
||||
nav={{
|
||||
contactsHref: data.contactsHref,
|
||||
companiesHref: data.companiesHref,
|
||||
customFieldsHref: data.customFieldsHref,
|
||||
tagsHref: data.tagsHref,
|
||||
duplicatesHref: data.duplicatesHref,
|
||||
}}
|
||||
newHref={data.newHref}
|
||||
exportHref={data.exportHref}
|
||||
defaultOwnerId={data.defaultOwnerId}
|
||||
duplicates={dupFetcher.data ?? null}
|
||||
errorKey={actionData?.error ?? null}
|
||||
actions={{
|
||||
onApplyFilter: (query) => navigate(toHref(query)),
|
||||
onGoToPage: (page) => navigate(toHref({ ...data.query, page })),
|
||||
onBulk: (intent, ids) => {
|
||||
const form = new FormData();
|
||||
form.set("intent", intent);
|
||||
ids.forEach((id) => form.append("kontaktId", id));
|
||||
submit(form, { method: "post" });
|
||||
},
|
||||
onCheckDuplicates: (fields) => {
|
||||
const form = new FormData();
|
||||
form.set("intent", "checkDuplicates");
|
||||
for (const [key, value] of Object.entries(fields)) form.set(key, value);
|
||||
dupFetcher.submit(form, { method: "post", action: data.newHref });
|
||||
},
|
||||
onExport: () => window.location.assign(data.exportHref),
|
||||
onNavigate: (href) => navigate(href),
|
||||
onAssignTag: (kontaktId, tagId) => {
|
||||
const form = new FormData();
|
||||
form.set("intent", "assignTag");
|
||||
form.set("kontaktId", kontaktId);
|
||||
form.set("tagId", tagId);
|
||||
submit(form, { method: "post" });
|
||||
},
|
||||
onRemoveTag: (kontaktId, tagId) => {
|
||||
const form = new FormData();
|
||||
form.set("intent", "removeTag");
|
||||
form.set("kontaktId", kontaktId);
|
||||
form.set("tagId", tagId);
|
||||
submit(form, { method: "post" });
|
||||
},
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user