@flowselections/mailbox-orders 1.0.53 → 1.0.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-lib/components/MailboxAuthBanner.d.ts +3 -3
- package/dist-lib/components/MailboxAuthBanner.d.ts.map +1 -1
- package/dist-lib/components/MailboxAuthBanner.js +20 -7
- package/dist-lib/components/MailboxPageFrame.d.ts +25 -0
- package/dist-lib/components/MailboxPageFrame.d.ts.map +1 -0
- package/dist-lib/components/MailboxPageFrame.js +103 -0
- package/dist-lib/components/MailboxProcessedPage.d.ts.map +1 -1
- package/dist-lib/components/MailboxProcessedPage.js +102 -61
- package/dist-lib/components/MailboxProposalsPage.d.ts.map +1 -1
- package/dist-lib/components/MailboxProposalsPage.js +191 -76
- package/dist-lib/components/MailboxSkippedPage.d.ts.map +1 -1
- package/dist-lib/components/MailboxSkippedPage.js +97 -19
- package/dist-lib/components/MailboxStatusLine.d.ts +8 -2
- package/dist-lib/components/MailboxStatusLine.d.ts.map +1 -1
- package/dist-lib/components/MailboxStatusLine.js +54 -8
- package/dist-lib/components/TablePagination.d.ts +2 -2
- package/dist-lib/components/TablePagination.d.ts.map +1 -1
- package/dist-lib/components/TablePagination.js +8 -12
- package/dist-lib/components/fs-ui/DataTable.d.ts +42 -0
- package/dist-lib/components/fs-ui/DataTable.d.ts.map +1 -0
- package/dist-lib/components/fs-ui/DataTable.js +40 -0
- package/dist-lib/components/fs-ui/EmptyState.d.ts +9 -0
- package/dist-lib/components/fs-ui/EmptyState.d.ts.map +1 -0
- package/dist-lib/components/fs-ui/EmptyState.js +5 -0
- package/dist-lib/components/fs-ui/FilterChips.d.ts +13 -0
- package/dist-lib/components/fs-ui/FilterChips.d.ts.map +1 -0
- package/dist-lib/components/fs-ui/FilterChips.js +8 -0
- package/dist-lib/components/fs-ui/FilterPanel.d.ts +32 -0
- package/dist-lib/components/fs-ui/FilterPanel.d.ts.map +1 -0
- package/dist-lib/components/fs-ui/FilterPanel.js +20 -0
- package/dist-lib/components/fs-ui/HoverTip.d.ts +15 -0
- package/dist-lib/components/fs-ui/HoverTip.d.ts.map +1 -0
- package/dist-lib/components/fs-ui/HoverTip.js +24 -0
- package/dist-lib/components/fs-ui/InlineAlert.d.ts +9 -0
- package/dist-lib/components/fs-ui/InlineAlert.d.ts.map +1 -0
- package/dist-lib/components/fs-ui/InlineAlert.js +6 -0
- package/dist-lib/components/fs-ui/KpiRow.d.ts +6 -0
- package/dist-lib/components/fs-ui/KpiRow.d.ts.map +1 -0
- package/dist-lib/components/fs-ui/KpiRow.js +7 -0
- package/dist-lib/components/fs-ui/KpiTile.d.ts +21 -0
- package/dist-lib/components/fs-ui/KpiTile.d.ts.map +1 -0
- package/dist-lib/components/fs-ui/KpiTile.js +40 -0
- package/dist-lib/components/fs-ui/MobilePrimaryAction.d.ts +10 -0
- package/dist-lib/components/fs-ui/MobilePrimaryAction.d.ts.map +1 -0
- package/dist-lib/components/fs-ui/MobilePrimaryAction.js +7 -0
- package/dist-lib/components/fs-ui/NoticeBar.d.ts +18 -0
- package/dist-lib/components/fs-ui/NoticeBar.d.ts.map +1 -0
- package/dist-lib/components/fs-ui/NoticeBar.js +24 -0
- package/dist-lib/components/fs-ui/PageHeader.d.ts +8 -0
- package/dist-lib/components/fs-ui/PageHeader.d.ts.map +1 -0
- package/dist-lib/components/fs-ui/PageHeader.js +5 -0
- package/dist-lib/components/fs-ui/PillTabs.d.ts +16 -0
- package/dist-lib/components/fs-ui/PillTabs.d.ts.map +1 -0
- package/dist-lib/components/fs-ui/PillTabs.js +29 -0
- package/dist-lib/components/fs-ui/RowMenu.d.ts +13 -0
- package/dist-lib/components/fs-ui/RowMenu.d.ts.map +1 -0
- package/dist-lib/components/fs-ui/RowMenu.js +10 -0
- package/dist-lib/components/fs-ui/SearchInput.d.ts +12 -0
- package/dist-lib/components/fs-ui/SearchInput.d.ts.map +1 -0
- package/dist-lib/components/fs-ui/SearchInput.js +38 -0
- package/dist-lib/components/fs-ui/ShortcutHelp.d.ts +7 -0
- package/dist-lib/components/fs-ui/ShortcutHelp.d.ts.map +1 -0
- package/dist-lib/components/fs-ui/ShortcutHelp.js +6 -0
- package/dist-lib/components/fs-ui/StatusIcon.d.ts +8 -0
- package/dist-lib/components/fs-ui/StatusIcon.d.ts.map +1 -0
- package/dist-lib/components/fs-ui/StatusIcon.js +16 -0
- package/dist-lib/components/fs-ui/TableSkeleton.d.ts +6 -0
- package/dist-lib/components/fs-ui/TableSkeleton.d.ts.map +1 -0
- package/dist-lib/components/fs-ui/TableSkeleton.js +6 -0
- package/dist-lib/components/fs-ui/Toolbar.d.ts +13 -0
- package/dist-lib/components/fs-ui/Toolbar.d.ts.map +1 -0
- package/dist-lib/components/fs-ui/Toolbar.js +10 -0
- package/dist-lib/components/fs-ui/UpdatedAt.d.ts +8 -0
- package/dist-lib/components/fs-ui/UpdatedAt.d.ts.map +1 -0
- package/dist-lib/components/fs-ui/UpdatedAt.js +17 -0
- package/dist-lib/components/fs-ui/useListHotkeys.d.ts +18 -0
- package/dist-lib/components/fs-ui/useListHotkeys.d.ts.map +1 -0
- package/dist-lib/components/fs-ui/useListHotkeys.js +48 -0
- package/dist-lib/components/settings/MailboxAiPromptCard.d.ts +2 -1
- package/dist-lib/components/settings/MailboxAiPromptCard.d.ts.map +1 -1
- package/dist-lib/components/settings/MailboxAiPromptCard.js +9 -1
- package/dist-lib/components/settings/MailboxFilterSettingsCard.js +1 -1
- package/dist-lib/components/settings/MailboxTestSetCard.d.ts +2 -1
- package/dist-lib/components/settings/MailboxTestSetCard.d.ts.map +1 -1
- package/dist-lib/components/settings/MailboxTestSetCard.js +10 -2
- package/dist-lib/integrations/supabase/types.d.ts +372 -0
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/format-date.d.ts +5 -0
- package/dist-lib/lib/format-date.d.ts.map +1 -0
- package/dist-lib/lib/format-date.js +30 -0
- package/dist-lib/lib/labels.d.ts +15 -0
- package/dist-lib/lib/labels.d.ts.map +1 -0
- package/dist-lib/lib/labels.js +57 -0
- package/dist-lib/lib/mailbox-list.functions.d.ts +67 -0
- package/dist-lib/lib/mailbox-list.functions.d.ts.map +1 -0
- package/dist-lib/lib/mailbox-list.functions.js +61 -0
- package/dist-lib/lib/mailbox.functions.js +3 -3
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-date.d.ts","sourceRoot":"","sources":["../../src/lib/format-date.ts"],"names":[],"mappings":"AAaA,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,GAAE,IAAiB,GAAG,MAAM,CAKjE;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,GAAE,IAAiB,GAAG,MAAM,CAMrE;AAED,+BAA+B;AAC/B,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEzC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Datums zoals in Verkoop: "di 3 nov", met tijd "di 3 nov 08:00".
|
|
2
|
+
// Alleen een ander jaar krijgt het jaartal erbij.
|
|
3
|
+
const DAYS = ["zo", "ma", "di", "wo", "do", "vr", "za"];
|
|
4
|
+
const MONTHS = ["jan", "feb", "mrt", "apr", "mei", "jun", "jul", "aug", "sep", "okt", "nov", "dec"];
|
|
5
|
+
function toDate(v) {
|
|
6
|
+
if (v == null || v === "")
|
|
7
|
+
return null;
|
|
8
|
+
const s = String(v);
|
|
9
|
+
const d = /^\d{4}-\d{2}-\d{2}$/.test(s) ? new Date(`${s}T12:00:00`) : new Date(s);
|
|
10
|
+
return Number.isNaN(d.getTime()) ? null : d;
|
|
11
|
+
}
|
|
12
|
+
export function fmtDay(v, now = new Date()) {
|
|
13
|
+
const d = toDate(v);
|
|
14
|
+
if (!d)
|
|
15
|
+
return "–";
|
|
16
|
+
const base = `${DAYS[d.getDay()]} ${d.getDate()} ${MONTHS[d.getMonth()]}`;
|
|
17
|
+
return d.getFullYear() === now.getFullYear() ? base : `${base} ${d.getFullYear()}`;
|
|
18
|
+
}
|
|
19
|
+
export function fmtDayTime(v, now = new Date()) {
|
|
20
|
+
const d = toDate(v);
|
|
21
|
+
if (!d)
|
|
22
|
+
return "–";
|
|
23
|
+
const hh = String(d.getHours()).padStart(2, "0");
|
|
24
|
+
const mm = String(d.getMinutes()).padStart(2, "0");
|
|
25
|
+
return `${fmtDay(d, now)} ${hh}:${mm}`;
|
|
26
|
+
}
|
|
27
|
+
/** Bedrag als "€ 1.234,56". */
|
|
28
|
+
export function fmtEuro(n) {
|
|
29
|
+
return "€ " + (Number(n) || 0).toLocaleString("nl-NL", { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
30
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const PROPOSAL_STATUS: Record<string, string>;
|
|
2
|
+
export declare const MESSAGE_STATUS: Record<string, string>;
|
|
3
|
+
export declare const FILTER_OUTCOME: Record<string, string>;
|
|
4
|
+
export declare const ANALYSIS_STATE: Record<string, string>;
|
|
5
|
+
export declare const READINESS: Record<string, string>;
|
|
6
|
+
export declare const ALL_LABEL_TABLES: {
|
|
7
|
+
PROPOSAL_STATUS: Record<string, string>;
|
|
8
|
+
MESSAGE_STATUS: Record<string, string>;
|
|
9
|
+
FILTER_OUTCOME: Record<string, string>;
|
|
10
|
+
ANALYSIS_STATE: Record<string, string>;
|
|
11
|
+
READINESS: Record<string, string>;
|
|
12
|
+
};
|
|
13
|
+
/** Vertaal een databasewaarde. Onbekend → "Overig"; de ruwe waarde gaat alleen naar console.warn. */
|
|
14
|
+
export declare function label(table: Record<string, string>, raw: unknown, fallback?: string): string;
|
|
15
|
+
//# sourceMappingURL=labels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"labels.d.ts","sourceRoot":"","sources":["../../src/lib/labels.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAOlD,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAajD,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAMjD,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAKjD,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAG5C,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;;;CAAiF,CAAC;AAI/G,qGAAqG;AACrG,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,SAAW,GAAG,MAAM,CAU9F"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// Eén vertaalbestand: elke status, reden, soort of bron uit de database gaat
|
|
2
|
+
// hierlangs naar Nederlandse tekst. Onbekend → "Overig" (ruwe waarde alleen in console).
|
|
3
|
+
export const PROPOSAL_STATUS = {
|
|
4
|
+
pending: "Te controleren",
|
|
5
|
+
approved: "Goedgekeurd",
|
|
6
|
+
rejected: "Afgewezen",
|
|
7
|
+
converted: "Order aangemaakt",
|
|
8
|
+
blocked_insufficient_stock: "Te weinig voorraad",
|
|
9
|
+
manual_review_load_carrier_disabled: "Belading controleren",
|
|
10
|
+
};
|
|
11
|
+
export const MESSAGE_STATUS = {
|
|
12
|
+
new: "Nieuw",
|
|
13
|
+
parsed: "Uitgelezen",
|
|
14
|
+
pending: "Te controleren",
|
|
15
|
+
skipped: "Overgeslagen",
|
|
16
|
+
waiting: "Wacht op uitlezen",
|
|
17
|
+
converted: "Order aangemaakt",
|
|
18
|
+
rejected: "Afgewezen",
|
|
19
|
+
approved: "Goedgekeurd",
|
|
20
|
+
manual_review_load_carrier_disabled: "Belading controleren",
|
|
21
|
+
blocked_insufficient_stock: "Te weinig voorraad",
|
|
22
|
+
error: "Niet gelukt",
|
|
23
|
+
fout: "Niet gelukt",
|
|
24
|
+
};
|
|
25
|
+
export const FILTER_OUTCOME = {
|
|
26
|
+
analyseren: "Wordt uitgelezen",
|
|
27
|
+
geen_bestelling: "Geen bestelling",
|
|
28
|
+
te_oud: "Te oud",
|
|
29
|
+
overslaan: "Overgeslagen",
|
|
30
|
+
bestelling: "Bestelling",
|
|
31
|
+
};
|
|
32
|
+
export const ANALYSIS_STATE = {
|
|
33
|
+
wacht: "Wacht op uitlezen",
|
|
34
|
+
klaar: "Uitgelezen",
|
|
35
|
+
bezig: "Wordt uitgelezen",
|
|
36
|
+
fout: "Niet gelukt",
|
|
37
|
+
};
|
|
38
|
+
export const READINESS = {
|
|
39
|
+
klaar: "Klaar",
|
|
40
|
+
controleren: "Controleren",
|
|
41
|
+
};
|
|
42
|
+
export const ALL_LABEL_TABLES = { PROPOSAL_STATUS, MESSAGE_STATUS, FILTER_OUTCOME, ANALYSIS_STATE, READINESS };
|
|
43
|
+
const warned = new Set();
|
|
44
|
+
/** Vertaal een databasewaarde. Onbekend → "Overig"; de ruwe waarde gaat alleen naar console.warn. */
|
|
45
|
+
export function label(table, raw, fallback = "Overig") {
|
|
46
|
+
const key = String(raw ?? "").trim();
|
|
47
|
+
if (!key)
|
|
48
|
+
return fallback;
|
|
49
|
+
const hit = table[key];
|
|
50
|
+
if (hit)
|
|
51
|
+
return hit;
|
|
52
|
+
if (!warned.has(key)) {
|
|
53
|
+
warned.add(key);
|
|
54
|
+
console.warn("[labels] onbekende waarde", key);
|
|
55
|
+
}
|
|
56
|
+
return fallback;
|
|
57
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
declare const pageInput: z.ZodObject<{
|
|
3
|
+
statuses: z.ZodArray<z.ZodEnum<{
|
|
4
|
+
pending: "pending";
|
|
5
|
+
approved: "approved";
|
|
6
|
+
rejected: "rejected";
|
|
7
|
+
}>>;
|
|
8
|
+
search: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
9
|
+
period: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
10
|
+
all: "all";
|
|
11
|
+
today: "today";
|
|
12
|
+
"7d": "7d";
|
|
13
|
+
"30d": "30d";
|
|
14
|
+
}>>>;
|
|
15
|
+
sort: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
16
|
+
desc: "desc";
|
|
17
|
+
asc: "asc";
|
|
18
|
+
}>>>;
|
|
19
|
+
dateField: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
20
|
+
received: "received";
|
|
21
|
+
reviewed: "reviewed";
|
|
22
|
+
}>>>;
|
|
23
|
+
tz: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
24
|
+
filter: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
25
|
+
klant_onbekend: "klant_onbekend";
|
|
26
|
+
}>>>>;
|
|
27
|
+
page: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
28
|
+
pageSize: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
29
|
+
}, z.core.$strip>;
|
|
30
|
+
export type ProposalsPageInput = z.input<typeof pageInput>;
|
|
31
|
+
/** Eén pagina voorstellen + totaal (mailbox_proposals_page). */
|
|
32
|
+
export declare const listProposalsPage: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
33
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
34
|
+
userId: string;
|
|
35
|
+
claims: import("@supabase/auth-js").User;
|
|
36
|
+
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
37
|
+
statuses: ("pending" | "approved" | "rejected")[];
|
|
38
|
+
search: string;
|
|
39
|
+
period: "all" | "today" | "7d" | "30d";
|
|
40
|
+
sort: "desc" | "asc";
|
|
41
|
+
dateField: "received" | "reviewed";
|
|
42
|
+
tz: string;
|
|
43
|
+
filter: "klant_onbekend" | null;
|
|
44
|
+
page: number;
|
|
45
|
+
pageSize: number;
|
|
46
|
+
}, Promise<{
|
|
47
|
+
items: any;
|
|
48
|
+
total: number;
|
|
49
|
+
}>>;
|
|
50
|
+
export interface MailboxKpis {
|
|
51
|
+
pending: number;
|
|
52
|
+
pending_today: number;
|
|
53
|
+
customer_unknown: number;
|
|
54
|
+
processed: number;
|
|
55
|
+
approved_today: number;
|
|
56
|
+
skipped: number;
|
|
57
|
+
}
|
|
58
|
+
/** Tellers voor tegels en tabbladen in één aanroep (mailbox_kpis). */
|
|
59
|
+
export declare const getMailboxKpis: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
60
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
61
|
+
userId: string;
|
|
62
|
+
claims: import("@supabase/auth-js").User;
|
|
63
|
+
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
64
|
+
tz: string;
|
|
65
|
+
}, Promise<MailboxKpis>>;
|
|
66
|
+
export {};
|
|
67
|
+
//# sourceMappingURL=mailbox-list.functions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mailbox-list.functions.d.ts","sourceRoot":"","sources":["../../src/lib/mailbox-list.functions.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,QAAA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAUb,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC;AAE3D,gEAAgE;AAChE,eAAO,MAAM,iBAAiB;;;;8CAEJ,OAAO;;;;;;;;;;;;;GAoB7B,CAAC;AAEL,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,sEAAsE;AACtE,eAAO,MAAM,cAAc;;;;8CAED,OAAO;;wBAiB7B,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// Leesfuncties voor de lijstweergaven (zoeken, filteren en pagineren op de server).
|
|
2
|
+
// Nieuwe functies; de bestaande listProposals blijft ongewijzigd bestaan.
|
|
3
|
+
import { createServerFn } from "@tanstack/react-start";
|
|
4
|
+
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware.js";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
const pageInput = z.object({
|
|
7
|
+
statuses: z.array(z.enum(["pending", "approved", "rejected"])).min(1),
|
|
8
|
+
search: z.string().max(200).optional().default(""),
|
|
9
|
+
period: z.enum(["all", "today", "7d", "30d"]).optional().default("all"),
|
|
10
|
+
sort: z.enum(["asc", "desc"]).optional().default("desc"),
|
|
11
|
+
dateField: z.enum(["received", "reviewed"]).optional().default("received"),
|
|
12
|
+
tz: z.string().max(64).optional().default("UTC"),
|
|
13
|
+
filter: z.enum(["klant_onbekend"]).nullable().optional().default(null),
|
|
14
|
+
page: z.number().int().min(1).optional().default(1),
|
|
15
|
+
pageSize: z.number().int().min(10).max(200).optional().default(50),
|
|
16
|
+
});
|
|
17
|
+
/** Eén pagina voorstellen + totaal (mailbox_proposals_page). */
|
|
18
|
+
export const listProposalsPage = createServerFn({ method: "GET" })
|
|
19
|
+
.middleware([requireSupabaseAuth])
|
|
20
|
+
.inputValidator((input) => pageInput.parse(input ?? {}))
|
|
21
|
+
.handler(async ({ data }) => {
|
|
22
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
23
|
+
const { data: res, error } = await supabaseAdmin.rpc("mailbox_proposals_page", {
|
|
24
|
+
p_statuses: data.statuses,
|
|
25
|
+
p_search: data.search?.trim() ? data.search.trim() : null,
|
|
26
|
+
p_period: data.period,
|
|
27
|
+
p_sort: data.sort,
|
|
28
|
+
p_date_field: data.dateField,
|
|
29
|
+
p_tz: data.tz,
|
|
30
|
+
p_filter: data.filter ?? null,
|
|
31
|
+
p_limit: data.pageSize,
|
|
32
|
+
p_offset: (data.page - 1) * data.pageSize,
|
|
33
|
+
});
|
|
34
|
+
if (error) {
|
|
35
|
+
console.error("[mailbox] mailbox_proposals_page", error);
|
|
36
|
+
throw new Error("De lijst kon niet worden geladen.");
|
|
37
|
+
}
|
|
38
|
+
const items = Array.isArray(res?.items) ? res.items : [];
|
|
39
|
+
return { items, total: Number(res?.total ?? 0) };
|
|
40
|
+
});
|
|
41
|
+
/** Tellers voor tegels en tabbladen in één aanroep (mailbox_kpis). */
|
|
42
|
+
export const getMailboxKpis = createServerFn({ method: "GET" })
|
|
43
|
+
.middleware([requireSupabaseAuth])
|
|
44
|
+
.inputValidator((input) => z.object({ tz: z.string().max(64).optional().default("UTC") }).parse(input ?? {}))
|
|
45
|
+
.handler(async ({ data }) => {
|
|
46
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
47
|
+
const { data: res, error } = await supabaseAdmin.rpc("mailbox_kpis", { p_tz: data.tz });
|
|
48
|
+
if (error) {
|
|
49
|
+
console.error("[mailbox] mailbox_kpis", error);
|
|
50
|
+
throw new Error("De tellers konden niet worden geladen.");
|
|
51
|
+
}
|
|
52
|
+
const n = (k) => Number(res?.[k] ?? 0) || 0;
|
|
53
|
+
return {
|
|
54
|
+
pending: n("pending"),
|
|
55
|
+
pending_today: n("pending_today"),
|
|
56
|
+
customer_unknown: n("customer_unknown"),
|
|
57
|
+
processed: n("processed"),
|
|
58
|
+
approved_today: n("approved_today"),
|
|
59
|
+
skipped: n("skipped"),
|
|
60
|
+
};
|
|
61
|
+
});
|
|
@@ -141,7 +141,7 @@ export const listProposals = createServerFn({ method: "GET" })
|
|
|
141
141
|
.inputValidator((input) => z.object({ status: z.enum(["pending", "approved", "rejected"]).optional() }).parse(input ?? {}))
|
|
142
142
|
.handler(async ({ data }) => {
|
|
143
143
|
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
144
|
-
|
|
144
|
+
// Standaardinstellingen: één keer per paginabezoek via ensureMailboxDefaultsFn.
|
|
145
145
|
// Alleen de kolommen die de lijstweergave toont. De mailtekst (body_text /
|
|
146
146
|
// body_html) en de bestelregels zijn bewust NIET opgenomen: die worden pas
|
|
147
147
|
// opgehaald zodra een voorstel geopend wordt (`getProposalDetail`).
|
|
@@ -1169,7 +1169,7 @@ export const listSkippedMessages = createServerFn({ method: "GET" })
|
|
|
1169
1169
|
.middleware([requireSupabaseAuth])
|
|
1170
1170
|
.handler(async () => {
|
|
1171
1171
|
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
1172
|
-
|
|
1172
|
+
// Standaardinstellingen: één keer per paginabezoek via ensureMailboxDefaultsFn.
|
|
1173
1173
|
const { data, error } = await supabaseAdmin
|
|
1174
1174
|
.from("mailbox_messages")
|
|
1175
1175
|
.select("id, from_email, from_name, subject, received_at, preview, filter_outcome, filter_reason, analysis_state, analysis_note, mailbox_order_proposals(id)")
|
|
@@ -1256,7 +1256,7 @@ export const getMailboxStatus = createServerFn({ method: "GET" })
|
|
|
1256
1256
|
.handler(async () => {
|
|
1257
1257
|
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
1258
1258
|
const admin = supabaseAdmin;
|
|
1259
|
-
|
|
1259
|
+
// Standaardinstellingen: één keer per paginabezoek via ensureMailboxDefaultsFn.
|
|
1260
1260
|
const { data: active } = await admin.rpc("email_auth_for_purpose", { _purpose: "orders", _direction: "receive" });
|
|
1261
1261
|
const activeRows = (Array.isArray(active) ? active : []);
|
|
1262
1262
|
const activeIds = activeRows.map((r) => r.id).filter(Boolean);
|