eatopia-ds 0.0.953 → 0.0.954

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/build/index10.js CHANGED
@@ -1,35 +1,32 @@
1
1
  import { j as t } from "./index24.js";
2
- import He, { useState as k, useEffect as Y, useMemo as D } from "react";
2
+ import He, { useState as k, useEffect as Y, useMemo as M } from "react";
3
3
  import { StockLeadTime as Ne } from "./index18.js";
4
4
  import { calculateConsumptionForecast as be, calculateTotalConsumptionForRange as _e } from "./index21.js";
5
5
  import { AlertIcon as Ue } from "./index23.js";
6
- const he = [1, 2, 3, 7, 10, 15, 30, 60, 90], Ve = 60, v = (n) => {
7
- const g = n.getFullYear(), q = String(n.getMonth() + 1).padStart(2, "0"), d = String(n.getDate()).padStart(2, "0");
8
- return `${g}-${q}-${d}`;
9
- }, S = (n) => {
10
- const g = n.split("-").map(Number);
11
- return g.length !== 3 || g.some(Number.isNaN) ? /* @__PURE__ */ new Date(NaN) : new Date(g[0], g[1] - 1, g[2]);
12
- }, Ye = () => {
6
+ const he = [1, 2, 3, 7, 10, 15, 30, 60, 90], v = (n) => {
7
+ const m = n.getFullYear(), q = String(n.getMonth() + 1).padStart(2, "0"), d = String(n.getDate()).padStart(2, "0");
8
+ return `${m}-${q}-${d}`;
9
+ }, I = (n) => {
10
+ const m = n.split("-").map(Number);
11
+ return m.length !== 3 || m.some(Number.isNaN) ? /* @__PURE__ */ new Date(NaN) : new Date(m[0], m[1] - 1, m[2]);
12
+ }, Ve = () => {
13
13
  const n = /* @__PURE__ */ new Date();
14
14
  return n.setDate(n.getDate() + 1), n.setHours(0, 0, 0, 0), v(n);
15
- }, A = () => {
15
+ }, O = () => {
16
16
  const n = /* @__PURE__ */ new Date();
17
17
  return n.setDate(n.getDate() + 1), n.setHours(0, 0, 0, 0), n;
18
- }, ve = (n) => n <= 0 ? 7 : he.reduce(
19
- (g, q) => Math.abs(q - n) < Math.abs(g - n) ? q : g
20
- ), P = (n) => {
21
- const g = ve(n);
22
- return Math.max(g, Ve);
23
- }, Ae = 42, je = {
18
+ }, P = (n) => n <= 0 ? 7 : he.reduce(
19
+ (m, q) => Math.abs(q - n) < Math.abs(m - n) ? q : m
20
+ ), Ye = 42, ve = {
24
21
  position: "relative",
25
- height: `${Ae}px`,
22
+ height: `${Ye}px`,
26
23
  border: "1.5px solid #e2e8f0",
27
24
  borderRadius: "10px",
28
25
  backgroundColor: "#f8fafc",
29
26
  display: "flex",
30
27
  alignItems: "center",
31
28
  boxSizing: "border-box"
32
- }, ke = {
29
+ }, je = {
33
30
  position: "absolute",
34
31
  inset: 0,
35
32
  width: "100%",
@@ -45,14 +42,14 @@ const he = [1, 2, 3, 7, 10, 15, 30, 60, 90], Ve = 60, v = (n) => {
45
42
  boxSizing: "border-box"
46
43
  }, W = ({
47
44
  children: n,
48
- ...g
49
- }) => /* @__PURE__ */ t.jsxs("div", { style: je, children: [
45
+ ...m
46
+ }) => /* @__PURE__ */ t.jsxs("div", { style: ve, children: [
50
47
  /* @__PURE__ */ t.jsx(
51
48
  "select",
52
49
  {
53
- ...g,
50
+ ...m,
54
51
  style: {
55
- ...ke,
52
+ ...je,
56
53
  padding: "0 36px 0 14px",
57
54
  appearance: "none",
58
55
  WebkitAppearance: "none"
@@ -90,27 +87,28 @@ const he = [1, 2, 3, 7, 10, 15, 30, 60, 90], Ve = 60, v = (n) => {
90
87
  )
91
88
  }
92
89
  )
93
- ] }), Oe = (n) => /* @__PURE__ */ t.jsx("div", { style: je, children: /* @__PURE__ */ t.jsx(
90
+ ] }), Oe = (n) => /* @__PURE__ */ t.jsx("div", { style: ve, children: /* @__PURE__ */ t.jsx(
94
91
  "input",
95
92
  {
96
93
  type: "date",
97
94
  ...n,
98
- style: { ...ke, padding: "0 14px" }
95
+ style: { ...je, padding: "0 14px" }
99
96
  }
100
97
  ) });
101
- function nt({
98
+ function tt({
102
99
  data: n,
103
- onSubmit: g,
100
+ onSubmit: m,
104
101
  onCancel: q,
105
102
  timelineData: d,
106
- fornecedoresOptions: $e,
107
- marcasOptions: Qe,
108
- embalagensOptions: Ge,
103
+ fornecedoresOptions: Ae,
104
+ marcasOptions: $e,
105
+ embalagensOptions: Qe,
109
106
  dailyConsumptionAverages: x,
110
- showSuggestionBar: qe = !0,
111
- showLegendTimeline: Ce = !1,
107
+ showSuggestionBar: ke = !0,
108
+ showLegendTimeline: qe = !1,
112
109
  initialQtdDays: j,
113
- stockLeadTimeZoomOnly: we = !1
110
+ stockLeadTimeZoomOnly: Ce = !1,
111
+ stockLeadTimeMinNavigationDays: we
114
112
  }) {
115
113
  var ee, te, ne, oe, re, se, ie, ae, le, ce, de, ue, fe, ge, pe, me;
116
114
  He.useEffect(() => {
@@ -135,7 +133,7 @@ function nt({
135
133
  };
136
134
  return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
137
135
  }, []);
138
- const O = () => {
136
+ const A = () => {
139
137
  if (!(d != null && d.timeline)) return 0;
140
138
  const { restockSuggestionStart: e, restockSuggestionEnd: s } = d.timeline;
141
139
  if (!e || !s) return 0;
@@ -143,15 +141,15 @@ function nt({
143
141
  return c > 0 ? c : 0;
144
142
  }, Te = () => {
145
143
  var i;
146
- const e = A(), s = (i = d == null ? void 0 : d.timeline) == null ? void 0 : i.stockEndDate;
144
+ const e = O(), s = (i = d == null ? void 0 : d.timeline) == null ? void 0 : i.stockEndDate;
147
145
  if (!s) return v(e);
148
- const r = S(s);
146
+ const r = I(s);
149
147
  return isNaN(r.getTime()) || r < e ? v(e) : v(r);
150
- }, Ie = () => ve(O()), Se = () => j != null && j > 0 ? P(j) : P(Ie()), p = (() => {
148
+ }, Se = () => P(A()), Ie = () => j != null && j > 0 ? P(j) : Se(), g = (() => {
151
149
  var i, l, c;
152
150
  const e = (i = n == null ? void 0 : n.fornecedores) == null ? void 0 : i[0];
153
151
  if (!e) return null;
154
- const s = O();
152
+ const s = A();
155
153
  if (!x || s <= 0) {
156
154
  const u = (l = e.marcas) == null ? void 0 : l[0], f = (c = u == null ? void 0 : u.embalagens) == null ? void 0 : c[0];
157
155
  return u && f ? {
@@ -164,16 +162,16 @@ function nt({
164
162
  let r = null;
165
163
  for (const u of e.marcas || [])
166
164
  for (const f of u.embalagens || []) {
167
- const m = f.quantidade_fornecedor;
168
- if (!(m <= 0))
165
+ const p = f.quantidade_fornecedor;
166
+ if (!(p <= 0))
169
167
  for (let h = 1; h <= 100; h++) {
170
- const xe = h * m, U = be({
168
+ const xe = h * p, U = be({
171
169
  dailyAverages: x,
172
170
  startDate: /* @__PURE__ */ new Date(),
173
171
  totalQuantity: xe
174
172
  });
175
173
  if (U.totalDays >= s) {
176
- const ye = h * f.valor_unitario * m, V = U.totalDays - s;
174
+ const ye = h * f.valor_unitario * p, V = U.totalDays - s;
177
175
  (!r || V < r.daysDifference || V === r.daysDifference && ye < r.totalValue) && (r = {
178
176
  marca: u.nome,
179
177
  embalagem: f.label,
@@ -195,46 +193,46 @@ function nt({
195
193
  } : null;
196
194
  })(), Ee = () => {
197
195
  var i, l, c;
198
- if (p)
199
- return p.valorUnitario;
196
+ if (g)
197
+ return g.valorUnitario;
200
198
  const e = (i = n == null ? void 0 : n.fornecedores) == null ? void 0 : i[0];
201
199
  if (!e) return 0;
202
200
  const s = (l = e.marcas) == null ? void 0 : l[0];
203
201
  if (!s) return 0;
204
202
  const r = (c = s.embalagens) == null ? void 0 : c[0];
205
203
  return (r == null ? void 0 : r.valor_unitario) ?? 0;
206
- }, L = n.unidade_medida ?? "kg", Be = ((ee = n.ultima_compra) == null ? void 0 : ee.unidade) ?? n.unidade_medida ?? "kg", [a, $] = k({
204
+ }, R = n.unidade_medida ?? "kg", Be = ((ee = n.ultima_compra) == null ? void 0 : ee.unidade) ?? n.unidade_medida ?? "kg", [a, $] = k({
207
205
  ...n,
208
- qtdPedido: (p == null ? void 0 : p.quantidade) ?? (n == null ? void 0 : n.qtdPedido) ?? 0,
209
- valorTotal: (n == null ? void 0 : n.valorTotal) ?? ((p == null ? void 0 : p.quantidade) ?? (n == null ? void 0 : n.qtdPedido) ?? 0) * Ee()
210
- }), [Me, Q] = k(
206
+ qtdPedido: (g == null ? void 0 : g.quantidade) ?? (n == null ? void 0 : n.qtdPedido) ?? 0,
207
+ valorTotal: (n == null ? void 0 : n.valorTotal) ?? ((g == null ? void 0 : g.quantidade) ?? (n == null ? void 0 : n.qtdPedido) ?? 0) * Ee()
208
+ }), [De, Q] = k(
211
209
  ((ne = (te = n == null ? void 0 : n.fornecedores) == null ? void 0 : te[0]) == null ? void 0 : ne.nome) ?? ""
212
210
  ), [w, E] = k(
213
- (p == null ? void 0 : p.marca) ?? ((ie = (se = (re = (oe = n == null ? void 0 : n.fornecedores) == null ? void 0 : oe[0]) == null ? void 0 : re.marcas) == null ? void 0 : se[0]) == null ? void 0 : ie.nome) ?? ""
211
+ (g == null ? void 0 : g.marca) ?? ((ie = (se = (re = (oe = n == null ? void 0 : n.fornecedores) == null ? void 0 : oe[0]) == null ? void 0 : re.marcas) == null ? void 0 : se[0]) == null ? void 0 : ie.nome) ?? ""
214
212
  ), [T, B] = k(
215
- (p == null ? void 0 : p.embalagem) ?? ((fe = (ue = (de = (ce = (le = (ae = n == null ? void 0 : n.fornecedores) == null ? void 0 : ae[0]) == null ? void 0 : le.marcas) == null ? void 0 : ce[0]) == null ? void 0 : de.embalagens) == null ? void 0 : ue[0]) == null ? void 0 : fe.label) ?? ""
216
- ), [R, G] = k(
213
+ (g == null ? void 0 : g.embalagem) ?? ((fe = (ue = (de = (ce = (le = (ae = n == null ? void 0 : n.fornecedores) == null ? void 0 : ae[0]) == null ? void 0 : le.marcas) == null ? void 0 : ce[0]) == null ? void 0 : de.embalagens) == null ? void 0 : ue[0]) == null ? void 0 : fe.label) ?? ""
214
+ ), [L, G] = k(
217
215
  Te
218
- ), [z, K] = k(Se);
216
+ ), [z, K] = k(Ie);
219
217
  Y(() => {
220
218
  var c, u, f;
221
- const e = A(), s = (c = d == null ? void 0 : d.timeline) == null ? void 0 : c.stockEndDate;
219
+ const e = O(), s = (c = d == null ? void 0 : d.timeline) == null ? void 0 : c.stockEndDate;
222
220
  let r;
223
221
  if (s) {
224
- const m = S(s);
225
- r = isNaN(m.getTime()) || m < e ? v(e) : v(m);
222
+ const p = I(s);
223
+ r = isNaN(p.getTime()) || p < e ? v(e) : v(p);
226
224
  } else
227
225
  r = v(e);
228
226
  let i = 0;
229
227
  if ((u = d == null ? void 0 : d.timeline) != null && u.restockSuggestionStart && ((f = d == null ? void 0 : d.timeline) != null && f.restockSuggestionEnd)) {
230
- const m = S(d.timeline.restockSuggestionStart), h = S(d.timeline.restockSuggestionEnd);
231
- !isNaN(m.getTime()) && !isNaN(h.getTime()) && (i = Math.ceil((h.getTime() - m.getTime()) / (1e3 * 60 * 60 * 24)) || 0);
228
+ const p = I(d.timeline.restockSuggestionStart), h = I(d.timeline.restockSuggestionEnd);
229
+ !isNaN(p.getTime()) && !isNaN(h.getTime()) && (i = Math.ceil((h.getTime() - p.getTime()) / (1e3 * 60 * 60 * 24)) || 0);
232
230
  }
233
231
  const l = j != null && j > 0 ? P(j) : P(i);
234
232
  G(r), K(l);
235
233
  }, [d, n, j]), Y(() => {
236
234
  var s, r, i;
237
- if (p) return;
235
+ if (g) return;
238
236
  const e = (s = n == null ? void 0 : n.fornecedores) == null ? void 0 : s[0];
239
237
  if (e) {
240
238
  Q(e.nome);
@@ -245,8 +243,8 @@ function nt({
245
243
  c && B(c.label);
246
244
  }
247
245
  }
248
- }, [n, p]);
249
- const M = D(() => {
246
+ }, [n, g]);
247
+ const D = M(() => {
250
248
  var l, c, u;
251
249
  const e = (l = a.fornecedores) == null ? void 0 : l[0];
252
250
  if (!e) return 0;
@@ -261,13 +259,13 @@ function nt({
261
259
  a.fornecedores,
262
260
  w,
263
261
  T
264
- ]), H = D(() => !x || M <= 0 ? null : be({
262
+ ]), H = M(() => !x || D <= 0 ? null : be({
265
263
  dailyAverages: x,
266
264
  startDate: /* @__PURE__ */ new Date(),
267
- totalQuantity: M
268
- }), [x, M]), F = (H == null ? void 0 : H.totalDays) ?? 0, y = D(() => {
265
+ totalQuantity: D
266
+ }), [x, D]), F = (H == null ? void 0 : H.totalDays) ?? 0, y = M(() => {
269
267
  if (!x) return 0;
270
- const e = A(), s = S(R);
268
+ const e = O(), s = I(L);
271
269
  if (isNaN(s.getTime())) return 0;
272
270
  const r = s < e ? e : s;
273
271
  return _e(
@@ -275,7 +273,7 @@ function nt({
275
273
  r,
276
274
  z
277
275
  );
278
- }, [x, R, z]), Z = D(() => {
276
+ }, [x, L, z]), Z = M(() => {
279
277
  if (d)
280
278
  return {
281
279
  ...d,
@@ -305,7 +303,7 @@ function nt({
305
303
  }, b = () => {
306
304
  var e;
307
305
  return ((e = J()) == null ? void 0 : e.quantidade_fornecedor) ?? 0;
308
- }, I = (e) => {
306
+ }, S = (e) => {
309
307
  const s = N(), r = e * s;
310
308
  $((i) => ({
311
309
  ...i,
@@ -317,16 +315,16 @@ function nt({
317
315
  B(e);
318
316
  const s = (c = a.fornecedores) == null ? void 0 : c[0];
319
317
  if (!s) return;
320
- const r = (u = s.marcas) == null ? void 0 : u.find((m) => m.nome === w);
318
+ const r = (u = s.marcas) == null ? void 0 : u.find((p) => p.nome === w);
321
319
  if (!r) return;
322
- const i = (f = r.embalagens) == null ? void 0 : f.find((m) => m.label === e);
320
+ const i = (f = r.embalagens) == null ? void 0 : f.find((p) => p.label === e);
323
321
  if (!i) return;
324
322
  const l = a.qtdPedido * (i.valor_unitario ?? 0);
325
- $((m) => ({
326
- ...m,
323
+ $((p) => ({
324
+ ...p,
327
325
  valorTotal: l
328
326
  }));
329
- }, De = () => {
327
+ }, Me = () => {
330
328
  var s;
331
329
  const e = (s = a.fornecedores) == null ? void 0 : s[0];
332
330
  return e ? e.marcas || [] : [];
@@ -345,7 +343,7 @@ function nt({
345
343
  if (!r || !r.embalagens || r.embalagens.length === 0) return;
346
344
  const i = r.embalagens[0];
347
345
  _(i.label);
348
- }, Le = (e) => {
346
+ }, Re = (e) => {
349
347
  var l, c, u;
350
348
  Q(e);
351
349
  const s = (l = a.fornecedores) == null ? void 0 : l.find(
@@ -360,13 +358,13 @@ function nt({
360
358
  E(r.nome);
361
359
  const i = (u = r.embalagens) == null ? void 0 : u[0];
362
360
  i ? _(i.label) : B("");
363
- }, Re = (e) => {
364
- e.preventDefault(), g(a);
361
+ }, Le = (e) => {
362
+ e.preventDefault(), m(a);
365
363
  }, ze = () => {
366
364
  const e = b();
367
365
  if (e <= 0 || y <= 0) return;
368
366
  const s = Math.ceil(y / e);
369
- I(s);
367
+ S(s);
370
368
  }, o = {
371
369
  container: {
372
370
  display: "flex",
@@ -576,7 +574,7 @@ function nt({
576
574
  backgroundColor: "#DC2626"
577
575
  }
578
576
  };
579
- return /* @__PURE__ */ t.jsxs("form", { onSubmit: Re, style: o.container, children: [
577
+ return /* @__PURE__ */ t.jsxs("form", { onSubmit: Le, style: o.container, children: [
580
578
  /* @__PURE__ */ t.jsxs("div", { style: o.header, children: [
581
579
  /* @__PURE__ */ t.jsx("h2", { style: o.itemTitle, children: a.nome }),
582
580
  /* @__PURE__ */ t.jsx("div", { style: o.valorUnitario, children: /* @__PURE__ */ t.jsx(
@@ -622,8 +620,8 @@ function nt({
622
620
  /* @__PURE__ */ t.jsx(
623
621
  W,
624
622
  {
625
- value: Me,
626
- onChange: (e) => Le(e.target.value),
623
+ value: De,
624
+ onChange: (e) => Re(e.target.value),
627
625
  children: (me = a.fornecedores) == null ? void 0 : me.map((e) => /* @__PURE__ */ t.jsx("option", { value: e.nome, children: e.nome }, e.nome))
628
626
  }
629
627
  )
@@ -635,7 +633,7 @@ function nt({
635
633
  {
636
634
  value: w,
637
635
  onChange: (e) => We(e.target.value),
638
- children: De().map((e) => /* @__PURE__ */ t.jsx("option", { value: e.nome, children: e.nome }, e.nome))
636
+ children: Me().map((e) => /* @__PURE__ */ t.jsx("option", { value: e.nome, children: e.nome }, e.nome))
639
637
  }
640
638
  )
641
639
  ] }),
@@ -656,14 +654,15 @@ function nt({
656
654
  {
657
655
  data: Z,
658
656
  controls: !0,
659
- controlsZoomOnly: we,
660
- showLegend: Ce,
657
+ controlsZoomOnly: Ce,
658
+ showLegend: qe,
661
659
  size: "sm",
662
- showSuggestionBar: qe,
663
- unitLabel: L,
664
- onAddSuggestedWeight: (e) => I(e),
665
- selectedQty: M,
666
- selectedQtyDays: F
660
+ showSuggestionBar: ke,
661
+ unitLabel: R,
662
+ onAddSuggestedWeight: (e) => S(e),
663
+ selectedQty: D,
664
+ selectedQtyDays: F,
665
+ minNavigationDays: we
667
666
  }
668
667
  ) }),
669
668
  /* @__PURE__ */ t.jsxs(
@@ -682,8 +681,8 @@ function nt({
682
681
  /* @__PURE__ */ t.jsx(
683
682
  Oe,
684
683
  {
685
- value: R,
686
- min: Ye(),
684
+ value: L,
685
+ min: Ve(),
687
686
  onChange: (e) => G(e.target.value),
688
687
  "aria-label": "Data inicial"
689
688
  }
@@ -745,7 +744,7 @@ function nt({
745
744
  fontWeight: "500",
746
745
  color: "#64748b"
747
746
  },
748
- children: L
747
+ children: R
749
748
  }
750
749
  )
751
750
  ]
@@ -803,7 +802,7 @@ function nt({
803
802
  ...o.quantityButton,
804
803
  ...a.qtdPedido <= 0 ? o.quantityButtonDisabled : {}
805
804
  },
806
- onClick: () => I(Math.max(0, a.qtdPedido - 1)),
805
+ onClick: () => S(Math.max(0, a.qtdPedido - 1)),
807
806
  onMouseEnter: (e) => {
808
807
  a.qtdPedido > 0 && (e.currentTarget.style.background = o.quantityButtonHover.background, e.currentTarget.style.transform = o.quantityButtonHover.transform);
809
808
  },
@@ -844,7 +843,7 @@ function nt({
844
843
  {
845
844
  type: "number",
846
845
  value: a.qtdPedido,
847
- onChange: (e) => I(
846
+ onChange: (e) => S(
848
847
  Math.max(0, parseInt(e.target.value) || 0)
849
848
  ),
850
849
  style: o.quantityInput,
@@ -860,7 +859,7 @@ function nt({
860
859
  {
861
860
  type: "button",
862
861
  style: o.quantityButton,
863
- onClick: () => I(a.qtdPedido + 1),
862
+ onClick: () => S(a.qtdPedido + 1),
864
863
  onMouseEnter: (e) => {
865
864
  e.currentTarget.style.background = o.quantityButtonHover.background, e.currentTarget.style.transform = o.quantityButtonHover.transform;
866
865
  },
@@ -919,7 +918,7 @@ function nt({
919
918
  /* @__PURE__ */ t.jsxs("span", { style: o.totalValue, children: [
920
919
  (a.qtdPedido * b()).toFixed(2),
921
920
  " ",
922
- L
921
+ R
923
922
  ] })
924
923
  ]
925
924
  }
@@ -1000,6 +999,6 @@ function nt({
1000
999
  ] });
1001
1000
  }
1002
1001
  export {
1003
- nt as OrderForm
1002
+ tt as OrderForm
1004
1003
  };
1005
1004
  //# sourceMappingURL=index10.js.map