@flowselections/pick-schermen-kwekers 1.0.1
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/README.md +24 -0
- package/dist-lib/_core-safelist.d.ts +2 -0
- package/dist-lib/_core-safelist.d.ts.map +1 -0
- package/dist-lib/_core-safelist.js +15 -0
- package/dist-lib/components/PickBeheerPage.d.ts +2 -0
- package/dist-lib/components/PickBeheerPage.d.ts.map +1 -0
- package/dist-lib/components/PickBeheerPage.js +84 -0
- package/dist-lib/components/PickDashboardPage.d.ts +2 -0
- package/dist-lib/components/PickDashboardPage.d.ts.map +1 -0
- package/dist-lib/components/PickDashboardPage.js +54 -0
- package/dist-lib/components/PickKioskPage.d.ts +7 -0
- package/dist-lib/components/PickKioskPage.d.ts.map +1 -0
- package/dist-lib/components/PickKioskPage.js +18 -0
- package/dist-lib/components/PickstationDetailPage.d.ts +6 -0
- package/dist-lib/components/PickstationDetailPage.d.ts.map +1 -0
- package/dist-lib/components/PickstationDetailPage.js +25 -0
- package/dist-lib/components/PickstationsPage.d.ts +2 -0
- package/dist-lib/components/PickstationsPage.d.ts.map +1 -0
- package/dist-lib/components/PickstationsPage.js +18 -0
- package/dist-lib/components/TemplateModuleLogo.d.ts +6 -0
- package/dist-lib/components/TemplateModuleLogo.d.ts.map +1 -0
- package/dist-lib/components/TemplateModuleLogo.js +4 -0
- package/dist-lib/components/TemplateModulePage.d.ts +2 -0
- package/dist-lib/components/TemplateModulePage.d.ts.map +1 -0
- package/dist-lib/components/TemplateModulePage.js +44 -0
- package/dist-lib/components/TemplatePage.d.ts +2 -0
- package/dist-lib/components/TemplatePage.d.ts.map +1 -0
- package/dist-lib/components/TemplatePage.js +4 -0
- package/dist-lib/components/pick/ConfigCrud.d.ts +27 -0
- package/dist-lib/components/pick/ConfigCrud.d.ts.map +1 -0
- package/dist-lib/components/pick/ConfigCrud.js +64 -0
- package/dist-lib/components/pick/CountryTiles.d.ts +9 -0
- package/dist-lib/components/pick/CountryTiles.d.ts.map +1 -0
- package/dist-lib/components/pick/CountryTiles.js +13 -0
- package/dist-lib/components/pick/PickScherm.d.ts +10 -0
- package/dist-lib/components/pick/PickScherm.d.ts.map +1 -0
- package/dist-lib/components/pick/PickScherm.js +114 -0
- package/dist-lib/components/pick/QueueTable.d.ts +13 -0
- package/dist-lib/components/pick/QueueTable.d.ts.map +1 -0
- package/dist-lib/components/pick/QueueTable.js +29 -0
- package/dist-lib/components/settings/MijnModuleSettingsCard.d.ts +2 -0
- package/dist-lib/components/settings/MijnModuleSettingsCard.d.ts.map +1 -0
- package/dist-lib/components/settings/MijnModuleSettingsCard.js +42 -0
- package/dist-lib/hooks/useMijnModuleData.d.ts +13 -0
- package/dist-lib/hooks/useMijnModuleData.d.ts.map +1 -0
- package/dist-lib/hooks/useMijnModuleData.js +49 -0
- package/dist-lib/hooks/usePickConfig.d.ts +9 -0
- package/dist-lib/hooks/usePickConfig.d.ts.map +1 -0
- package/dist-lib/hooks/usePickConfig.js +29 -0
- package/dist-lib/hooks/usePickQueue.d.ts +34 -0
- package/dist-lib/hooks/usePickQueue.d.ts.map +1 -0
- package/dist-lib/hooks/usePickQueue.js +105 -0
- package/dist-lib/index.d.ts +20 -0
- package/dist-lib/index.d.ts.map +1 -0
- package/dist-lib/index.js +53 -0
- package/dist-lib/integrations/supabase/auth-attacher.d.ts +2 -0
- package/dist-lib/integrations/supabase/auth-attacher.d.ts.map +1 -0
- package/dist-lib/integrations/supabase/auth-attacher.js +12 -0
- package/dist-lib/integrations/supabase/auth-middleware.d.ts +15877 -0
- package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -0
- package/dist-lib/integrations/supabase/auth-middleware.js +52 -0
- package/dist-lib/integrations/supabase/client.d.ts +15873 -0
- package/dist-lib/integrations/supabase/client.d.ts.map +1 -0
- package/dist-lib/integrations/supabase/client.js +13 -0
- package/dist-lib/integrations/supabase/client.server.d.ts +15873 -0
- package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -0
- package/dist-lib/integrations/supabase/client.server.js +30 -0
- package/dist-lib/integrations/supabase/types.d.ts +16383 -0
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -0
- package/dist-lib/integrations/supabase/types.js +78 -0
- package/dist-lib/lib/pickApi.d.ts +89 -0
- package/dist-lib/lib/pickApi.d.ts.map +1 -0
- package/dist-lib/lib/pickApi.js +204 -0
- package/dist-lib/lib/pickTypes.d.ts +165 -0
- package/dist-lib/lib/pickTypes.d.ts.map +1 -0
- package/dist-lib/lib/pickTypes.js +24 -0
- package/dist-lib/lib/utils.d.ts +3 -0
- package/dist-lib/lib/utils.d.ts.map +1 -0
- package/dist-lib/lib/utils.js +5 -0
- package/dist-lib/lib/validationSchemas.d.ts +15 -0
- package/dist-lib/lib/validationSchemas.d.ts.map +1 -0
- package/dist-lib/lib/validationSchemas.js +25 -0
- package/dist-lib/styles.css +1 -0
- package/package.json +107 -0
- package/public/logo.png +0 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
export const Constants = {
|
|
2
|
+
public: {
|
|
3
|
+
Enums: {
|
|
4
|
+
ai_import_status: [
|
|
5
|
+
"nieuw",
|
|
6
|
+
"verwerken",
|
|
7
|
+
"bevestigen",
|
|
8
|
+
"klaar",
|
|
9
|
+
"mislukt",
|
|
10
|
+
],
|
|
11
|
+
app_role: ["admin", "planner", "monteur", "administratie", "ai_admin"],
|
|
12
|
+
doc_layout_type: [
|
|
13
|
+
"pakbon",
|
|
14
|
+
"factuur",
|
|
15
|
+
"offerte",
|
|
16
|
+
"orderbevestiging",
|
|
17
|
+
"etiket",
|
|
18
|
+
"verzendlabel",
|
|
19
|
+
"productlabel",
|
|
20
|
+
"barcode_label",
|
|
21
|
+
"magazijnlijst",
|
|
22
|
+
"controlelijst",
|
|
23
|
+
"transportdocument",
|
|
24
|
+
"vrij",
|
|
25
|
+
"sticker",
|
|
26
|
+
"productiebon",
|
|
27
|
+
],
|
|
28
|
+
doc_orientation: ["portrait", "landscape"],
|
|
29
|
+
exact_env: ["staging", "live"],
|
|
30
|
+
exact_push_status: ["pending", "sent", "error"],
|
|
31
|
+
itk_customer_segment: ["Business", "Private"],
|
|
32
|
+
itk_dynamic_field_type: ["text", "select", "date", "checkbox"],
|
|
33
|
+
planning_item_status: [
|
|
34
|
+
"gepland",
|
|
35
|
+
"bezig",
|
|
36
|
+
"afgerond",
|
|
37
|
+
"geannuleerd",
|
|
38
|
+
"concept",
|
|
39
|
+
"vrijgegeven",
|
|
40
|
+
],
|
|
41
|
+
print_job_status: [
|
|
42
|
+
"wachtend",
|
|
43
|
+
"bezig",
|
|
44
|
+
"voltooid",
|
|
45
|
+
"mislukt",
|
|
46
|
+
"geannuleerd",
|
|
47
|
+
],
|
|
48
|
+
printer_connection: [
|
|
49
|
+
"ipp",
|
|
50
|
+
"raw9100",
|
|
51
|
+
"printnode",
|
|
52
|
+
"cups",
|
|
53
|
+
"usb",
|
|
54
|
+
"windows",
|
|
55
|
+
"airprint",
|
|
56
|
+
"cloud",
|
|
57
|
+
],
|
|
58
|
+
printer_kind: [
|
|
59
|
+
"labelprinter",
|
|
60
|
+
"laserprinter",
|
|
61
|
+
"inkjet",
|
|
62
|
+
"thermal",
|
|
63
|
+
"kantoorprinter",
|
|
64
|
+
"overig",
|
|
65
|
+
],
|
|
66
|
+
quote_status: [
|
|
67
|
+
"concept",
|
|
68
|
+
"verzonden",
|
|
69
|
+
"bekeken",
|
|
70
|
+
"in_behandeling",
|
|
71
|
+
"geaccepteerd",
|
|
72
|
+
"afgewezen",
|
|
73
|
+
"verlopen",
|
|
74
|
+
"gearchiveerd",
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { supabase } from "@flowselections/core";
|
|
2
|
+
import type { PickCountry, PickDashboardRow, PickDocumentType, PickLock, PickPrinter, PickQueueItem, PickScreen, PickSortRule, PickStation, PickStationType, PickStatus, PickTask } from "./pickTypes";
|
|
3
|
+
declare const db: {
|
|
4
|
+
from: (t: string) => any;
|
|
5
|
+
rpc: (fn: string, args?: Record<string, unknown>) => Promise<{
|
|
6
|
+
data: any;
|
|
7
|
+
error: any;
|
|
8
|
+
}>;
|
|
9
|
+
channel: (name: string) => any;
|
|
10
|
+
removeChannel: (c: any) => void;
|
|
11
|
+
auth: typeof supabase.auth;
|
|
12
|
+
};
|
|
13
|
+
export { db as pickDb };
|
|
14
|
+
export declare const pickApi: {
|
|
15
|
+
countries(): Promise<PickCountry[]>;
|
|
16
|
+
statuses(): Promise<PickStatus[]>;
|
|
17
|
+
printers(): Promise<PickPrinter[]>;
|
|
18
|
+
documentTypes(): Promise<PickDocumentType[]>;
|
|
19
|
+
stationTypes(): Promise<PickStationType[]>;
|
|
20
|
+
tasks(): Promise<PickTask[]>;
|
|
21
|
+
stations(): Promise<PickStation[]>;
|
|
22
|
+
screens(stationId?: string): Promise<PickScreen[]>;
|
|
23
|
+
screenDocumentTypes(screenId: string): Promise<{
|
|
24
|
+
document_type_id: string;
|
|
25
|
+
print_order: number;
|
|
26
|
+
printer_id: string | null;
|
|
27
|
+
}[]>;
|
|
28
|
+
locks(stationId?: string): Promise<PickLock[]>;
|
|
29
|
+
dashboard(): Promise<PickDashboardRow[]>;
|
|
30
|
+
countryCounts(screenId: string): Promise<Record<string, number>>;
|
|
31
|
+
/** Server-side gefilterde, gepagineerde wachtrij. */
|
|
32
|
+
queue(params: {
|
|
33
|
+
screenId?: string;
|
|
34
|
+
stationId?: string;
|
|
35
|
+
country?: string | null;
|
|
36
|
+
search?: string;
|
|
37
|
+
documentTypeId?: string | null;
|
|
38
|
+
urgentOnly?: boolean;
|
|
39
|
+
includeDone?: boolean;
|
|
40
|
+
sortRules?: PickSortRule[];
|
|
41
|
+
page?: number;
|
|
42
|
+
pageSize?: number;
|
|
43
|
+
}): Promise<{
|
|
44
|
+
items: PickQueueItem[];
|
|
45
|
+
total: number;
|
|
46
|
+
}>;
|
|
47
|
+
claimNext(args: {
|
|
48
|
+
stationId: string | null;
|
|
49
|
+
screenId: string | null;
|
|
50
|
+
country: string | null;
|
|
51
|
+
sessionId: string;
|
|
52
|
+
timeout: number;
|
|
53
|
+
}): Promise<PickQueueItem>;
|
|
54
|
+
claim(args: {
|
|
55
|
+
itemId: string;
|
|
56
|
+
stationId: string | null;
|
|
57
|
+
screenId: string | null;
|
|
58
|
+
sessionId: string;
|
|
59
|
+
timeout: number;
|
|
60
|
+
}): Promise<PickQueueItem>;
|
|
61
|
+
completePrint(itemId: string, printerId: string | null, sessionId: string): Promise<PickQueueItem>;
|
|
62
|
+
releaseLock(itemId: string): Promise<void>;
|
|
63
|
+
cancelItem(itemId: string): Promise<void>;
|
|
64
|
+
log(entry: Record<string, unknown>): Promise<void>;
|
|
65
|
+
heartbeat(args: {
|
|
66
|
+
stationId: string;
|
|
67
|
+
screenId: string | null;
|
|
68
|
+
sessionId: string;
|
|
69
|
+
}): Promise<void>;
|
|
70
|
+
heartbeats(): Promise<{
|
|
71
|
+
id: string;
|
|
72
|
+
station_id: string;
|
|
73
|
+
screen_id: string | null;
|
|
74
|
+
session_id: string;
|
|
75
|
+
last_seen_at: string;
|
|
76
|
+
}[]>;
|
|
77
|
+
logs(limit?: number): Promise<{
|
|
78
|
+
id: string;
|
|
79
|
+
action: string;
|
|
80
|
+
created_at: string;
|
|
81
|
+
user_id: string | null;
|
|
82
|
+
queue_item_id: string | null;
|
|
83
|
+
station_id: string | null;
|
|
84
|
+
}[]>;
|
|
85
|
+
upsert(table: string, row: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
86
|
+
remove(table: string, id: string): Promise<void>;
|
|
87
|
+
};
|
|
88
|
+
export declare function getSessionId(): string;
|
|
89
|
+
//# sourceMappingURL=pickApi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pickApi.d.ts","sourceRoot":"","sources":["../../src/lib/pickApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EA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AAC,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB;;;;oBAuCqB;QACpB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;QACzB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;QACxB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;QACvB,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;KACjB;gBAYiB;QAChB,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;QACzB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;QACxB,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;KACjB;0BAY2B,MAAM,aAAa,MAAM,GAAG,IAAI,aAAa,MAAM;wBAUrD,MAAM;uBAKP,MAAM;eAWd,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;oBAOlB;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE;;YAiB/E,MAAM;oBACE,MAAM;mBACP,MAAM,GAAG,IAAI;oBACZ,MAAM;sBACJ,MAAM;;;YAMhB,MAAM;gBACF,MAAM;oBACF,MAAM;iBACT,MAAM,GAAG,IAAI;uBACP,MAAM,GAAG,IAAI;oBAChB,MAAM,GAAG,IAAI;;kBAIT,MAAM,OAAO,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;kBAMpC,MAAM,MAAM,MAAM;CAIvC,CAAC;AAEF,wBAAgB,YAAY,IAAI,MAAM,CASrC"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { supabase } from "@flowselections/core";
|
|
2
|
+
import { safeArray } from "./pickTypes";
|
|
3
|
+
// De core-client is getypeerd op het core-schema; deze module gebruikt eigen tabellen.
|
|
4
|
+
const db = supabase;
|
|
5
|
+
export { db as pickDb };
|
|
6
|
+
function unwrap(res) {
|
|
7
|
+
if (res.error)
|
|
8
|
+
throw new Error(res.error.message);
|
|
9
|
+
return safeArray(res.data);
|
|
10
|
+
}
|
|
11
|
+
export const pickApi = {
|
|
12
|
+
async countries() {
|
|
13
|
+
return unwrap(await db.from("pick_countries").select("*").eq("active", true).order("sort_order"));
|
|
14
|
+
},
|
|
15
|
+
async statuses() {
|
|
16
|
+
return unwrap(await db.from("pick_document_statuses").select("*").order("sort_order"));
|
|
17
|
+
},
|
|
18
|
+
async printers() {
|
|
19
|
+
return unwrap(await db.from("pick_station_printers").select("*").order("name"));
|
|
20
|
+
},
|
|
21
|
+
async documentTypes() {
|
|
22
|
+
return unwrap(await db.from("pick_document_types").select("*").order("sort_order"));
|
|
23
|
+
},
|
|
24
|
+
async stationTypes() {
|
|
25
|
+
return unwrap(await db.from("pick_station_types").select("*").order("sort_order"));
|
|
26
|
+
},
|
|
27
|
+
async tasks() {
|
|
28
|
+
return unwrap(await db.from("pick_station_tasks").select("*").order("sort_order"));
|
|
29
|
+
},
|
|
30
|
+
async stations() {
|
|
31
|
+
return unwrap(await db.from("pick_stations").select("*").order("sort_order"));
|
|
32
|
+
},
|
|
33
|
+
async screens(stationId) {
|
|
34
|
+
let q = db.from("pick_station_screens").select("*").order("sort_order");
|
|
35
|
+
if (stationId)
|
|
36
|
+
q = q.eq("station_id", stationId);
|
|
37
|
+
return unwrap(await q);
|
|
38
|
+
},
|
|
39
|
+
async screenDocumentTypes(screenId) {
|
|
40
|
+
return unwrap(await db.from("pick_screen_document_types").select("*").eq("screen_id", screenId).order("print_order"));
|
|
41
|
+
},
|
|
42
|
+
async locks(stationId) {
|
|
43
|
+
let q = db.from("pick_queue_locks").select("*");
|
|
44
|
+
if (stationId)
|
|
45
|
+
q = q.eq("station_id", stationId);
|
|
46
|
+
return unwrap(await q);
|
|
47
|
+
},
|
|
48
|
+
async dashboard() {
|
|
49
|
+
const { data, error } = await db.rpc("pick_station_dashboard");
|
|
50
|
+
if (error)
|
|
51
|
+
throw new Error(error.message);
|
|
52
|
+
return safeArray(data);
|
|
53
|
+
},
|
|
54
|
+
async countryCounts(screenId) {
|
|
55
|
+
const rows = unwrap(await db
|
|
56
|
+
.from("pick_queue")
|
|
57
|
+
.select("country_code")
|
|
58
|
+
.eq("screen_id", screenId)
|
|
59
|
+
.is("printed_at", null)
|
|
60
|
+
.is("cancelled_at", null)
|
|
61
|
+
.limit(5000));
|
|
62
|
+
const counts = {};
|
|
63
|
+
for (const r of rows) {
|
|
64
|
+
const c = r.country_code ?? "??";
|
|
65
|
+
counts[c] = (counts[c] ?? 0) + 1;
|
|
66
|
+
}
|
|
67
|
+
return counts;
|
|
68
|
+
},
|
|
69
|
+
/** Server-side gefilterde, gepagineerde wachtrij. */
|
|
70
|
+
async queue(params) {
|
|
71
|
+
const pageSize = params.pageSize ?? 50;
|
|
72
|
+
const page = params.page ?? 0;
|
|
73
|
+
let q = db.from("pick_queue").select("*", { count: "exact" });
|
|
74
|
+
if (params.screenId)
|
|
75
|
+
q = q.eq("screen_id", params.screenId);
|
|
76
|
+
if (params.stationId)
|
|
77
|
+
q = q.eq("station_id", params.stationId);
|
|
78
|
+
if (params.country)
|
|
79
|
+
q = q.eq("country_code", params.country);
|
|
80
|
+
if (params.documentTypeId)
|
|
81
|
+
q = q.eq("document_type_id", params.documentTypeId);
|
|
82
|
+
if (params.urgentOnly)
|
|
83
|
+
q = q.eq("is_urgent", true);
|
|
84
|
+
if (!params.includeDone)
|
|
85
|
+
q = q.is("printed_at", null).is("cancelled_at", null);
|
|
86
|
+
if (params.search) {
|
|
87
|
+
const s = `%${params.search}%`;
|
|
88
|
+
q = q.or([
|
|
89
|
+
`document_number.ilike.${s}`,
|
|
90
|
+
`order_number.ilike.${s}`,
|
|
91
|
+
`customer_name.ilike.${s}`,
|
|
92
|
+
`reference.ilike.${s}`,
|
|
93
|
+
`barcode.ilike.${s}`,
|
|
94
|
+
].join(","));
|
|
95
|
+
}
|
|
96
|
+
const rules = params.sortRules?.length
|
|
97
|
+
? params.sortRules
|
|
98
|
+
: [
|
|
99
|
+
{ field: "is_urgent", direction: "desc" },
|
|
100
|
+
{ field: "priority", direction: "asc" },
|
|
101
|
+
{ field: "announced_at", direction: "asc" },
|
|
102
|
+
];
|
|
103
|
+
for (const r of rules)
|
|
104
|
+
q = q.order(r.field, { ascending: r.direction !== "desc" });
|
|
105
|
+
q = q.range(page * pageSize, page * pageSize + pageSize - 1);
|
|
106
|
+
const res = await q;
|
|
107
|
+
if (res.error)
|
|
108
|
+
throw new Error(res.error.message);
|
|
109
|
+
return { items: safeArray(res.data), total: res.count ?? 0 };
|
|
110
|
+
},
|
|
111
|
+
async claimNext(args) {
|
|
112
|
+
const { data, error } = await db.rpc("pick_claim_next_document", {
|
|
113
|
+
_station_id: args.stationId,
|
|
114
|
+
_screen_id: args.screenId,
|
|
115
|
+
_country_code: args.country,
|
|
116
|
+
_session_id: args.sessionId,
|
|
117
|
+
_timeout_seconds: args.timeout,
|
|
118
|
+
});
|
|
119
|
+
if (error)
|
|
120
|
+
throw new Error(error.message);
|
|
121
|
+
return data;
|
|
122
|
+
},
|
|
123
|
+
async claim(args) {
|
|
124
|
+
const { data, error } = await db.rpc("pick_claim_document", {
|
|
125
|
+
_queue_item_id: args.itemId,
|
|
126
|
+
_station_id: args.stationId,
|
|
127
|
+
_screen_id: args.screenId,
|
|
128
|
+
_session_id: args.sessionId,
|
|
129
|
+
_timeout_seconds: args.timeout,
|
|
130
|
+
});
|
|
131
|
+
if (error)
|
|
132
|
+
throw new Error(error.message);
|
|
133
|
+
return data;
|
|
134
|
+
},
|
|
135
|
+
async completePrint(itemId, printerId, sessionId) {
|
|
136
|
+
const { data, error } = await db.rpc("pick_complete_print", {
|
|
137
|
+
_queue_item_id: itemId,
|
|
138
|
+
_printer_id: printerId,
|
|
139
|
+
_session_id: sessionId,
|
|
140
|
+
});
|
|
141
|
+
if (error)
|
|
142
|
+
throw new Error(error.message);
|
|
143
|
+
return data;
|
|
144
|
+
},
|
|
145
|
+
async releaseLock(itemId) {
|
|
146
|
+
const { error } = await db.rpc("pick_release_lock", { _queue_item_id: itemId });
|
|
147
|
+
if (error)
|
|
148
|
+
throw new Error(error.message);
|
|
149
|
+
},
|
|
150
|
+
async cancelItem(itemId) {
|
|
151
|
+
const cancelled = unwrap(await db.from("pick_document_statuses").select("*").eq("code", "cancelled").limit(1))[0];
|
|
152
|
+
const res = await db
|
|
153
|
+
.from("pick_queue")
|
|
154
|
+
.update({ cancelled_at: new Date().toISOString(), status_id: cancelled?.id ?? null })
|
|
155
|
+
.eq("id", itemId);
|
|
156
|
+
if (res.error)
|
|
157
|
+
throw new Error(res.error.message);
|
|
158
|
+
},
|
|
159
|
+
async log(entry) {
|
|
160
|
+
await db.from("pick_station_logs").insert({
|
|
161
|
+
...entry,
|
|
162
|
+
browser: typeof navigator !== "undefined" ? navigator.userAgent : null,
|
|
163
|
+
});
|
|
164
|
+
},
|
|
165
|
+
async heartbeat(args) {
|
|
166
|
+
const { data } = await db.auth.getUser();
|
|
167
|
+
await db.from("pick_station_heartbeats").upsert({
|
|
168
|
+
station_id: args.stationId,
|
|
169
|
+
screen_id: args.screenId,
|
|
170
|
+
session_id: args.sessionId,
|
|
171
|
+
user_id: data?.user?.id ?? null,
|
|
172
|
+
browser: typeof navigator !== "undefined" ? navigator.userAgent : null,
|
|
173
|
+
last_seen_at: new Date().toISOString(),
|
|
174
|
+
}, { onConflict: "session_id" });
|
|
175
|
+
},
|
|
176
|
+
async heartbeats() {
|
|
177
|
+
return unwrap(await db.from("pick_station_heartbeats").select("*").order("last_seen_at", { ascending: false }));
|
|
178
|
+
},
|
|
179
|
+
async logs(limit = 100) {
|
|
180
|
+
return unwrap(await db.from("pick_station_logs").select("*").order("created_at", { ascending: false }).limit(limit));
|
|
181
|
+
},
|
|
182
|
+
async upsert(table, row) {
|
|
183
|
+
const res = await db.from(table).upsert(row).select();
|
|
184
|
+
if (res.error)
|
|
185
|
+
throw new Error(res.error.message);
|
|
186
|
+
return safeArray(res.data)[0];
|
|
187
|
+
},
|
|
188
|
+
async remove(table, id) {
|
|
189
|
+
const res = await db.from(table).delete().eq("id", id);
|
|
190
|
+
if (res.error)
|
|
191
|
+
throw new Error(res.error.message);
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
export function getSessionId() {
|
|
195
|
+
if (typeof window === "undefined")
|
|
196
|
+
return "ssr";
|
|
197
|
+
const key = "pick_session_id";
|
|
198
|
+
let id = window.sessionStorage.getItem(key);
|
|
199
|
+
if (!id) {
|
|
200
|
+
id = crypto.randomUUID();
|
|
201
|
+
window.sessionStorage.setItem(key, id);
|
|
202
|
+
}
|
|
203
|
+
return id;
|
|
204
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
export interface PickCountry {
|
|
2
|
+
id: string;
|
|
3
|
+
code: string;
|
|
4
|
+
name: string;
|
|
5
|
+
flag: string | null;
|
|
6
|
+
sort_order: number;
|
|
7
|
+
active: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface PickStatus {
|
|
10
|
+
id: string;
|
|
11
|
+
code: string;
|
|
12
|
+
name: string;
|
|
13
|
+
color: string | null;
|
|
14
|
+
sort_order: number;
|
|
15
|
+
is_open: boolean;
|
|
16
|
+
is_terminal: boolean;
|
|
17
|
+
active: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface PickPrinter {
|
|
20
|
+
id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
code: string | null;
|
|
23
|
+
location: string | null;
|
|
24
|
+
connection: string | null;
|
|
25
|
+
status: string;
|
|
26
|
+
status_message: string | null;
|
|
27
|
+
last_seen_at: string | null;
|
|
28
|
+
active: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface PickDocumentType {
|
|
31
|
+
id: string;
|
|
32
|
+
code: string;
|
|
33
|
+
name: string;
|
|
34
|
+
description: string | null;
|
|
35
|
+
report_key: string | null;
|
|
36
|
+
print_template: string | null;
|
|
37
|
+
printer_id: string | null;
|
|
38
|
+
priority: number;
|
|
39
|
+
color: string | null;
|
|
40
|
+
icon: string | null;
|
|
41
|
+
sort_order: number;
|
|
42
|
+
active: boolean;
|
|
43
|
+
}
|
|
44
|
+
export interface PickStationType {
|
|
45
|
+
id: string;
|
|
46
|
+
code: string;
|
|
47
|
+
name: string;
|
|
48
|
+
description: string | null;
|
|
49
|
+
icon: string | null;
|
|
50
|
+
color: string | null;
|
|
51
|
+
sort_order: number;
|
|
52
|
+
active: boolean;
|
|
53
|
+
}
|
|
54
|
+
export interface PickTask {
|
|
55
|
+
id: string;
|
|
56
|
+
code: string;
|
|
57
|
+
name: string;
|
|
58
|
+
description: string | null;
|
|
59
|
+
icon: string | null;
|
|
60
|
+
color: string | null;
|
|
61
|
+
workflow: Record<string, unknown>;
|
|
62
|
+
sort_order: number;
|
|
63
|
+
active: boolean;
|
|
64
|
+
}
|
|
65
|
+
export interface PickStation {
|
|
66
|
+
id: string;
|
|
67
|
+
name: string;
|
|
68
|
+
description: string | null;
|
|
69
|
+
type_id: string | null;
|
|
70
|
+
task_id: string | null;
|
|
71
|
+
location: string | null;
|
|
72
|
+
department: string | null;
|
|
73
|
+
color: string | null;
|
|
74
|
+
icon: string | null;
|
|
75
|
+
sort_order: number;
|
|
76
|
+
allow_multi_screen: boolean;
|
|
77
|
+
default_printer_id: string | null;
|
|
78
|
+
sort_rules: PickSortRule[];
|
|
79
|
+
lock_timeout_seconds: number;
|
|
80
|
+
require_country_selection: boolean;
|
|
81
|
+
active: boolean;
|
|
82
|
+
}
|
|
83
|
+
export interface PickSortRule {
|
|
84
|
+
field: string;
|
|
85
|
+
direction: "asc" | "desc";
|
|
86
|
+
}
|
|
87
|
+
export interface PickScreen {
|
|
88
|
+
id: string;
|
|
89
|
+
station_id: string;
|
|
90
|
+
name: string;
|
|
91
|
+
description: string | null;
|
|
92
|
+
screen_type: string;
|
|
93
|
+
printer_id: string | null;
|
|
94
|
+
filters: Record<string, unknown>;
|
|
95
|
+
sort_rules: PickSortRule[] | null;
|
|
96
|
+
sort_order: number;
|
|
97
|
+
active: boolean;
|
|
98
|
+
}
|
|
99
|
+
export interface PickQueueItem {
|
|
100
|
+
id: string;
|
|
101
|
+
station_id: string | null;
|
|
102
|
+
screen_id: string | null;
|
|
103
|
+
document_type_id: string | null;
|
|
104
|
+
status_id: string | null;
|
|
105
|
+
document_number: string | null;
|
|
106
|
+
order_number: string | null;
|
|
107
|
+
reference: string | null;
|
|
108
|
+
barcode: string | null;
|
|
109
|
+
customer_name: string | null;
|
|
110
|
+
delivery_address: string | null;
|
|
111
|
+
country_code: string | null;
|
|
112
|
+
route: string | null;
|
|
113
|
+
order_type: string | null;
|
|
114
|
+
line_count: number;
|
|
115
|
+
cart_count: number;
|
|
116
|
+
priority: number;
|
|
117
|
+
is_urgent: boolean;
|
|
118
|
+
announced_at: string;
|
|
119
|
+
due_at: string | null;
|
|
120
|
+
assigned_user_id: string | null;
|
|
121
|
+
printed_at: string | null;
|
|
122
|
+
printer_id: string | null;
|
|
123
|
+
print_count: number;
|
|
124
|
+
warnings: string[];
|
|
125
|
+
cancelled_at: string | null;
|
|
126
|
+
created_at: string;
|
|
127
|
+
}
|
|
128
|
+
export interface PickLock {
|
|
129
|
+
id: string;
|
|
130
|
+
queue_item_id: string;
|
|
131
|
+
station_id: string | null;
|
|
132
|
+
screen_id: string | null;
|
|
133
|
+
session_id: string | null;
|
|
134
|
+
locked_by: string | null;
|
|
135
|
+
locked_at: string;
|
|
136
|
+
expires_at: string;
|
|
137
|
+
}
|
|
138
|
+
export interface PickDashboardRow {
|
|
139
|
+
station_id: string;
|
|
140
|
+
station_name: string;
|
|
141
|
+
waiting: number;
|
|
142
|
+
active: number;
|
|
143
|
+
done_today: number;
|
|
144
|
+
avg_wait_seconds: number;
|
|
145
|
+
active_sessions: number;
|
|
146
|
+
}
|
|
147
|
+
export interface PickPermission {
|
|
148
|
+
id: string;
|
|
149
|
+
user_id: string;
|
|
150
|
+
station_id: string | null;
|
|
151
|
+
task_id: string | null;
|
|
152
|
+
country_code: string | null;
|
|
153
|
+
urgent_only: boolean;
|
|
154
|
+
can_print: boolean;
|
|
155
|
+
can_reprint: boolean;
|
|
156
|
+
can_break_lock: boolean;
|
|
157
|
+
can_cancel: boolean;
|
|
158
|
+
}
|
|
159
|
+
export declare const SORT_FIELDS: {
|
|
160
|
+
value: string;
|
|
161
|
+
label: string;
|
|
162
|
+
}[];
|
|
163
|
+
export declare function safeArray<T>(value: unknown): T[];
|
|
164
|
+
export declare function sinceLabel(iso: string | null): string;
|
|
165
|
+
//# sourceMappingURL=pickTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pickTypes.d.ts","sourceRoot":"","sources":["../../src/lib/pickTypes.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,GAAG,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AAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,cAAc,EAAE,OAAO,CAAC;IACxB,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,WAAW,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EASzD,CAAC;AAEF,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,CAAC,EAAE,CAEhD;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAMrD"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Types voor de Pickstations-module. Alles is database-gestuurd; deze types
|
|
2
|
+
// beschrijven alleen de vorm van de rijen, nooit vaste waardes.
|
|
3
|
+
export const SORT_FIELDS = [
|
|
4
|
+
{ value: "is_urgent", label: "Spoed eerst" },
|
|
5
|
+
{ value: "priority", label: "Prioriteit" },
|
|
6
|
+
{ value: "announced_at", label: "Aanmeldmoment" },
|
|
7
|
+
{ value: "created_at", label: "Aanmaakmoment" },
|
|
8
|
+
{ value: "customer_name", label: "Klant" },
|
|
9
|
+
{ value: "route", label: "Route" },
|
|
10
|
+
{ value: "country_code", label: "Land" },
|
|
11
|
+
{ value: "cart_count", label: "Aantal karren" },
|
|
12
|
+
];
|
|
13
|
+
export function safeArray(value) {
|
|
14
|
+
return Array.isArray(value) ? value : [];
|
|
15
|
+
}
|
|
16
|
+
export function sinceLabel(iso) {
|
|
17
|
+
if (!iso)
|
|
18
|
+
return "-";
|
|
19
|
+
const mins = Math.max(0, Math.floor((Date.now() - new Date(iso).getTime()) / 60000));
|
|
20
|
+
if (mins < 60)
|
|
21
|
+
return `${mins} min`;
|
|
22
|
+
const h = Math.floor(mins / 60);
|
|
23
|
+
return `${h}u ${mins % 60}m`;
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,MAAM,CAAA;AAG5C,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const loginSchema: z.ZodObject<{
|
|
3
|
+
email: z.ZodString;
|
|
4
|
+
password: z.ZodString;
|
|
5
|
+
}, z.core.$strip>;
|
|
6
|
+
export declare const bugReportSchema: z.ZodObject<{
|
|
7
|
+
title: z.ZodString;
|
|
8
|
+
description: z.ZodString;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
export declare const ALLOWED_FILE_TYPES: string[];
|
|
11
|
+
export declare function validateFileUpload(file: File): {
|
|
12
|
+
valid: boolean;
|
|
13
|
+
error?: string;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=validationSchemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validationSchemas.d.ts","sourceRoot":"","sources":["../../src/lib/validationSchemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,WAAW;;;iBAGtB,CAAC;AAEH,eAAO,MAAM,eAAe;;;iBAG1B,CAAC;AAEH,eAAO,MAAM,kBAAkB,UAK9B,CAAC;AAIF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAQjF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const loginSchema = z.object({
|
|
3
|
+
email: z.string().email("Ongeldig e-mailadres"),
|
|
4
|
+
password: z.string().min(6, "Wachtwoord moet minimaal 6 tekens bevatten"),
|
|
5
|
+
});
|
|
6
|
+
export const bugReportSchema = z.object({
|
|
7
|
+
title: z.string().min(1, "Titel is verplicht").max(200),
|
|
8
|
+
description: z.string().min(1, "Beschrijving is verplicht").max(5000),
|
|
9
|
+
});
|
|
10
|
+
export const ALLOWED_FILE_TYPES = [
|
|
11
|
+
"image/png",
|
|
12
|
+
"image/jpeg",
|
|
13
|
+
"image/gif",
|
|
14
|
+
"application/pdf",
|
|
15
|
+
];
|
|
16
|
+
const MAX_FILE_SIZE = 10 * 1024 * 1024; // 10MB
|
|
17
|
+
export function validateFileUpload(file) {
|
|
18
|
+
if (!ALLOWED_FILE_TYPES.includes(file.type)) {
|
|
19
|
+
return { valid: false, error: "Bestandstype niet toegestaan" };
|
|
20
|
+
}
|
|
21
|
+
if (file.size > MAX_FILE_SIZE) {
|
|
22
|
+
return { valid: false, error: "Bestand is te groot (max 10MB)" };
|
|
23
|
+
}
|
|
24
|
+
return { valid: true };
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@source "./";
|