@burdenoff/microfe-movethewheels 2026.1028.1 → 2026.1031.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/dist/MoveTheWheelsRoot.js +130 -122
- package/dist/MoveTheWheelsRoutes.js +55 -51
- package/dist/components/ExportStatusBanner.js +53 -0
- package/dist/components/marketplace/MarketplaceDialogs.js +524 -0
- package/dist/generated/wspace-types.d.ts +30737 -8505
- package/dist/hooks/useEntityExport.js +85 -0
- package/dist/hooks/useMarketplace.js +265 -0
- package/dist/movethewheels/components/ExportStatusBanner.d.ts +7 -0
- package/dist/movethewheels/components/marketplace/MarketplaceDialogs.d.ts +18 -0
- package/dist/movethewheels/hooks/useEntityExport.d.ts +32 -0
- package/dist/movethewheels/hooks/useMarketplace.d.ts +121 -0
- package/dist/movethewheels/pages/MarketplacePage.d.ts +1 -0
- package/dist/movethewheels/utils/entityExport.d.ts +64 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/badge-check.js +11 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/chevron-down.js +8 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/chevron-up.js +8 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/pencil.js +11 -0
- package/dist/node_modules/lucide-react/dist/esm/icons/store.js +26 -0
- package/dist/pages/CustomersPage.js +64 -58
- package/dist/pages/DriversPage.js +113 -107
- package/dist/pages/MarketplacePage.js +503 -0
- package/dist/pages/OrdersListPage.js +85 -79
- package/dist/pages/ProductsPage.js +63 -57
- package/dist/pages/VehiclesPage.js +91 -85
- package/dist/utils/entityExport.js +54 -0
- package/package.json +3 -2
- package/src/generated/wspace-types.ts +34017 -8803
- package/src/movethewheels/MoveTheWheelsRoot.tsx +8 -0
- package/src/movethewheels/MoveTheWheelsRoutes.tsx +4 -0
- package/src/movethewheels/components/ExportStatusBanner.tsx +78 -0
- package/src/movethewheels/components/marketplace/MarketplaceDialogs.tsx +633 -0
- package/src/movethewheels/hooks/useEntityExport.ts +130 -0
- package/src/movethewheels/hooks/useMarketplace.ts +526 -0
- package/src/movethewheels/pages/CustomersPage.tsx +11 -2
- package/src/movethewheels/pages/DriversPage.tsx +11 -2
- package/src/movethewheels/pages/MarketplacePage.tsx +571 -0
- package/src/movethewheels/pages/OrdersListPage.tsx +13 -2
- package/src/movethewheels/pages/ProductsPage.tsx +11 -2
- package/src/movethewheels/pages/VehiclesPage.tsx +11 -2
- package/src/movethewheels/utils/entityExport.ts +140 -0
|
@@ -0,0 +1,524 @@
|
|
|
1
|
+
import { Button as e, Input as t, Label as n, Select as r, SelectContent as i, SelectItem as a, SelectTrigger as o, SelectValue as s, Switch as c, Textarea as l } from "../ui.js";
|
|
2
|
+
import { FormError as u } from "../FormError.js";
|
|
3
|
+
import { EntityCombobox as d } from "../EntityCombobox.js";
|
|
4
|
+
import { AVAILABILITIES as f, OFFERING_CATEGORIES as p, PROVIDER_TYPES as m, humanizeEnum as h, useMarketplaceActions as ee, useShipmentOptions as g } from "../../hooks/useMarketplace.js";
|
|
5
|
+
import { useEffect as _, useState as v } from "react";
|
|
6
|
+
import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
|
|
7
|
+
import { ResponsiveDialog as S, ResponsiveDialogContent as C, ResponsiveDialogDescription as w, ResponsiveDialogFooter as T, ResponsiveDialogHeader as E, ResponsiveDialogTitle as D } from "@burdenoff/fe-libs/ui";
|
|
8
|
+
//#region src/movethewheels/components/marketplace/MarketplaceDialogs.tsx
|
|
9
|
+
function te(e, t) {
|
|
10
|
+
return e instanceof Error && e.message ? e.message : t;
|
|
11
|
+
}
|
|
12
|
+
function O(e) {
|
|
13
|
+
return e.split(",").map((e) => e.trim()).filter(Boolean);
|
|
14
|
+
}
|
|
15
|
+
function k(e) {
|
|
16
|
+
let t = e.trim();
|
|
17
|
+
if (!t) return null;
|
|
18
|
+
let n = Number(t);
|
|
19
|
+
return Number.isFinite(n) ? n : "invalid";
|
|
20
|
+
}
|
|
21
|
+
function A(e) {
|
|
22
|
+
return e.trim() || null;
|
|
23
|
+
}
|
|
24
|
+
function j({ open: d, onOpenChange: f, onDone: p, provider: g }) {
|
|
25
|
+
let y = ee(), [j, M] = v(""), [N, P] = v("CARRIER"), [F, I] = v(""), [L, R] = v(""), [z, B] = v(""), [V, H] = v(""), [U, W] = v(""), [G, K] = v(""), [q, J] = v(""), [Y, X] = v(""), [Z, ne] = v(!1), [Q, re] = v(!0), [ie, ae] = v(!1), [oe, $] = v(null);
|
|
26
|
+
_(() => {
|
|
27
|
+
d && (M(g?.name ?? ""), P(g?.type ?? "CARRIER"), I(g?.description ?? ""), R(g?.rating == null ? "" : String(g.rating)), B(g?.contact.contactName ?? ""), H(g?.contact.email ?? ""), W(g?.contact.phone ?? ""), K(g?.contact.website ?? ""), J(g?.services.join(", ") ?? ""), X(g?.serviceAreas.join(", ") ?? ""), ne(g?.isVerified ?? !1), re(g?.isActive ?? !0), $(null));
|
|
28
|
+
}, [d, g]);
|
|
29
|
+
let se = async () => {
|
|
30
|
+
if (!j.trim()) {
|
|
31
|
+
$("Enter the provider name.");
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
let e = k(L);
|
|
35
|
+
if (e === "invalid" || e !== null && (e < 0 || e > 5)) {
|
|
36
|
+
$("Rating must be a number from 0 to 5.");
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
let t = {
|
|
40
|
+
...z.trim() ? { contactName: z.trim() } : {},
|
|
41
|
+
...V.trim() ? { email: V.trim() } : {},
|
|
42
|
+
...U.trim() ? { phone: U.trim() } : {},
|
|
43
|
+
...G.trim() ? { website: G.trim() } : {}
|
|
44
|
+
}, n = {
|
|
45
|
+
name: j.trim(),
|
|
46
|
+
type: N,
|
|
47
|
+
description: A(F),
|
|
48
|
+
rating: e,
|
|
49
|
+
contactInfo: Object.keys(t).length > 0 ? t : null,
|
|
50
|
+
services: O(q),
|
|
51
|
+
serviceAreas: O(Y),
|
|
52
|
+
isVerified: Z,
|
|
53
|
+
isActive: Q
|
|
54
|
+
};
|
|
55
|
+
ae(!0), $(null);
|
|
56
|
+
try {
|
|
57
|
+
g ? (await y.updateProvider(g.id, n), p(`Updated ${n.name}.`)) : (await y.createProvider(n), p(`Added ${n.name} to the marketplace.`)), f(!1);
|
|
58
|
+
} catch (e) {
|
|
59
|
+
$(te(e, "Could not save the provider."));
|
|
60
|
+
} finally {
|
|
61
|
+
ae(!1);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
return /* @__PURE__ */ b(S, {
|
|
65
|
+
open: d,
|
|
66
|
+
onOpenChange: f,
|
|
67
|
+
children: /* @__PURE__ */ x(C, {
|
|
68
|
+
className: "sm:max-w-xl",
|
|
69
|
+
children: [/* @__PURE__ */ x(E, { children: [/* @__PURE__ */ b(D, { children: g ? "Edit provider" : "Add a service provider" }), /* @__PURE__ */ b(w, { children: "Carriers, 3PLs, warehouses and specialists you can call on when you need capacity." })] }), /* @__PURE__ */ x("form", {
|
|
70
|
+
className: "grid gap-4",
|
|
71
|
+
onSubmit: (e) => {
|
|
72
|
+
e.preventDefault(), se();
|
|
73
|
+
},
|
|
74
|
+
children: [
|
|
75
|
+
/* @__PURE__ */ b(u, { message: oe }),
|
|
76
|
+
/* @__PURE__ */ x("div", {
|
|
77
|
+
className: "grid gap-4 sm:grid-cols-2",
|
|
78
|
+
children: [/* @__PURE__ */ x("div", {
|
|
79
|
+
className: "grid gap-1.5",
|
|
80
|
+
children: [/* @__PURE__ */ b(n, {
|
|
81
|
+
htmlFor: "mtw-provider-name",
|
|
82
|
+
children: "Name"
|
|
83
|
+
}), /* @__PURE__ */ b(t, {
|
|
84
|
+
id: "mtw-provider-name",
|
|
85
|
+
value: j,
|
|
86
|
+
maxLength: 255,
|
|
87
|
+
onChange: (e) => M(e.target.value),
|
|
88
|
+
required: !0
|
|
89
|
+
})]
|
|
90
|
+
}), /* @__PURE__ */ x("div", {
|
|
91
|
+
className: "grid gap-1.5",
|
|
92
|
+
children: [/* @__PURE__ */ b(n, {
|
|
93
|
+
htmlFor: "mtw-provider-type",
|
|
94
|
+
children: "Type"
|
|
95
|
+
}), /* @__PURE__ */ x(r, {
|
|
96
|
+
value: N,
|
|
97
|
+
onValueChange: (e) => P(e),
|
|
98
|
+
children: [/* @__PURE__ */ b(o, {
|
|
99
|
+
id: "mtw-provider-type",
|
|
100
|
+
children: /* @__PURE__ */ b(s, {})
|
|
101
|
+
}), /* @__PURE__ */ b(i, { children: m.map((e) => /* @__PURE__ */ b(a, {
|
|
102
|
+
value: e,
|
|
103
|
+
children: h(e)
|
|
104
|
+
}, e)) })]
|
|
105
|
+
})]
|
|
106
|
+
})]
|
|
107
|
+
}),
|
|
108
|
+
/* @__PURE__ */ x("div", {
|
|
109
|
+
className: "grid gap-1.5",
|
|
110
|
+
children: [/* @__PURE__ */ b(n, {
|
|
111
|
+
htmlFor: "mtw-provider-description",
|
|
112
|
+
children: "Description"
|
|
113
|
+
}), /* @__PURE__ */ b(l, {
|
|
114
|
+
id: "mtw-provider-description",
|
|
115
|
+
value: F,
|
|
116
|
+
maxLength: 2e3,
|
|
117
|
+
rows: 3,
|
|
118
|
+
onChange: (e) => I(e.target.value)
|
|
119
|
+
})]
|
|
120
|
+
}),
|
|
121
|
+
/* @__PURE__ */ x("div", {
|
|
122
|
+
className: "grid gap-4 sm:grid-cols-2",
|
|
123
|
+
children: [
|
|
124
|
+
/* @__PURE__ */ x("div", {
|
|
125
|
+
className: "grid gap-1.5",
|
|
126
|
+
children: [/* @__PURE__ */ b(n, {
|
|
127
|
+
htmlFor: "mtw-provider-services",
|
|
128
|
+
children: "Services (comma separated)"
|
|
129
|
+
}), /* @__PURE__ */ b(t, {
|
|
130
|
+
id: "mtw-provider-services",
|
|
131
|
+
value: q,
|
|
132
|
+
placeholder: "Reefer, Hazmat, Same day",
|
|
133
|
+
onChange: (e) => J(e.target.value)
|
|
134
|
+
})]
|
|
135
|
+
}),
|
|
136
|
+
/* @__PURE__ */ x("div", {
|
|
137
|
+
className: "grid gap-1.5",
|
|
138
|
+
children: [/* @__PURE__ */ b(n, {
|
|
139
|
+
htmlFor: "mtw-provider-areas",
|
|
140
|
+
children: "Service areas (comma separated)"
|
|
141
|
+
}), /* @__PURE__ */ b(t, {
|
|
142
|
+
id: "mtw-provider-areas",
|
|
143
|
+
value: Y,
|
|
144
|
+
placeholder: "Mumbai, Pune, NH48 corridor",
|
|
145
|
+
onChange: (e) => X(e.target.value)
|
|
146
|
+
})]
|
|
147
|
+
}),
|
|
148
|
+
/* @__PURE__ */ x("div", {
|
|
149
|
+
className: "grid gap-1.5",
|
|
150
|
+
children: [/* @__PURE__ */ b(n, {
|
|
151
|
+
htmlFor: "mtw-provider-contact",
|
|
152
|
+
children: "Contact person"
|
|
153
|
+
}), /* @__PURE__ */ b(t, {
|
|
154
|
+
id: "mtw-provider-contact",
|
|
155
|
+
value: z,
|
|
156
|
+
onChange: (e) => B(e.target.value)
|
|
157
|
+
})]
|
|
158
|
+
}),
|
|
159
|
+
/* @__PURE__ */ x("div", {
|
|
160
|
+
className: "grid gap-1.5",
|
|
161
|
+
children: [/* @__PURE__ */ b(n, {
|
|
162
|
+
htmlFor: "mtw-provider-email",
|
|
163
|
+
children: "Email"
|
|
164
|
+
}), /* @__PURE__ */ b(t, {
|
|
165
|
+
id: "mtw-provider-email",
|
|
166
|
+
type: "email",
|
|
167
|
+
value: V,
|
|
168
|
+
onChange: (e) => H(e.target.value)
|
|
169
|
+
})]
|
|
170
|
+
}),
|
|
171
|
+
/* @__PURE__ */ x("div", {
|
|
172
|
+
className: "grid gap-1.5",
|
|
173
|
+
children: [/* @__PURE__ */ b(n, {
|
|
174
|
+
htmlFor: "mtw-provider-phone",
|
|
175
|
+
children: "Phone"
|
|
176
|
+
}), /* @__PURE__ */ b(t, {
|
|
177
|
+
id: "mtw-provider-phone",
|
|
178
|
+
value: U,
|
|
179
|
+
onChange: (e) => W(e.target.value)
|
|
180
|
+
})]
|
|
181
|
+
}),
|
|
182
|
+
/* @__PURE__ */ x("div", {
|
|
183
|
+
className: "grid gap-1.5",
|
|
184
|
+
children: [/* @__PURE__ */ b(n, {
|
|
185
|
+
htmlFor: "mtw-provider-website",
|
|
186
|
+
children: "Website"
|
|
187
|
+
}), /* @__PURE__ */ b(t, {
|
|
188
|
+
id: "mtw-provider-website",
|
|
189
|
+
value: G,
|
|
190
|
+
onChange: (e) => K(e.target.value)
|
|
191
|
+
})]
|
|
192
|
+
}),
|
|
193
|
+
/* @__PURE__ */ x("div", {
|
|
194
|
+
className: "grid gap-1.5",
|
|
195
|
+
children: [/* @__PURE__ */ b(n, {
|
|
196
|
+
htmlFor: "mtw-provider-rating",
|
|
197
|
+
children: "Your rating (0–5)"
|
|
198
|
+
}), /* @__PURE__ */ b(t, {
|
|
199
|
+
id: "mtw-provider-rating",
|
|
200
|
+
inputMode: "decimal",
|
|
201
|
+
value: L,
|
|
202
|
+
onChange: (e) => R(e.target.value)
|
|
203
|
+
})]
|
|
204
|
+
})
|
|
205
|
+
]
|
|
206
|
+
}),
|
|
207
|
+
/* @__PURE__ */ x("div", {
|
|
208
|
+
className: "flex flex-wrap gap-6",
|
|
209
|
+
children: [/* @__PURE__ */ x("label", {
|
|
210
|
+
className: "flex items-center gap-2 text-sm",
|
|
211
|
+
htmlFor: "mtw-provider-verified",
|
|
212
|
+
children: [/* @__PURE__ */ b(c, {
|
|
213
|
+
id: "mtw-provider-verified",
|
|
214
|
+
checked: Z,
|
|
215
|
+
onCheckedChange: ne
|
|
216
|
+
}), "Verified by your team"]
|
|
217
|
+
}), /* @__PURE__ */ x("label", {
|
|
218
|
+
className: "flex items-center gap-2 text-sm",
|
|
219
|
+
htmlFor: "mtw-provider-active",
|
|
220
|
+
children: [/* @__PURE__ */ b(c, {
|
|
221
|
+
id: "mtw-provider-active",
|
|
222
|
+
checked: Q,
|
|
223
|
+
onCheckedChange: re
|
|
224
|
+
}), "Active"]
|
|
225
|
+
})]
|
|
226
|
+
}),
|
|
227
|
+
/* @__PURE__ */ x(T, { children: [/* @__PURE__ */ b(e, {
|
|
228
|
+
type: "button",
|
|
229
|
+
variant: "outline",
|
|
230
|
+
onClick: () => f(!1),
|
|
231
|
+
children: "Cancel"
|
|
232
|
+
}), /* @__PURE__ */ b(e, {
|
|
233
|
+
type: "submit",
|
|
234
|
+
disabled: ie,
|
|
235
|
+
children: ie ? "Saving…" : g ? "Save changes" : "Add provider"
|
|
236
|
+
})] })
|
|
237
|
+
]
|
|
238
|
+
})]
|
|
239
|
+
})
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
function M({ open: d, onOpenChange: m, onDone: g, provider: y, offering: O }) {
|
|
243
|
+
let j = ee(), [M, N] = v(""), [P, F] = v("FULL_TRUCKLOAD"), [I, L] = v(""), [R, z] = v(""), [B, V] = v("USD"), [H, U] = v(""), [W, G] = v(""), [K, q] = v("AVAILABLE"), [J, Y] = v(!0), [X, Z] = v(!1), [ne, Q] = v(null);
|
|
244
|
+
_(() => {
|
|
245
|
+
d && (N(O?.name ?? ""), F(O?.category ?? "FULL_TRUCKLOAD"), L(O?.description ?? ""), z(O?.price == null ? "" : String(O.price)), V(O?.currency ?? "USD"), U(O?.pricingUnit ?? ""), G(O?.transitDays == null ? "" : String(O.transitDays)), q(O?.availability ?? "AVAILABLE"), Y(O?.isActive ?? !0), Q(null));
|
|
246
|
+
}, [d, O]);
|
|
247
|
+
let re = async () => {
|
|
248
|
+
if (!y) return;
|
|
249
|
+
if (!M.trim()) {
|
|
250
|
+
Q("Enter the offering name.");
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
let e = k(R);
|
|
254
|
+
if (e === "invalid" || e !== null && e < 0) {
|
|
255
|
+
Q("Price must be zero or a positive number, or left blank for \"on request\".");
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
let t = k(W);
|
|
259
|
+
if (t === "invalid" || t !== null && (!Number.isInteger(t) || t < 0)) {
|
|
260
|
+
Q("Transit days must be a whole number.");
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
if (!/^[A-Za-z]{3}$/.test(B.trim())) {
|
|
264
|
+
Q("Currency must be a three-letter code such as USD or INR.");
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
let n = {
|
|
268
|
+
name: M.trim(),
|
|
269
|
+
category: P,
|
|
270
|
+
description: A(I),
|
|
271
|
+
price: e,
|
|
272
|
+
currency: B.trim().toUpperCase(),
|
|
273
|
+
pricingUnit: A(H),
|
|
274
|
+
transitDays: t,
|
|
275
|
+
availability: K,
|
|
276
|
+
isActive: J
|
|
277
|
+
};
|
|
278
|
+
Z(!0), Q(null);
|
|
279
|
+
try {
|
|
280
|
+
O ? (await j.updateOffering(O.id, n), g(`Updated ${n.name}.`)) : (await j.createOffering(y.id, n), g(`Added ${n.name} to ${y.name}.`)), m(!1);
|
|
281
|
+
} catch (e) {
|
|
282
|
+
Q(te(e, "Could not save the offering."));
|
|
283
|
+
} finally {
|
|
284
|
+
Z(!1);
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
return /* @__PURE__ */ b(S, {
|
|
288
|
+
open: d,
|
|
289
|
+
onOpenChange: m,
|
|
290
|
+
children: /* @__PURE__ */ x(C, {
|
|
291
|
+
className: "sm:max-w-lg",
|
|
292
|
+
children: [/* @__PURE__ */ x(E, { children: [/* @__PURE__ */ b(D, { children: O ? "Edit offering" : "Add an offering" }), /* @__PURE__ */ b(w, { children: y ? `A service ${y.name} offers, with an indicative price.` : null })] }), /* @__PURE__ */ x("form", {
|
|
293
|
+
className: "grid gap-4",
|
|
294
|
+
onSubmit: (e) => {
|
|
295
|
+
e.preventDefault(), re();
|
|
296
|
+
},
|
|
297
|
+
children: [
|
|
298
|
+
/* @__PURE__ */ b(u, { message: ne }),
|
|
299
|
+
/* @__PURE__ */ x("div", {
|
|
300
|
+
className: "grid gap-1.5",
|
|
301
|
+
children: [/* @__PURE__ */ b(n, {
|
|
302
|
+
htmlFor: "mtw-offering-name",
|
|
303
|
+
children: "Name"
|
|
304
|
+
}), /* @__PURE__ */ b(t, {
|
|
305
|
+
id: "mtw-offering-name",
|
|
306
|
+
value: M,
|
|
307
|
+
maxLength: 255,
|
|
308
|
+
onChange: (e) => N(e.target.value),
|
|
309
|
+
required: !0
|
|
310
|
+
})]
|
|
311
|
+
}),
|
|
312
|
+
/* @__PURE__ */ x("div", {
|
|
313
|
+
className: "grid gap-4 sm:grid-cols-2",
|
|
314
|
+
children: [
|
|
315
|
+
/* @__PURE__ */ x("div", {
|
|
316
|
+
className: "grid gap-1.5",
|
|
317
|
+
children: [/* @__PURE__ */ b(n, {
|
|
318
|
+
htmlFor: "mtw-offering-category",
|
|
319
|
+
children: "Category"
|
|
320
|
+
}), /* @__PURE__ */ x(r, {
|
|
321
|
+
value: P,
|
|
322
|
+
onValueChange: (e) => F(e),
|
|
323
|
+
children: [/* @__PURE__ */ b(o, {
|
|
324
|
+
id: "mtw-offering-category",
|
|
325
|
+
children: /* @__PURE__ */ b(s, {})
|
|
326
|
+
}), /* @__PURE__ */ b(i, { children: p.map((e) => /* @__PURE__ */ b(a, {
|
|
327
|
+
value: e,
|
|
328
|
+
children: h(e)
|
|
329
|
+
}, e)) })]
|
|
330
|
+
})]
|
|
331
|
+
}),
|
|
332
|
+
/* @__PURE__ */ x("div", {
|
|
333
|
+
className: "grid gap-1.5",
|
|
334
|
+
children: [/* @__PURE__ */ b(n, {
|
|
335
|
+
htmlFor: "mtw-offering-availability",
|
|
336
|
+
children: "Availability"
|
|
337
|
+
}), /* @__PURE__ */ x(r, {
|
|
338
|
+
value: K,
|
|
339
|
+
onValueChange: (e) => q(e),
|
|
340
|
+
children: [/* @__PURE__ */ b(o, {
|
|
341
|
+
id: "mtw-offering-availability",
|
|
342
|
+
children: /* @__PURE__ */ b(s, {})
|
|
343
|
+
}), /* @__PURE__ */ b(i, { children: f.map((e) => /* @__PURE__ */ b(a, {
|
|
344
|
+
value: e,
|
|
345
|
+
children: h(e)
|
|
346
|
+
}, e)) })]
|
|
347
|
+
})]
|
|
348
|
+
}),
|
|
349
|
+
/* @__PURE__ */ x("div", {
|
|
350
|
+
className: "grid gap-1.5",
|
|
351
|
+
children: [/* @__PURE__ */ b(n, {
|
|
352
|
+
htmlFor: "mtw-offering-price",
|
|
353
|
+
children: "Price (blank = on request)"
|
|
354
|
+
}), /* @__PURE__ */ b(t, {
|
|
355
|
+
id: "mtw-offering-price",
|
|
356
|
+
inputMode: "decimal",
|
|
357
|
+
value: R,
|
|
358
|
+
onChange: (e) => z(e.target.value)
|
|
359
|
+
})]
|
|
360
|
+
}),
|
|
361
|
+
/* @__PURE__ */ x("div", {
|
|
362
|
+
className: "grid gap-1.5",
|
|
363
|
+
children: [/* @__PURE__ */ b(n, {
|
|
364
|
+
htmlFor: "mtw-offering-currency",
|
|
365
|
+
children: "Currency"
|
|
366
|
+
}), /* @__PURE__ */ b(t, {
|
|
367
|
+
id: "mtw-offering-currency",
|
|
368
|
+
value: B,
|
|
369
|
+
maxLength: 3,
|
|
370
|
+
onChange: (e) => V(e.target.value)
|
|
371
|
+
})]
|
|
372
|
+
}),
|
|
373
|
+
/* @__PURE__ */ x("div", {
|
|
374
|
+
className: "grid gap-1.5",
|
|
375
|
+
children: [/* @__PURE__ */ b(n, {
|
|
376
|
+
htmlFor: "mtw-offering-unit",
|
|
377
|
+
children: "Priced per"
|
|
378
|
+
}), /* @__PURE__ */ b(t, {
|
|
379
|
+
id: "mtw-offering-unit",
|
|
380
|
+
value: H,
|
|
381
|
+
placeholder: "load, km, pallet…",
|
|
382
|
+
maxLength: 40,
|
|
383
|
+
onChange: (e) => U(e.target.value)
|
|
384
|
+
})]
|
|
385
|
+
}),
|
|
386
|
+
/* @__PURE__ */ x("div", {
|
|
387
|
+
className: "grid gap-1.5",
|
|
388
|
+
children: [/* @__PURE__ */ b(n, {
|
|
389
|
+
htmlFor: "mtw-offering-transit",
|
|
390
|
+
children: "Transit days"
|
|
391
|
+
}), /* @__PURE__ */ b(t, {
|
|
392
|
+
id: "mtw-offering-transit",
|
|
393
|
+
inputMode: "numeric",
|
|
394
|
+
value: W,
|
|
395
|
+
onChange: (e) => G(e.target.value)
|
|
396
|
+
})]
|
|
397
|
+
})
|
|
398
|
+
]
|
|
399
|
+
}),
|
|
400
|
+
/* @__PURE__ */ x("div", {
|
|
401
|
+
className: "grid gap-1.5",
|
|
402
|
+
children: [/* @__PURE__ */ b(n, {
|
|
403
|
+
htmlFor: "mtw-offering-description",
|
|
404
|
+
children: "Description"
|
|
405
|
+
}), /* @__PURE__ */ b(l, {
|
|
406
|
+
id: "mtw-offering-description",
|
|
407
|
+
value: I,
|
|
408
|
+
maxLength: 2e3,
|
|
409
|
+
rows: 2,
|
|
410
|
+
onChange: (e) => L(e.target.value)
|
|
411
|
+
})]
|
|
412
|
+
}),
|
|
413
|
+
/* @__PURE__ */ x("label", {
|
|
414
|
+
className: "flex items-center gap-2 text-sm",
|
|
415
|
+
htmlFor: "mtw-offering-active",
|
|
416
|
+
children: [/* @__PURE__ */ b(c, {
|
|
417
|
+
id: "mtw-offering-active",
|
|
418
|
+
checked: J,
|
|
419
|
+
onCheckedChange: Y
|
|
420
|
+
}), "Active"]
|
|
421
|
+
}),
|
|
422
|
+
/* @__PURE__ */ x(T, { children: [/* @__PURE__ */ b(e, {
|
|
423
|
+
type: "button",
|
|
424
|
+
variant: "outline",
|
|
425
|
+
onClick: () => m(!1),
|
|
426
|
+
children: "Cancel"
|
|
427
|
+
}), /* @__PURE__ */ b(e, {
|
|
428
|
+
type: "submit",
|
|
429
|
+
disabled: X,
|
|
430
|
+
children: X ? "Saving…" : O ? "Save changes" : "Add offering"
|
|
431
|
+
})] })
|
|
432
|
+
]
|
|
433
|
+
})]
|
|
434
|
+
})
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
function N({ open: t, onOpenChange: r, onDone: i, provider: a }) {
|
|
438
|
+
let o = ee(), [s, c] = v(""), [l, f] = v(""), [p, m] = v(!1), [O, k] = v(null), { shipments: A, total: j, isLoading: M } = g({
|
|
439
|
+
search: s,
|
|
440
|
+
limit: 20
|
|
441
|
+
});
|
|
442
|
+
_(() => {
|
|
443
|
+
t && (c(""), f(""), k(null));
|
|
444
|
+
}, [t]);
|
|
445
|
+
let N = A.find((e) => e.id === l) ?? null, P = async () => {
|
|
446
|
+
if (a) {
|
|
447
|
+
if (!l) {
|
|
448
|
+
k("Choose the shipment this provider will carry.");
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
m(!0), k(null);
|
|
452
|
+
try {
|
|
453
|
+
let e = await o.assignShipment(l, a.id);
|
|
454
|
+
i(`${a.name} is now the carrier for shipment ${e.shipmentNumber}.`), r(!1);
|
|
455
|
+
} catch (e) {
|
|
456
|
+
k(te(e, "Could not assign the provider."));
|
|
457
|
+
} finally {
|
|
458
|
+
m(!1);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
};
|
|
462
|
+
return /* @__PURE__ */ b(S, {
|
|
463
|
+
open: t,
|
|
464
|
+
onOpenChange: r,
|
|
465
|
+
children: /* @__PURE__ */ x(C, {
|
|
466
|
+
className: "sm:max-w-md",
|
|
467
|
+
children: [/* @__PURE__ */ x(E, { children: [/* @__PURE__ */ b(D, { children: "Assign to a shipment" }), /* @__PURE__ */ b(w, { children: a ? `Make ${a.name} the carrier of a shipment.${a.isVerified && a.isActive ? "" : " This provider is not verified or not active — check before you commit freight."}` : null })] }), /* @__PURE__ */ x("form", {
|
|
468
|
+
className: "grid gap-4",
|
|
469
|
+
onSubmit: (e) => {
|
|
470
|
+
e.preventDefault(), P();
|
|
471
|
+
},
|
|
472
|
+
children: [
|
|
473
|
+
/* @__PURE__ */ b(u, { message: O }),
|
|
474
|
+
/* @__PURE__ */ x("div", {
|
|
475
|
+
className: "grid gap-1.5",
|
|
476
|
+
children: [/* @__PURE__ */ b(n, {
|
|
477
|
+
htmlFor: "mtw-assign-shipment",
|
|
478
|
+
children: "Shipment"
|
|
479
|
+
}), /* @__PURE__ */ b(d, {
|
|
480
|
+
id: "mtw-assign-shipment",
|
|
481
|
+
value: l,
|
|
482
|
+
onChange: f,
|
|
483
|
+
options: A,
|
|
484
|
+
loading: M,
|
|
485
|
+
required: !0,
|
|
486
|
+
getId: (e) => e.id,
|
|
487
|
+
getLabel: (e) => e.shipmentNumber,
|
|
488
|
+
renderOption: (e) => /* @__PURE__ */ x(y, { children: [
|
|
489
|
+
e.shipmentNumber,
|
|
490
|
+
" ",
|
|
491
|
+
/* @__PURE__ */ x("span", {
|
|
492
|
+
className: "text-text-tertiary",
|
|
493
|
+
children: [
|
|
494
|
+
"(",
|
|
495
|
+
h(e.status),
|
|
496
|
+
")"
|
|
497
|
+
]
|
|
498
|
+
})
|
|
499
|
+
] }),
|
|
500
|
+
selectedOption: N,
|
|
501
|
+
placeholder: "Search shipments",
|
|
502
|
+
searchPlaceholder: "Search by shipment number…",
|
|
503
|
+
emptyText: "No shipments found.",
|
|
504
|
+
onSearchChange: c,
|
|
505
|
+
totalCount: j
|
|
506
|
+
})]
|
|
507
|
+
}),
|
|
508
|
+
/* @__PURE__ */ x(T, { children: [/* @__PURE__ */ b(e, {
|
|
509
|
+
type: "button",
|
|
510
|
+
variant: "outline",
|
|
511
|
+
onClick: () => r(!1),
|
|
512
|
+
children: "Cancel"
|
|
513
|
+
}), /* @__PURE__ */ b(e, {
|
|
514
|
+
type: "submit",
|
|
515
|
+
disabled: p,
|
|
516
|
+
children: p ? "Assigning…" : "Assign carrier"
|
|
517
|
+
})] })
|
|
518
|
+
]
|
|
519
|
+
})]
|
|
520
|
+
})
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
//#endregion
|
|
524
|
+
export { N as AssignShipmentDialog, M as OfferingDialog, j as ProviderDialog };
|