@burdenoff/microfe-healthybowl 2026.717.2 → 2026.717.3
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/healthybowl/hooks/useOrderShipment.js +56 -0
- package/dist/healthybowl/hooks/useOrderShipment.js.map +1 -0
- package/dist/healthybowl/pages/marketplace/OrdersPage.js +299 -394
- package/dist/healthybowl/pages/marketplace/OrdersPage.js.map +1 -1
- package/dist/healthybowl/pages/marketplace/ShipmentTrackingPanel.js +213 -0
- package/dist/healthybowl/pages/marketplace/ShipmentTrackingPanel.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { useHealthyBowl as e } from "../context/HealthyBowlContext.js";
|
|
2
|
+
import { useCallback as t } from "react";
|
|
3
|
+
import { gql as n } from "@apollo/client";
|
|
4
|
+
import { useMutation as r, useQuery as i } from "@apollo/client/react";
|
|
5
|
+
//#region src/healthybowl/hooks/useOrderShipment.ts
|
|
6
|
+
var a = "\n orderId\n hasShipment\n shipmentId\n shipmentNumber\n trackingNumber\n status\n estimatedDelivery\n actualDelivery\n timeline {\n id\n eventType\n timestamp\n details\n location\n }\n coldChain {\n temperatureControlled\n targetMin\n targetMax\n unit\n currentTemperature\n readingAt\n breach\n }\n", o = n`
|
|
7
|
+
query HealthyBowlOrderShipment($orderId: ID!, $context: ContextInput!) {
|
|
8
|
+
healthyBowlOrderShipment(orderId: $orderId, context: $context) {
|
|
9
|
+
${a}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
`, s = n`
|
|
13
|
+
mutation CreateHealthyBowlOrderShipment($orderId: ID!, $perishable: Boolean, $context: ContextInput!) {
|
|
14
|
+
createHealthyBowlOrderShipment(orderId: $orderId, perishable: $perishable, context: $context) {
|
|
15
|
+
${a}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
`;
|
|
19
|
+
function c(n) {
|
|
20
|
+
let { workspaceId: a } = e(), c = { workspaceId: a }, { data: l, loading: u, error: d, refetch: f } = i(o, {
|
|
21
|
+
variables: {
|
|
22
|
+
orderId: n ?? "",
|
|
23
|
+
context: c
|
|
24
|
+
},
|
|
25
|
+
skip: !n || !a,
|
|
26
|
+
fetchPolicy: "cache-and-network",
|
|
27
|
+
errorPolicy: "all",
|
|
28
|
+
notifyOnNetworkStatusChange: !0
|
|
29
|
+
}), [p, { loading: m }] = r(s), h = t(async (e) => {
|
|
30
|
+
if (!n) throw Error("No order selected");
|
|
31
|
+
let t = (await p({ variables: {
|
|
32
|
+
orderId: n,
|
|
33
|
+
perishable: e ?? null,
|
|
34
|
+
context: c
|
|
35
|
+
} })).data?.createHealthyBowlOrderShipment;
|
|
36
|
+
if (!t) throw Error("Could not arrange the shipment");
|
|
37
|
+
return await f().catch(() => void 0), t;
|
|
38
|
+
}, [
|
|
39
|
+
p,
|
|
40
|
+
n,
|
|
41
|
+
a,
|
|
42
|
+
f
|
|
43
|
+
]);
|
|
44
|
+
return {
|
|
45
|
+
shipment: l?.healthyBowlOrderShipment ?? null,
|
|
46
|
+
loading: u,
|
|
47
|
+
error: d ? d.message : null,
|
|
48
|
+
refetch: f,
|
|
49
|
+
createShipment: h,
|
|
50
|
+
creating: m
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
export { c as useOrderShipment };
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=useOrderShipment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOrderShipment.js","names":[],"sources":["../../../src/healthybowl/hooks/useOrderShipment.ts"],"sourcesContent":["/**\n * Buyer shipment tracking + cold-chain (roadmap #17, D-4).\n *\n * A fulfilled order maps to a REAL wspace-movethewheels-svc Shipment (created + read by the HB\n * backend over the internal wspace gateway — HB owns only the order→shipment mapping, never the\n * logistics data). This hook exposes:\n *\n * - `shipment` — the movethewheels Shipment status + ordered TrackingEvent timeline\n * (picked-up → in-transit → out-for-delivery → delivered) + cold-chain surface, or\n * `hasShipment: false` when none exists yet (the UI shows an empty state).\n * - `createShipment(perishable?)` — arrange the shipment for the order (seller action). Perishable\n * produce (the default) maps to a temperature-controlled shipment.\n *\n * These operations post-date the checked-in SDL, so — mirroring `useOrderPayments` — they are\n * hand-written `gql` documents executed directly against the live gateway.\n * @module healthybowl\n */\nimport { useCallback } from 'react';\nimport { gql } from '@apollo/client';\nimport { useMutation, useQuery } from '@apollo/client/react';\nimport { useHealthyBowl } from '../context/HealthyBowlContext';\n\n/** One ordered step in the shipment tracking timeline, from a real movethewheels TrackingEvent. */\nexport interface ShipmentTrackingEvent {\n id: string;\n /** PICKED_UP | IN_TRANSIT | OUT_FOR_DELIVERY | DELIVERED | ARRIVED | DEPARTED | FAILED | RETURNED | CREATED. */\n eventType: string;\n timestamp: string;\n details: string | null;\n location: string | null;\n}\n\n/** Cold-chain surface for a temperature-controlled (perishable) shipment. */\nexport interface ShipmentColdChain {\n temperatureControlled: boolean;\n targetMin: number | null;\n targetMax: number | null;\n unit: string | null;\n /** Latest recorded temperature, when movethewheels holds telemetry; null otherwise. */\n currentTemperature: number | null;\n readingAt: string | null;\n /** True when the latest reading is outside the target range — drives the alert style. */\n breach: boolean;\n}\n\n/** The buyer-facing shipment tracking + cold-chain view for an order. */\nexport interface OrderShipment {\n orderId: string;\n hasShipment: boolean;\n shipmentId: string | null;\n shipmentNumber: string | null;\n trackingNumber: string | null;\n /** PLANNED | PICKED_UP | IN_TRANSIT | DELIVERED | FAILED | RETURNED. */\n status: string | null;\n estimatedDelivery: string | null;\n actualDelivery: string | null;\n timeline: ShipmentTrackingEvent[];\n coldChain: ShipmentColdChain | null;\n}\n\nconst ORDER_SHIPMENT_FIELDS = `\n orderId\n hasShipment\n shipmentId\n shipmentNumber\n trackingNumber\n status\n estimatedDelivery\n actualDelivery\n timeline {\n id\n eventType\n timestamp\n details\n location\n }\n coldChain {\n temperatureControlled\n targetMin\n targetMax\n unit\n currentTemperature\n readingAt\n breach\n }\n`;\n\nconst ORDER_SHIPMENT_QUERY = gql`\n query HealthyBowlOrderShipment($orderId: ID!, $context: ContextInput!) {\n healthyBowlOrderShipment(orderId: $orderId, context: $context) {\n ${ORDER_SHIPMENT_FIELDS}\n }\n }\n`;\n\nconst CREATE_ORDER_SHIPMENT = gql`\n mutation CreateHealthyBowlOrderShipment($orderId: ID!, $perishable: Boolean, $context: ContextInput!) {\n createHealthyBowlOrderShipment(orderId: $orderId, perishable: $perishable, context: $context) {\n ${ORDER_SHIPMENT_FIELDS}\n }\n }\n`;\n\ninterface OrderShipmentQueryData {\n healthyBowlOrderShipment: OrderShipment | null;\n}\ninterface CreateOrderShipmentData {\n createHealthyBowlOrderShipment: OrderShipment;\n}\n\n/**\n * Read the shipment tracking + cold-chain for one order, plus the create (\"arrange shipment\") call.\n *\n * Pass `null` (e.g. when the tracking panel is closed) to skip the read entirely. The read is\n * best-effort (`errorPolicy: 'all'`) so a logistics-gateway hiccup shows an empty/pending state\n * rather than tearing down the orders page.\n */\nexport function useOrderShipment(orderId: string | null) {\n const { workspaceId } = useHealthyBowl();\n const context = { workspaceId };\n\n const { data, loading, error, refetch } = useQuery<OrderShipmentQueryData>(ORDER_SHIPMENT_QUERY, {\n variables: { orderId: orderId ?? '', context },\n skip: !orderId || !workspaceId,\n fetchPolicy: 'cache-and-network',\n errorPolicy: 'all',\n notifyOnNetworkStatusChange: true,\n });\n\n const [createMutation, { loading: creating }] = useMutation<CreateOrderShipmentData>(CREATE_ORDER_SHIPMENT);\n\n /** Arrange the movethewheels shipment for this order. Idempotent server-side. */\n const createShipment = useCallback(\n async (perishable?: boolean): Promise<OrderShipment> => {\n if (!orderId) throw new Error('No order selected');\n const res = await createMutation({\n variables: { orderId, perishable: perishable ?? null, context },\n });\n const shipment = res.data?.createHealthyBowlOrderShipment;\n if (!shipment) throw new Error('Could not arrange the shipment');\n await refetch().catch(() => undefined);\n return shipment;\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [createMutation, orderId, workspaceId, refetch]\n );\n\n return {\n shipment: data?.healthyBowlOrderShipment ?? null,\n loading,\n error: error ? error.message : null,\n refetch,\n createShipment,\n creating,\n };\n}\n"],"mappings":";;;;;AA4DA,IAAM,IAAwB,iWA2BxB,IAAuB,CAAG;;;QAGxB,EAAsB;;;GAKxB,IAAwB,CAAG;;;QAGzB,EAAsB;;;;AAmB9B,SAAgB,EAAiB,GAAwB;CACvD,IAAM,EAAE,mBAAgB,GAAgB,EAClC,IAAU,EAAE,gBAAa,EAEzB,EAAE,SAAM,YAAS,UAAO,eAAY,EAAiC,GAAsB;EAC/F,WAAW;GAAE,SAAS,KAAW;GAAI;GAAS;EAC9C,MAAM,CAAC,KAAW,CAAC;EACnB,aAAa;EACb,aAAa;EACb,6BAA6B;EAC9B,CAAC,EAEI,CAAC,GAAgB,EAAE,SAAS,OAAc,EAAqC,EAAsB,EAGrG,IAAiB,EACrB,OAAO,MAAiD;AACtD,MAAI,CAAC,EAAS,OAAU,MAAM,oBAAoB;EAIlD,IAAM,KAHM,MAAM,EAAe,EAC/B,WAAW;GAAE;GAAS,YAAY,KAAc;GAAM;GAAS,EAChE,CAAC,EACmB,MAAM;AAC3B,MAAI,CAAC,EAAU,OAAU,MAAM,iCAAiC;AAEhE,SADA,MAAM,GAAS,CAAC,YAAY,KAAA,EAAU,EAC/B;IAGT;EAAC;EAAgB;EAAS;EAAa;EAAQ,CAChD;AAED,QAAO;EACL,UAAU,GAAM,4BAA4B;EAC5C;EACA,OAAO,IAAQ,EAAM,UAAU;EAC/B;EACA;EACA;EACD"}
|