eatopia-ds 0.0.952 → 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,15 +1,15 @@
1
1
  import { j as t } from "./index24.js";
2
- import ze, { useState as k, useEffect as Y, useMemo as D } from "react";
3
- import { StockLeadTime as He } from "./index18.js";
4
- import { calculateConsumptionForecast as ye, calculateTotalConsumptionForRange as Ne } from "./index21.js";
5
- import { AlertIcon as _e } from "./index23.js";
2
+ import He, { useState as k, useEffect as Y, useMemo as M } from "react";
3
+ import { StockLeadTime as Ne } from "./index18.js";
4
+ import { calculateConsumptionForecast as be, calculateTotalConsumptionForRange as _e } from "./index21.js";
5
+ import { AlertIcon as Ue } from "./index23.js";
6
6
  const he = [1, 2, 3, 7, 10, 15, 30, 60, 90], v = (n) => {
7
7
  const m = n.getFullYear(), q = String(n.getMonth() + 1).padStart(2, "0"), d = String(n.getDate()).padStart(2, "0");
8
8
  return `${m}-${q}-${d}`;
9
9
  }, I = (n) => {
10
10
  const m = n.split("-").map(Number);
11
11
  return m.length !== 3 || m.some(Number.isNaN) ? /* @__PURE__ */ new Date(NaN) : new Date(m[0], m[1] - 1, m[2]);
12
- }, Ue = () => {
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
15
  }, O = () => {
@@ -17,9 +17,9 @@ const he = [1, 2, 3, 7, 10, 15, 30, 60, 90], v = (n) => {
17
17
  return n.setDate(n.getDate() + 1), n.setHours(0, 0, 0, 0), n;
18
18
  }, P = (n) => n <= 0 ? 7 : he.reduce(
19
19
  (m, q) => Math.abs(q - n) < Math.abs(m - n) ? q : m
20
- ), Ve = 42, ve = {
20
+ ), Ye = 42, ve = {
21
21
  position: "relative",
22
- height: `${Ve}px`,
22
+ height: `${Ye}px`,
23
23
  border: "1.5px solid #e2e8f0",
24
24
  borderRadius: "10px",
25
25
  backgroundColor: "#f8fafc",
@@ -87,7 +87,7 @@ const he = [1, 2, 3, 7, 10, 15, 30, 60, 90], v = (n) => {
87
87
  )
88
88
  }
89
89
  )
90
- ] }), Ye = (n) => /* @__PURE__ */ t.jsx("div", { style: ve, children: /* @__PURE__ */ t.jsx(
90
+ ] }), Oe = (n) => /* @__PURE__ */ t.jsx("div", { style: ve, children: /* @__PURE__ */ t.jsx(
91
91
  "input",
92
92
  {
93
93
  type: "date",
@@ -95,22 +95,23 @@ const he = [1, 2, 3, 7, 10, 15, 30, 60, 90], v = (n) => {
95
95
  style: { ...je, padding: "0 14px" }
96
96
  }
97
97
  ) });
98
- function et({
98
+ function tt({
99
99
  data: n,
100
100
  onSubmit: m,
101
101
  onCancel: q,
102
102
  timelineData: d,
103
- fornecedoresOptions: Oe,
104
- marcasOptions: Ae,
105
- embalagensOptions: $e,
103
+ fornecedoresOptions: Ae,
104
+ marcasOptions: $e,
105
+ embalagensOptions: Qe,
106
106
  dailyConsumptionAverages: x,
107
107
  showSuggestionBar: ke = !0,
108
108
  showLegendTimeline: qe = !1,
109
109
  initialQtdDays: j,
110
- stockLeadTimeZoomOnly: Ce = !1
110
+ stockLeadTimeZoomOnly: Ce = !1,
111
+ stockLeadTimeMinNavigationDays: we
111
112
  }) {
112
113
  var ee, te, ne, oe, re, se, ie, ae, le, ce, de, ue, fe, ge, pe, me;
113
- ze.useEffect(() => {
114
+ He.useEffect(() => {
114
115
  const e = document.createElement("style");
115
116
  return e.textContent = `
116
117
  .order-form-quantity-input::-webkit-outer-spin-button,
@@ -125,10 +126,10 @@ function et({
125
126
  document.head.removeChild(e);
126
127
  };
127
128
  }, []);
128
- const [C, we] = k(!1);
129
+ const [C, Fe] = k(!1);
129
130
  Y(() => {
130
131
  const e = () => {
131
- we(window.innerWidth <= 768);
132
+ Fe(window.innerWidth <= 768);
132
133
  };
133
134
  return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
134
135
  }, []);
@@ -138,13 +139,13 @@ function et({
138
139
  if (!e || !s) return 0;
139
140
  const r = new Date(e), l = new Date(s).getTime() - r.getTime(), c = Math.ceil(l / (1e3 * 60 * 60 * 24));
140
141
  return c > 0 ? c : 0;
141
- }, Fe = () => {
142
+ }, Te = () => {
142
143
  var i;
143
144
  const e = O(), s = (i = d == null ? void 0 : d.timeline) == null ? void 0 : i.stockEndDate;
144
145
  if (!s) return v(e);
145
146
  const r = I(s);
146
147
  return isNaN(r.getTime()) || r < e ? v(e) : v(r);
147
- }, Te = () => P(A()), Se = () => j != null && j > 0 ? P(j) : Te(), g = (() => {
148
+ }, Se = () => P(A()), Ie = () => j != null && j > 0 ? P(j) : Se(), g = (() => {
148
149
  var i, l, c;
149
150
  const e = (i = n == null ? void 0 : n.fornecedores) == null ? void 0 : i[0];
150
151
  if (!e) return null;
@@ -164,20 +165,20 @@ function et({
164
165
  const p = f.quantidade_fornecedor;
165
166
  if (!(p <= 0))
166
167
  for (let h = 1; h <= 100; h++) {
167
- const xe = h * p, U = ye({
168
+ const xe = h * p, U = be({
168
169
  dailyAverages: x,
169
170
  startDate: /* @__PURE__ */ new Date(),
170
171
  totalQuantity: xe
171
172
  });
172
173
  if (U.totalDays >= s) {
173
- const be = h * f.valor_unitario * p, V = U.totalDays - s;
174
- (!r || V < r.daysDifference || V === r.daysDifference && be < r.totalValue) && (r = {
174
+ const ye = h * f.valor_unitario * p, V = U.totalDays - s;
175
+ (!r || V < r.daysDifference || V === r.daysDifference && ye < r.totalValue) && (r = {
175
176
  marca: u.nome,
176
177
  embalagem: f.label,
177
178
  quantidade: h,
178
179
  valorUnitario: f.valor_unitario,
179
180
  totalKg: xe,
180
- totalValue: be,
181
+ totalValue: ye,
181
182
  days: U.totalDays,
182
183
  daysDifference: V
183
184
  });
@@ -190,7 +191,7 @@ function et({
190
191
  quantidade: r.quantidade,
191
192
  valorUnitario: r.valorUnitario
192
193
  } : null;
193
- })(), Ie = () => {
194
+ })(), Ee = () => {
194
195
  var i, l, c;
195
196
  if (g)
196
197
  return g.valorUnitario;
@@ -200,19 +201,19 @@ function et({
200
201
  if (!s) return 0;
201
202
  const r = (c = s.embalagens) == null ? void 0 : c[0];
202
203
  return (r == null ? void 0 : r.valor_unitario) ?? 0;
203
- }, R = n.unidade_medida ?? "kg", Ee = ((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({
204
205
  ...n,
205
206
  qtdPedido: (g == null ? void 0 : g.quantidade) ?? (n == null ? void 0 : n.qtdPedido) ?? 0,
206
- valorTotal: (n == null ? void 0 : n.valorTotal) ?? ((g == null ? void 0 : g.quantidade) ?? (n == null ? void 0 : n.qtdPedido) ?? 0) * Ie()
207
- }), [Be, Q] = k(
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(
208
209
  ((ne = (te = n == null ? void 0 : n.fornecedores) == null ? void 0 : te[0]) == null ? void 0 : ne.nome) ?? ""
209
210
  ), [w, E] = k(
210
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) ?? ""
211
212
  ), [T, B] = k(
212
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) ?? ""
213
214
  ), [L, G] = k(
214
- Fe
215
- ), [z, K] = k(Se);
215
+ Te
216
+ ), [z, K] = k(Ie);
216
217
  Y(() => {
217
218
  var c, u, f;
218
219
  const e = O(), s = (c = d == null ? void 0 : d.timeline) == null ? void 0 : c.stockEndDate;
@@ -243,7 +244,7 @@ function et({
243
244
  }
244
245
  }
245
246
  }, [n, g]);
246
- const M = D(() => {
247
+ const D = M(() => {
247
248
  var l, c, u;
248
249
  const e = (l = a.fornecedores) == null ? void 0 : l[0];
249
250
  if (!e) return 0;
@@ -258,21 +259,21 @@ function et({
258
259
  a.fornecedores,
259
260
  w,
260
261
  T
261
- ]), H = D(() => !x || M <= 0 ? null : ye({
262
+ ]), H = M(() => !x || D <= 0 ? null : be({
262
263
  dailyAverages: x,
263
264
  startDate: /* @__PURE__ */ new Date(),
264
- totalQuantity: M
265
- }), [x, M]), F = (H == null ? void 0 : H.totalDays) ?? 0, b = D(() => {
265
+ totalQuantity: D
266
+ }), [x, D]), F = (H == null ? void 0 : H.totalDays) ?? 0, y = M(() => {
266
267
  if (!x) return 0;
267
268
  const e = O(), s = I(L);
268
269
  if (isNaN(s.getTime())) return 0;
269
270
  const r = s < e ? e : s;
270
- return Ne(
271
+ return _e(
271
272
  x,
272
273
  r,
273
274
  z
274
275
  );
275
- }, [x, L, z]), Z = D(() => {
276
+ }, [x, L, z]), Z = M(() => {
276
277
  if (d)
277
278
  return {
278
279
  ...d,
@@ -299,7 +300,7 @@ function et({
299
300
  /\B(?=(\d{3})+(?!\d))/g,
300
301
  "."
301
302
  )},${i}`;
302
- }, y = () => {
303
+ }, b = () => {
303
304
  var e;
304
305
  return ((e = J()) == null ? void 0 : e.quantidade_fornecedor) ?? 0;
305
306
  }, S = (e) => {
@@ -327,13 +328,13 @@ function et({
327
328
  var s;
328
329
  const e = (s = a.fornecedores) == null ? void 0 : s[0];
329
330
  return e ? e.marcas || [] : [];
330
- }, De = () => {
331
+ }, Pe = () => {
331
332
  var r, i;
332
333
  const e = (r = a.fornecedores) == null ? void 0 : r[0];
333
334
  if (!e) return [];
334
335
  const s = (i = e.marcas) == null ? void 0 : i.find((l) => l.nome === w);
335
336
  return s ? s.embalagens || [] : [];
336
- }, Pe = (e) => {
337
+ }, We = (e) => {
337
338
  var l, c;
338
339
  E(e);
339
340
  const s = (l = a.fornecedores) == null ? void 0 : l[0];
@@ -342,7 +343,7 @@ function et({
342
343
  if (!r || !r.embalagens || r.embalagens.length === 0) return;
343
344
  const i = r.embalagens[0];
344
345
  _(i.label);
345
- }, We = (e) => {
346
+ }, Re = (e) => {
346
347
  var l, c, u;
347
348
  Q(e);
348
349
  const s = (l = a.fornecedores) == null ? void 0 : l.find(
@@ -357,12 +358,12 @@ function et({
357
358
  E(r.nome);
358
359
  const i = (u = r.embalagens) == null ? void 0 : u[0];
359
360
  i ? _(i.label) : B("");
360
- }, Re = (e) => {
361
+ }, Le = (e) => {
361
362
  e.preventDefault(), m(a);
362
- }, Le = () => {
363
- const e = y();
364
- if (e <= 0 || b <= 0) return;
365
- const s = Math.ceil(b / e);
363
+ }, ze = () => {
364
+ const e = b();
365
+ if (e <= 0 || y <= 0) return;
366
+ const s = Math.ceil(y / e);
366
367
  S(s);
367
368
  }, o = {
368
369
  container: {
@@ -573,7 +574,7 @@ function et({
573
574
  backgroundColor: "#DC2626"
574
575
  }
575
576
  };
576
- return /* @__PURE__ */ t.jsxs("form", { onSubmit: Re, style: o.container, children: [
577
+ return /* @__PURE__ */ t.jsxs("form", { onSubmit: Le, style: o.container, children: [
577
578
  /* @__PURE__ */ t.jsxs("div", { style: o.header, children: [
578
579
  /* @__PURE__ */ t.jsx("h2", { style: o.itemTitle, children: a.nome }),
579
580
  /* @__PURE__ */ t.jsx("div", { style: o.valorUnitario, children: /* @__PURE__ */ t.jsx(
@@ -603,14 +604,14 @@ function et({
603
604
  children: [
604
605
  /* @__PURE__ */ t.jsxs("div", { style: o.infoRow, children: [
605
606
  /* @__PURE__ */ t.jsxs("div", { style: o.infoText, children: [
606
- /* @__PURE__ */ t.jsx(_e, { width: 20, height: 20 }),
607
+ /* @__PURE__ */ t.jsx(Ue, { width: 20, height: 20 }),
607
608
  "Última compra ",
608
609
  (ge = a.ultima_compra) == null ? void 0 : ge.data
609
610
  ] }),
610
611
  /* @__PURE__ */ t.jsxs("div", { style: o.infoValue, children: [
611
612
  Number(((pe = a.ultima_compra) == null ? void 0 : pe.quantidade) ?? 0).toFixed(2),
612
613
  " ",
613
- Ee.toUpperCase()
614
+ Be.toUpperCase()
614
615
  ] })
615
616
  ] }),
616
617
  /* @__PURE__ */ t.jsxs("div", { style: o.formGrid, children: [
@@ -619,8 +620,8 @@ function et({
619
620
  /* @__PURE__ */ t.jsx(
620
621
  W,
621
622
  {
622
- value: Be,
623
- onChange: (e) => We(e.target.value),
623
+ value: De,
624
+ onChange: (e) => Re(e.target.value),
624
625
  children: (me = a.fornecedores) == null ? void 0 : me.map((e) => /* @__PURE__ */ t.jsx("option", { value: e.nome, children: e.nome }, e.nome))
625
626
  }
626
627
  )
@@ -631,7 +632,7 @@ function et({
631
632
  W,
632
633
  {
633
634
  value: w,
634
- onChange: (e) => Pe(e.target.value),
635
+ onChange: (e) => We(e.target.value),
635
636
  children: Me().map((e) => /* @__PURE__ */ t.jsx("option", { value: e.nome, children: e.nome }, e.nome))
636
637
  }
637
638
  )
@@ -643,13 +644,13 @@ function et({
643
644
  {
644
645
  value: T,
645
646
  onChange: (e) => _(e.target.value),
646
- children: De().map((e) => /* @__PURE__ */ t.jsx("option", { value: e.label, children: e.label }, e.label))
647
+ children: Pe().map((e) => /* @__PURE__ */ t.jsx("option", { value: e.label, children: e.label }, e.label))
647
648
  }
648
649
  )
649
650
  ] })
650
651
  ] }),
651
652
  Z && /* @__PURE__ */ t.jsx("div", { style: { marginTop: "8px", marginBottom: "8px" }, children: /* @__PURE__ */ t.jsx(
652
- He,
653
+ Ne,
653
654
  {
654
655
  data: Z,
655
656
  controls: !0,
@@ -659,8 +660,9 @@ function et({
659
660
  showSuggestionBar: ke,
660
661
  unitLabel: R,
661
662
  onAddSuggestedWeight: (e) => S(e),
662
- selectedQty: M,
663
- selectedQtyDays: F
663
+ selectedQty: D,
664
+ selectedQtyDays: F,
665
+ minNavigationDays: we
664
666
  }
665
667
  ) }),
666
668
  /* @__PURE__ */ t.jsxs(
@@ -677,10 +679,10 @@ function et({
677
679
  /* @__PURE__ */ t.jsxs("div", { style: o.formField, children: [
678
680
  /* @__PURE__ */ t.jsx("label", { style: o.label, children: "Data inicial" }),
679
681
  /* @__PURE__ */ t.jsx(
680
- Ye,
682
+ Oe,
681
683
  {
682
684
  value: L,
683
- min: Ue(),
685
+ min: Ve(),
684
686
  onChange: (e) => G(e.target.value),
685
687
  "aria-label": "Data inicial"
686
688
  }
@@ -732,7 +734,7 @@ function et({
732
734
  letterSpacing: "-0.3px"
733
735
  },
734
736
  children: [
735
- b.toFixed(2),
737
+ y.toFixed(2),
736
738
  " ",
737
739
  /* @__PURE__ */ t.jsx(
738
740
  "span",
@@ -752,8 +754,8 @@ function et({
752
754
  "button",
753
755
  {
754
756
  type: "button",
755
- onClick: Le,
756
- disabled: b <= 0 || y() <= 0,
757
+ onClick: ze,
758
+ disabled: y <= 0 || b() <= 0,
757
759
  style: {
758
760
  display: "flex",
759
761
  alignItems: "center",
@@ -763,19 +765,19 @@ function et({
763
765
  minWidth: "30px",
764
766
  borderRadius: "8px",
765
767
  border: "none",
766
- backgroundColor: b > 0 && y() > 0 ? "#FF4E00" : "#e5e7eb",
767
- color: b > 0 && y() > 0 ? "white" : "#9ca3af",
768
+ backgroundColor: y > 0 && b() > 0 ? "#FF4E00" : "#e5e7eb",
769
+ color: y > 0 && b() > 0 ? "white" : "#9ca3af",
768
770
  fontSize: "16px",
769
- cursor: b > 0 && y() > 0 ? "pointer" : "not-allowed",
770
- opacity: b <= 0 || y() <= 0 ? 0.5 : 1,
771
+ cursor: y > 0 && b() > 0 ? "pointer" : "not-allowed",
772
+ opacity: y <= 0 || b() <= 0 ? 0.5 : 1,
771
773
  transition: "all 0.2s",
772
774
  fontFamily: "Inter, sans-serif"
773
775
  },
774
776
  onMouseEnter: (e) => {
775
- b > 0 && y() > 0 && (e.currentTarget.style.backgroundColor = "#e04400");
777
+ y > 0 && b() > 0 && (e.currentTarget.style.backgroundColor = "#e04400");
776
778
  },
777
779
  onMouseLeave: (e) => {
778
- b > 0 && y() > 0 && (e.currentTarget.style.backgroundColor = "#FF4E00");
780
+ y > 0 && b() > 0 && (e.currentTarget.style.backgroundColor = "#FF4E00");
779
781
  },
780
782
  "aria-label": "Definir quantidade pelo consumo previsto",
781
783
  children: "↻"
@@ -914,7 +916,7 @@ function et({
914
916
  children: [
915
917
  /* @__PURE__ */ t.jsx("span", { style: o.totalLabel, children: "Total:" }),
916
918
  /* @__PURE__ */ t.jsxs("span", { style: o.totalValue, children: [
917
- (a.qtdPedido * y()).toFixed(2),
919
+ (a.qtdPedido * b()).toFixed(2),
918
920
  " ",
919
921
  R
920
922
  ] })
@@ -997,6 +999,6 @@ function et({
997
999
  ] });
998
1000
  }
999
1001
  export {
1000
- et as OrderForm
1002
+ tt as OrderForm
1001
1003
  };
1002
1004
  //# sourceMappingURL=index10.js.map