@plurix/ecom-components 1.14.1-eng-task-1249.11 → 1.14.1-eng-task-1249.12

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.
@@ -1,7 +1,6 @@
1
1
  import { Dispatch, SetStateAction } from 'react';
2
2
  import { SelectedItemProps } from './components/ProductSelected';
3
3
  import { SimilarProducts as SimilarProductsProps } from '../../types/ChangeOrderModal';
4
- import { GetOrderFormMutationInput } from './api/getOrderForm';
5
4
 
6
5
  export interface ChangeOrderModalProps {
7
6
  postalCode: string;
@@ -12,15 +11,19 @@ export interface ChangeOrderModalProps {
12
11
  isClubClient?: boolean;
13
12
  orderFormId: string;
14
13
  saveSelectedSimilarProduct?: (similarProduct: SimilarProductsProps | undefined) => void;
15
- getOrderFormMutation?: (variables: GetOrderFormMutationInput) => Promise<{
14
+ getOrderFormMutation?: (variables: {}) => Promise<CustomDataMutationResponse>;
15
+ getProductsSimilarsMutation?: any;
16
+ postChangeOrderMutation?: any;
17
+ }
18
+ interface CustomDataMutationResponse {
19
+ data: {
16
20
  getOrderForm: {
17
21
  data: string;
18
22
  };
19
- }>;
20
- getProductsSimilarsMutation?: any;
21
- postChangeOrderMutation?: any;
23
+ };
22
24
  }
23
25
  export interface idSubstitutionCriteriasProps {
24
26
  [key: string]: string;
25
27
  }
26
28
  export declare const ChangeOrderModal: ({ selectedItem, postalCode, orderFormId, isClubClient, isOpen, environment, setIsOpen, saveSelectedSimilarProduct, getOrderFormMutation, getProductsSimilarsMutation, postChangeOrderMutation }: ChangeOrderModalProps) => import("react/jsx-runtime").JSX.Element;
29
+ export {};
@@ -1,116 +1,119 @@
1
- import { jsx as n, jsxs as N, Fragment as k } from "react/jsx-runtime";
2
- import { useState as f, useEffect as A } from "react";
3
- import { Modal as E } from "../Modal/Modal.js";
4
- import { ProductSelected as _ } from "./components/ProductSelected.js";
5
- import { SimilarProducts as v } from "./components/SimilarProducts.js";
6
- import { ModalFooter as J } from "./components/ModalFooter.js";
7
- /* empty css */import { getProductsSimilars as L } from "./api/getProductsSimilars.js";
8
- import T from "../../hooks/useAnalitcsEvents.js";
9
- import { NoSimilarProduct as $ } from "./components/NoSimilarProduct.js";
10
- import { getOrderForm as z } from "./api/getOrderForm.js";
11
- import { postChangeOrder as B } from "./api/postChangeOrder.js";
12
- import { Skeleton as G } from "../Skeleton/index.js";
13
- const io = ({
1
+ import { jsx as s, jsxs as E, Fragment as J } from "react/jsx-runtime";
2
+ import { useState as e, useEffect as M } from "react";
3
+ import { Modal as _ } from "../Modal/Modal.js";
4
+ import { ProductSelected as v } from "./components/ProductSelected.js";
5
+ import { SimilarProducts as L } from "./components/SimilarProducts.js";
6
+ import { ModalFooter as T } from "./components/ModalFooter.js";
7
+ /* empty css */import { getProductsSimilars as $ } from "./api/getProductsSimilars.js";
8
+ import z from "../../hooks/useAnalitcsEvents.js";
9
+ import { NoSimilarProduct as B } from "./components/NoSimilarProduct.js";
10
+ import { getOrderForm as G } from "./api/getOrderForm.js";
11
+ import { postChangeOrder as H } from "./api/postChangeOrder.js";
12
+ import { Skeleton as K } from "../Skeleton/index.js";
13
+ const so = ({
14
14
  selectedItem: o,
15
- postalCode: h,
16
- orderFormId: l,
17
- isClubClient: S,
18
- isOpen: y,
19
- environment: O,
15
+ postalCode: O,
16
+ orderFormId: d,
17
+ isClubClient: b,
18
+ isOpen: C,
19
+ environment: P,
20
20
  setIsOpen: p,
21
- saveSelectedSimilarProduct: u,
22
- getOrderFormMutation: b,
23
- getProductsSimilarsMutation: C,
21
+ saveSelectedSimilarProduct: f,
22
+ getOrderFormMutation: g,
23
+ getProductsSimilarsMutation: x,
24
24
  postChangeOrderMutation: F
25
25
  }) => {
26
- const [a, P] = f(), [x, m] = f(!1), s = O === "io", { genericTaggingEvent: j } = T(), [r, e] = f({ itemId: "" });
27
- A(() => {
26
+ const [a, N] = e(), [j, m] = e(!1), r = P === "io", { genericTaggingEvent: q } = z(), [t, h] = e({ itemId: "" });
27
+ M(() => {
28
28
  (async () => {
29
29
  m(!0);
30
30
  try {
31
- const t = await L({
32
- postalCode: h,
31
+ const i = await $({
32
+ postalCode: O,
33
33
  selectedItem: o,
34
- isIO: s,
35
- getProductsSimilarsMutation: C
36
- }), d = (t == null ? void 0 : t.products) || [];
37
- P(d);
34
+ isIO: r,
35
+ getProductsSimilarsMutation: x
36
+ }), u = (i == null ? void 0 : i.products) || [];
37
+ N(u);
38
38
  } finally {
39
39
  m(!1);
40
40
  }
41
41
  })(), (async () => {
42
- var t, d;
42
+ var i, u;
43
43
  m(!0);
44
44
  try {
45
- const c = await z(
46
- l,
47
- s,
48
- b
49
- ), i = ((d = (t = c == null ? void 0 : c.customData) == null ? void 0 : t.customApps) == null ? void 0 : d.find(
50
- (M) => M.id === "janis"
45
+ const S = r && G(d, r), c = g && g({
46
+ input: {
47
+ orderFormId: d
48
+ }
49
+ });
50
+ if (console.log("mutationResponse", c), !S)
51
+ return;
52
+ const l = r ? S : JSON.parse(c == null ? void 0 : c.getOrderForm.data), n = ((u = (i = l == null ? void 0 : l.customData) == null ? void 0 : i.customApps) == null ? void 0 : u.find(
53
+ (A) => A.id === "janis"
51
54
  )) || null;
52
- let g = {};
53
- i != null && i.fields.idSubstitutionCriterias && (g = JSON.parse(
54
- i == null ? void 0 : i.fields.idSubstitutionCriterias
55
+ let y = {};
56
+ n != null && n.fields.idSubstitutionCriterias && (y = JSON.parse(
57
+ n == null ? void 0 : n.fields.idSubstitutionCriterias
55
58
  ));
56
59
  const w = o == null ? void 0 : o.productOriginId;
57
- e({
58
- itemId: `${g[w]}`
60
+ h({
61
+ itemId: `${y[w]}`
59
62
  });
60
63
  } finally {
61
64
  m(!1);
62
65
  }
63
66
  })();
64
67
  }, []);
65
- const q = () => {
66
- B(
67
- l,
68
- s,
68
+ const k = () => {
69
+ H(
70
+ d,
71
+ r,
69
72
  o.productOriginId,
70
- r.itemId,
73
+ t.itemId,
71
74
  F
72
- ), r && (u == null || u(r), j("salvar_substituto", {
75
+ ), t && (f == null || f(t), q("salvar_substituto", {
73
76
  name: o.name,
74
- replacement_item: r == null ? void 0 : r.name
77
+ replacement_item: t == null ? void 0 : t.name
75
78
  })), p(!1);
76
79
  };
77
- return /* @__PURE__ */ n(
78
- E,
80
+ return /* @__PURE__ */ s(
81
+ _,
79
82
  {
80
- isOpen: y,
83
+ isOpen: C,
81
84
  setIsOpen: p,
82
85
  className: "change-order-modal",
83
86
  title: "Produto com estoque baixo",
84
- Footer: a && a.length > 0 && /* @__PURE__ */ n(
85
- J,
87
+ Footer: a && a.length > 0 && /* @__PURE__ */ s(
88
+ T,
86
89
  {
87
- saveSelectedSimilarProduct: q
90
+ saveSelectedSimilarProduct: k
88
91
  }
89
92
  ),
90
- children: x ? /* @__PURE__ */ n(
91
- G,
93
+ children: j ? /* @__PURE__ */ s(
94
+ K,
92
95
  {
93
- width: s ? "100%" : "90%",
94
- height: s ? 600 : 425,
96
+ width: r ? "100%" : "90%",
97
+ height: r ? 600 : 425,
95
98
  backgroundColor: "var(--color-grayScale-faded)",
96
99
  margin: "auto",
97
100
  animation: !0
98
101
  }
99
- ) : /* @__PURE__ */ N(k, { children: [
100
- o && /* @__PURE__ */ n(_, { selectedItem: o }),
101
- a && a.length > 0 ? /* @__PURE__ */ n(
102
- v,
102
+ ) : /* @__PURE__ */ E(J, { children: [
103
+ o && /* @__PURE__ */ s(v, { selectedItem: o }),
104
+ a && a.length > 0 ? /* @__PURE__ */ s(
105
+ L,
103
106
  {
104
- isClubClient: S,
105
- similarProductSelect: r,
106
- setSimilarProductSelect: e,
107
+ isClubClient: b,
108
+ similarProductSelect: t,
109
+ setSimilarProductSelect: h,
107
110
  products: a
108
111
  }
109
- ) : /* @__PURE__ */ n($, {})
112
+ ) : /* @__PURE__ */ s(B, {})
110
113
  ] })
111
114
  }
112
115
  );
113
116
  };
114
117
  export {
115
- io as ChangeOrderModal
118
+ so as ChangeOrderModal
116
119
  };
@@ -1,24 +1 @@
1
- export interface CustomDataMutation {
2
- getOrderForm: {
3
- data: string;
4
- };
5
- }
6
- export interface CustomData {
7
- customApps: CustomApp[];
8
- customFields: unknown[];
9
- }
10
- export interface GetOrderFormMutationInput {
11
- input: {
12
- orderFormId: string;
13
- };
14
- }
15
- export interface CustomApp {
16
- fields: Record<string, string>;
17
- id: string;
18
- major: number;
19
- }
20
- export declare const getOrderForm: (orderFormId: string, isIO: boolean, getOrderFormMutation?: (variables: GetOrderFormMutationInput) => Promise<{
21
- getOrderForm: {
22
- data: string;
23
- };
24
- }>) => Promise<any>;
1
+ export declare const getOrderForm: (orderFormId: string, isIO: boolean) => Promise<any>;
@@ -1,24 +1,16 @@
1
- import n from "axios";
2
- const i = async (t, o, e) => {
1
+ import e from "axios";
2
+ const c = async (o, t) => {
3
3
  try {
4
- if (o) {
5
- const { data: a } = await n.post(
6
- `/api/checkout/pub/orderForm/${t}`
4
+ if (t) {
5
+ const { data: r } = await e.post(
6
+ `/api/checkout/pub/orderForm/${o}`
7
7
  );
8
- return a;
8
+ return r;
9
9
  }
10
- if (!e)
11
- return;
12
- const { getOrderForm: r } = await e({
13
- input: {
14
- orderFormId: t
15
- }
16
- });
17
- return JSON.parse(r.data);
18
10
  } catch (r) {
19
11
  console.error("Error in Change Order Modal", r);
20
12
  }
21
13
  };
22
14
  export {
23
- i as getOrderForm
15
+ c as getOrderForm
24
16
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@plurix/ecom-components",
3
3
  "author": "Plurix",
4
4
  "private": false,
5
- "version": "1.14.1-eng-task-1249.11",
5
+ "version": "1.14.1-eng-task-1249.12",
6
6
  "type": "module",
7
7
  "main": "dist/main.js",
8
8
  "types": "dist/main.d.ts",