@flowselections/mailbox-orders 1.0.13 → 1.0.15
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/MailboxFilterBar.d.ts +31 -0
- package/dist-lib/components/MailboxFilterBar.d.ts.map +1 -0
- package/dist-lib/components/MailboxFilterBar.js +67 -0
- package/dist-lib/components/MailboxProcessedPage.d.ts.map +1 -1
- package/dist-lib/components/MailboxProcessedPage.js +41 -5
- package/dist-lib/components/MailboxProposalsPage.d.ts.map +1 -1
- package/dist-lib/components/MailboxProposalsPage.js +38 -28
- package/dist-lib/index.d.ts +1 -0
- package/dist-lib/index.d.ts.map +1 -1
- package/dist-lib/index.js +1 -0
- package/dist-lib/integrations/supabase/client.d.ts +114 -0
- package/dist-lib/integrations/supabase/client.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.server.d.ts +114 -0
- package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/types.d.ts +114 -0
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/mailbox.functions.d.ts.map +1 -1
- package/dist-lib/lib/mailbox.functions.js +35 -5
- package/dist-lib/lib/product-name.d.ts +3 -0
- package/dist-lib/lib/product-name.d.ts.map +1 -0
- package/dist-lib/lib/product-name.js +10 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mailbox.functions.d.ts","sourceRoot":"","sources":["../../src/lib/mailbox.functions.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"mailbox.functions.d.ts","sourceRoot":"","sources":["../../src/lib/mailbox.functions.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AA0B9D,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;QAi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;;uBAhCvG,MAAM;oBACT,MAAM,GAAG,IAAI;sBACX,MAAM;0BAEF,MAAM;0BACN,MAAM;yBACP,MAAM;;;qBA0FW,MAAM;eAClB,MAAM,GAAG,IAAI;;;;GAoBjC,CAAC;AAiBL,eAAO,MAAM,eAAe;;;;8CAEF,OAAO;;;;;;;;;;;;;;;;GAuC7B,CAAC;AAEL,eAAO,MAAM,cAAc;;;;0CAEL;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE;aAAR,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;GAQnC,CAAC;AAEL,eAAO,MAAM,gCAAgC;;;;0CAEvB;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE;gBAAR,MAAM;;;;;;;;;;;;;;;;;;;GAUtC,CAAC;AAKL,eAAO,MAAM,mBAAmB;;;;;;YAqBD,MAAM;;;;;GAQjC,CAAC;AAEL,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;GAS9B,CAAC;AAGL,eAAO,MAAM,gBAAgB;;;;;;GAUzB,CAAC;AAiBL,eAAO,MAAM,8BAA8B;;;;8CAEjB,OAAO;;;;0BAOT,MAAM;0BAAoB,MAAM;yBAAmB,MAAM;oBAC/D,OAAO;oBACP,MAAM,GAAG,IAAI;oBAAc,MAAM,GAAG,IAAI;sBACtC,MAAM,GAAG,IAAI;sBAAgB,MAAM,GAAG,IAAI;;yBAEO,MAAM;yBAAmB,MAAM;;;0BAL5E,MAAM;0BAAoB,MAAM;yBAAmB,MAAM;oBAC/D,OAAO;oBACP,MAAM,GAAG,IAAI;oBAAc,MAAM,GAAG,IAAI;sBACtC,MAAM,GAAG,IAAI;sBAAgB,MAAM,GAAG,IAAI;;;;;GAsM1D,CAAC"}
|
|
@@ -4,7 +4,8 @@ import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware";
|
|
|
4
4
|
import { createClient } from "@supabase/supabase-js";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import { computeEarliestDelivery } from "../lib/delivery-date";
|
|
7
|
-
import {
|
|
7
|
+
import { stripLeadingQuantity } from "../lib/product-name";
|
|
8
|
+
import { emailBodyText, inlineCidImages, normalizeAddressList, normalizeAttachments, sanitizeEmailHtml, stripInvisible, } from "./mailbox-body";
|
|
8
9
|
import { EMPTY_LOAD_CARRIERS, isLoadCarrierAllowed, loadCarrierLabel, normalizeAllowedLoadCarriers, } from "./load-carriers";
|
|
9
10
|
// ─── Actieve mailbox (uit gedeelde e-mail-auth module) ──────────────────────
|
|
10
11
|
// Geen auth-middleware: de RPC is SECURITY DEFINER en EXECUTE staat ook aan
|
|
@@ -149,8 +150,8 @@ export const listProposals = createServerFn({ method: "GET" })
|
|
|
149
150
|
const sel = (s) => s;
|
|
150
151
|
let q = supabaseAdmin
|
|
151
152
|
.from("mailbox_order_proposals")
|
|
152
|
-
.select(sel("id, status, created_at, matched_customer_id, ai_ok:parsed_payload->ai->>ok, " +
|
|
153
|
-
"mailbox_messages(subject, from_email, from_name, received_at, connection_id), " +
|
|
153
|
+
.select(sel("id, status, created_at, reviewed_at, matched_customer_id, ai_ok:parsed_payload->ai->>ok, " +
|
|
154
|
+
"mailbox_messages(subject, from_email, from_name, received_at, connection_id, body_text), " +
|
|
154
155
|
"mailbox_proposal_field_values(field_key, value, needs_review)"))
|
|
155
156
|
.order("created_at", { ascending: false })
|
|
156
157
|
.limit(200);
|
|
@@ -159,7 +160,19 @@ export const listProposals = createServerFn({ method: "GET" })
|
|
|
159
160
|
const { data: rows, error } = await q;
|
|
160
161
|
if (error)
|
|
161
162
|
throw new Error(error.message);
|
|
162
|
-
|
|
163
|
+
// Korte preview (Outlook-stijl) i.p.v. de volledige mailtekst meesturen.
|
|
164
|
+
const items = (Array.isArray(rows) ? rows : []).map((row) => {
|
|
165
|
+
const m = row?.mailbox_messages;
|
|
166
|
+
if (!m)
|
|
167
|
+
return row;
|
|
168
|
+
const { body_text, ...rest } = m;
|
|
169
|
+
const preview = stripInvisible(String(body_text ?? ""))
|
|
170
|
+
.replace(/\s+/g, " ")
|
|
171
|
+
.trim()
|
|
172
|
+
.slice(0, 180);
|
|
173
|
+
return { ...row, mailbox_messages: { ...rest, preview } };
|
|
174
|
+
});
|
|
175
|
+
return { items };
|
|
163
176
|
});
|
|
164
177
|
/** Eén voorstel volledig: mailtekst, bestelregels en veldwaarden. */
|
|
165
178
|
export const getProposalDetail = createServerFn({ method: "GET" })
|
|
@@ -331,10 +344,27 @@ export const approveProposal = createServerFn({ method: "POST" })
|
|
|
331
344
|
}).select("id").single();
|
|
332
345
|
if (orderErr)
|
|
333
346
|
throw new Error(orderErr.message);
|
|
347
|
+
// Productnaam altijd uit de catalogus; alleen zonder koppeling terugvallen
|
|
348
|
+
// op de (opgeschoonde) tekst uit de mail.
|
|
349
|
+
const linkedIds = Array.from(new Set(data.lines.map((l) => l.product_id).filter((v) => !!v)));
|
|
350
|
+
const nameById = new Map();
|
|
351
|
+
if (linkedIds.length > 0) {
|
|
352
|
+
const { data: prodRows } = await supabaseAdmin
|
|
353
|
+
.from("products")
|
|
354
|
+
.select("id, product")
|
|
355
|
+
.in("id", linkedIds);
|
|
356
|
+
for (const p of Array.isArray(prodRows) ? prodRows : []) {
|
|
357
|
+
const n = typeof p?.product === "string" ? p.product.trim() : "";
|
|
358
|
+
if (n)
|
|
359
|
+
nameById.set(String(p.id), n);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
334
362
|
const items = data.lines.map((l) => ({
|
|
335
363
|
order_id: order.id,
|
|
336
364
|
product_id: l.product_id,
|
|
337
|
-
product_name: l.
|
|
365
|
+
product_name: (l.product_id ? nameById.get(l.product_id) : null) ||
|
|
366
|
+
stripLeadingQuantity(l.raw_product_text) ||
|
|
367
|
+
"Onbekend product",
|
|
338
368
|
quantity: Math.max(1, Math.round(l.quantity ?? 1)),
|
|
339
369
|
unit: l.unit ?? "stuks",
|
|
340
370
|
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-name.d.ts","sourceRoot":"","sources":["../../src/lib/product-name.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAO5E"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Haalt een aantal-prefix ("3x ", "3 x ", "10 stuks ") weg uit ruwe mailtekst. */
|
|
2
|
+
export function stripLeadingQuantity(text) {
|
|
3
|
+
const t = (text ?? "").trim();
|
|
4
|
+
if (!t)
|
|
5
|
+
return "";
|
|
6
|
+
const cleaned = t
|
|
7
|
+
.replace(/^\d+[.,]?\d*\s*(x|st|stk|stuks|stuk|planten|plant|fust|fusten|pcs)?\s*[-:·]?\s*/i, "")
|
|
8
|
+
.trim();
|
|
9
|
+
return cleaned || t;
|
|
10
|
+
}
|