@uappi/public-sdk 1.2.9 → 1.3.0

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.
Files changed (109) hide show
  1. package/.gitlab-ci.yml +43 -0
  2. package/.vscode/extensions.json +4 -4
  3. package/.vscode/settings.json +6 -6
  4. package/README.md +67 -0
  5. package/components/Animations/ExpandTransition.ts +89 -89
  6. package/components/Animations/index.ts +1 -1
  7. package/components/ColorTheme/ColorTheme.ts +80 -80
  8. package/components/ColorTheme/index.ts +1 -1
  9. package/components/ColorTheme/types.ts +18 -18
  10. package/components/SocialAuth/FacebookAuth/types.ts +2 -2
  11. package/components/SocialAuth/GoogleAuth/types.ts +2 -2
  12. package/components/SocialAuth/index.ts +1 -1
  13. package/components/index.ts +2 -2
  14. package/main.ts +4 -4
  15. package/modules/Api/README.md +479 -469
  16. package/modules/Api/endpoints/CategoryComposable.ts +15 -0
  17. package/modules/Api/endpoints/CommonComposable.ts +24 -24
  18. package/modules/Api/endpoints/CouponComposable.ts +18 -18
  19. package/modules/Api/endpoints/LoggoutComposable.ts +8 -8
  20. package/modules/Api/endpoints/MFAComposable.ts +43 -43
  21. package/modules/Api/endpoints/PaymentComposable.ts +14 -14
  22. package/modules/Api/endpoints/PublicComposable.ts +8 -8
  23. package/modules/Api/endpoints/TemplateComposable.ts +7 -7
  24. package/modules/Api/endpoints/ThirdPartyComposable.ts +13 -13
  25. package/modules/Api/endpoints/UpsellComposable.ts +17 -17
  26. package/modules/Api/endpoints/VerifyComposable.ts +7 -7
  27. package/modules/Api/endpoints/WalletComposable.ts +36 -36
  28. package/modules/Api/index.ts +3 -0
  29. package/modules/Api/paramsSerializer/encodeWafNormalizer.ts +7 -7
  30. package/modules/Api/types/endpoints/cart/cart.interfaces.ts +161 -161
  31. package/modules/Api/types/endpoints/cart/cart.types.ts +27 -27
  32. package/modules/Api/types/endpoints/category/category.interfaces.ts +16 -0
  33. package/modules/Api/types/endpoints/common/common.interfaces.ts +21 -21
  34. package/modules/Api/types/endpoints/country/country.types.ts +7502 -7502
  35. package/modules/Api/types/endpoints/coupon/coupon.interfaces.ts +13 -13
  36. package/modules/Api/types/endpoints/discounts/discounts.interfaces.ts +9 -9
  37. package/modules/Api/types/endpoints/mfa/mfa.interfaces.ts +51 -51
  38. package/modules/Api/types/endpoints/payment/payment.interfaces.ts +103 -103
  39. package/modules/Api/types/endpoints/payment/payment.types.ts +27 -27
  40. package/modules/Api/types/endpoints/price/price.interfaces.ts +21 -21
  41. package/modules/Api/types/endpoints/template/template.interfaces.ts +29 -29
  42. package/modules/Api/types/endpoints/third-party/oauth.interfaces.ts +5 -5
  43. package/modules/Api/types/endpoints/upsell/upsell.interfaces.ts +12 -12
  44. package/modules/Api/types/endpoints/wallet/wallet-obsearch.ts +8 -8
  45. package/modules/Api/types/endpoints/wallet/wallet.interfaces.ts +57 -57
  46. package/modules/Api/types/endpoints/zipcode/zipcode.interfaces.ts +23 -23
  47. package/modules/Api/types/index.ts +514 -504
  48. package/modules/Tracking/endpoints/CartComposable.ts +75 -75
  49. package/modules/Tracking/endpoints/CustomerComposable.ts +71 -71
  50. package/modules/Tracking/endpoints/types.ts +11 -11
  51. package/modules/Tracking/events/actions/addPaymentInfo.ts +31 -31
  52. package/modules/Tracking/events/actions/addShippingInfo.ts +27 -27
  53. package/modules/Tracking/events/actions/addToCart.ts +35 -35
  54. package/modules/Tracking/events/actions/beginCheckout.ts +28 -28
  55. package/modules/Tracking/events/actions/customerProfile.ts +36 -36
  56. package/modules/Tracking/events/actions/generateLead.ts +12 -12
  57. package/modules/Tracking/events/actions/login.ts +8 -8
  58. package/modules/Tracking/events/actions/purchase.ts +42 -42
  59. package/modules/Tracking/events/actions/removeFromCart.ts +52 -52
  60. package/modules/Tracking/events/actions/search.ts +8 -8
  61. package/modules/Tracking/events/actions/selectItem.ts +64 -64
  62. package/modules/Tracking/events/actions/selectPromotion.ts +24 -24
  63. package/modules/Tracking/events/actions/shippingCalculation.ts +7 -7
  64. package/modules/Tracking/events/actions/signup.ts +8 -8
  65. package/modules/Tracking/events/actions/upsertToCart.ts +62 -62
  66. package/modules/Tracking/events/views/viewCart.ts +28 -28
  67. package/modules/Tracking/events/views/viewHome.ts +5 -5
  68. package/modules/Tracking/events/views/viewItem.ts +31 -31
  69. package/modules/Tracking/events/views/viewItemList.ts +65 -65
  70. package/modules/Tracking/events/views/viewNotFound.ts +5 -5
  71. package/modules/Tracking/events/views/viewOther.ts +5 -5
  72. package/modules/Tracking/events/views/viewPayment.ts +7 -7
  73. package/modules/Tracking/events/views/viewPromotion.ts +28 -28
  74. package/modules/Tracking/events/views/viewShipping.ts +7 -7
  75. package/modules/Tracking/index.ts +84 -84
  76. package/modules/Tracking/publicApiTracking.ts +35 -35
  77. package/modules/Tracking/types/actions/add-payment-info.interfaces.ts +12 -12
  78. package/modules/Tracking/types/actions/add-shipping-info.interfaces.ts +11 -11
  79. package/modules/Tracking/types/actions/add-to-cart.interfaces.ts +10 -10
  80. package/modules/Tracking/types/actions/begin-checkout.interfaces.ts +12 -12
  81. package/modules/Tracking/types/actions/customer-profile.interfaces.ts +19 -19
  82. package/modules/Tracking/types/actions/file-download.interfaces.ts +4 -4
  83. package/modules/Tracking/types/actions/generate-lead.interfaces.ts +12 -12
  84. package/modules/Tracking/types/actions/login.interfaces.ts +4 -4
  85. package/modules/Tracking/types/actions/purchase.interfaces.ts +18 -18
  86. package/modules/Tracking/types/actions/remove-from-cart.interfaces.ts +10 -10
  87. package/modules/Tracking/types/actions/search.interfaces.ts +4 -4
  88. package/modules/Tracking/types/actions/select-item.interfaces.ts +16 -16
  89. package/modules/Tracking/types/actions/select-promotion.interfaces.ts +8 -8
  90. package/modules/Tracking/types/actions/share.interfaces.ts +4 -4
  91. package/modules/Tracking/types/actions/shipping-calculation.interfaces.ts +3 -3
  92. package/modules/Tracking/types/actions/signup.interfaces.ts +4 -4
  93. package/modules/Tracking/types/event.types.ts +54 -54
  94. package/modules/Tracking/types/index.ts +37 -37
  95. package/modules/Tracking/types/item.interfaces.ts +30 -30
  96. package/modules/Tracking/types/views/view-cart.interfaces.ts +11 -11
  97. package/modules/Tracking/types/views/view-home.interfaces.ts +3 -3
  98. package/modules/Tracking/types/views/view-item-list.interfaces.ts +11 -11
  99. package/modules/Tracking/types/views/view-item.interfaces.ts +15 -15
  100. package/modules/Tracking/types/views/view-not-found.interfaces.ts +3 -3
  101. package/modules/Tracking/types/views/view-other.interfaces.ts +3 -3
  102. package/modules/Tracking/types/views/view-payment.interfaces.ts +3 -3
  103. package/modules/Tracking/types/views/view-promotion.interfaces.ts +8 -8
  104. package/modules/Tracking/types/views/view-shipping.interfaces.ts +3 -3
  105. package/modules/Tracking/utils/cart.ts +100 -100
  106. package/modules/Tracking/utils/pushDatalayer.ts +7 -7
  107. package/modules/index.ts +1 -1
  108. package/package.json +2 -3
  109. package/scripts/release.sh +34 -0
@@ -1,75 +1,75 @@
1
- import api from '../../Api';
2
-
3
- import { addShippingInfoAction } from '../events/actions/addShippingInfo';
4
- import { addToCartAction } from '../events/actions/addToCart';
5
- import { purchaseAction } from '../events/actions/purchase';
6
- import { removeFromCartAction } from '../events/actions/removeFromCart';
7
- import { shippingCalculationAction } from '../events/actions/shippingCalculation';
8
- import { upsertToCartAction } from '../events/actions/upsertToCart';
9
-
10
- import type { UpsertTrackingCartRequest } from '../types';
11
- import type {
12
- BuyCartRequest,
13
- CartResponse,
14
- DeleteCartRequest,
15
- SelectShipimentRequest,
16
- ShipmentQuoteCartRequest,
17
- UpsertCartRequest,
18
- } from '../../Api/types';
19
-
20
- export function listDetail() {
21
- return api.cart.listDetail().then(data => {
22
- return data;
23
- });
24
- }
25
-
26
- export function addProduct(payload: UpsertTrackingCartRequest) {
27
- return api.cart.addProduct(payload as UpsertCartRequest).then(data => {
28
- addToCartAction(payload, data);
29
- return data;
30
- });
31
- }
32
-
33
- export function upsertProduct(payload: UpsertTrackingCartRequest) {
34
- return api.cart
35
- .upsertProduct(payload as UpsertCartRequest)
36
- .then(data => {
37
- upsertToCartAction(payload, data);
38
- return data;
39
- });
40
- }
41
-
42
- export function deleteProduct(
43
- payload: DeleteCartRequest,
44
- oldCartResponse: CartResponse,
45
- ) {
46
- return api.cart.deleteProduct(payload).then(data => {
47
- removeFromCartAction(payload, data, oldCartResponse);
48
- return data;
49
- });
50
- }
51
-
52
- export function selectShipment(payload: SelectShipimentRequest) {
53
- return api.cart.selectShipment(payload).then(data => {
54
- addShippingInfoAction(data);
55
- return data;
56
- });
57
- }
58
-
59
- export function shipmentQuote(payload: ShipmentQuoteCartRequest) {
60
- return api.cart.shipmentQuote(payload).then(data => {
61
- shippingCalculationAction();
62
- return data;
63
- });
64
- }
65
-
66
- export function buy(
67
- payload: BuyCartRequest,
68
- paymentMethod: string,
69
- cartResponse: CartResponse,
70
- ) {
71
- return api.cart.buy(payload).then(data => {
72
- purchaseAction(paymentMethod, cartResponse);
73
- return data;
74
- });
75
- }
1
+ import api from '../../Api';
2
+
3
+ import { addShippingInfoAction } from '../events/actions/addShippingInfo';
4
+ import { addToCartAction } from '../events/actions/addToCart';
5
+ import { purchaseAction } from '../events/actions/purchase';
6
+ import { removeFromCartAction } from '../events/actions/removeFromCart';
7
+ import { shippingCalculationAction } from '../events/actions/shippingCalculation';
8
+ import { upsertToCartAction } from '../events/actions/upsertToCart';
9
+
10
+ import type { UpsertTrackingCartRequest } from '../types';
11
+ import type {
12
+ BuyCartRequest,
13
+ CartResponse,
14
+ DeleteCartRequest,
15
+ SelectShipimentRequest,
16
+ ShipmentQuoteCartRequest,
17
+ UpsertCartRequest,
18
+ } from '../../Api/types';
19
+
20
+ export function listDetail() {
21
+ return api.cart.listDetail().then(data => {
22
+ return data;
23
+ });
24
+ }
25
+
26
+ export function addProduct(payload: UpsertTrackingCartRequest) {
27
+ return api.cart.addProduct(payload as UpsertCartRequest).then(data => {
28
+ addToCartAction(payload, data);
29
+ return data;
30
+ });
31
+ }
32
+
33
+ export function upsertProduct(payload: UpsertTrackingCartRequest) {
34
+ return api.cart
35
+ .upsertProduct(payload as UpsertCartRequest)
36
+ .then(data => {
37
+ upsertToCartAction(payload, data);
38
+ return data;
39
+ });
40
+ }
41
+
42
+ export function deleteProduct(
43
+ payload: DeleteCartRequest,
44
+ oldCartResponse: CartResponse,
45
+ ) {
46
+ return api.cart.deleteProduct(payload).then(data => {
47
+ removeFromCartAction(payload, data, oldCartResponse);
48
+ return data;
49
+ });
50
+ }
51
+
52
+ export function selectShipment(payload: SelectShipimentRequest) {
53
+ return api.cart.selectShipment(payload).then(data => {
54
+ addShippingInfoAction(data);
55
+ return data;
56
+ });
57
+ }
58
+
59
+ export function shipmentQuote(payload: ShipmentQuoteCartRequest) {
60
+ return api.cart.shipmentQuote(payload).then(data => {
61
+ shippingCalculationAction();
62
+ return data;
63
+ });
64
+ }
65
+
66
+ export function buy(
67
+ payload: BuyCartRequest,
68
+ paymentMethod: string,
69
+ cartResponse: CartResponse,
70
+ ) {
71
+ return api.cart.buy(payload).then(data => {
72
+ purchaseAction(paymentMethod, cartResponse);
73
+ return data;
74
+ });
75
+ }
@@ -1,71 +1,71 @@
1
- import publicApi from '../../Api';
2
-
3
- import type { TrackingCustomerFields } from './types';
4
-
5
- import { customerProfileAction } from '../events/actions/customerProfile';
6
- import { generateLead } from '../events/actions/generateLead';
7
- import { loginAction } from '../events/actions/login';
8
- import { signupAction } from '../events/actions/signup';
9
-
10
- import type { CustomerLead } from '../types';
11
- import type {
12
- ApiParams,
13
- CustomerConditionFields,
14
- CustomerFields,
15
- CustomerSortFields,
16
- SigninCustomerByDocument,
17
- SigninCustomerByEmail,
18
- SignupCustomer,
19
- } from '../../Api/types';
20
-
21
- export function detail(
22
- options?: Pick<
23
- ApiParams<
24
- TrackingCustomerFields,
25
- CustomerSortFields,
26
- CustomerConditionFields
27
- >,
28
- 'condition' | 'fields' | 'order'
29
- >,
30
- ) {
31
-
32
- let fields: Array<CustomerFields> = ['addresses', 'flags'];
33
-
34
- if (options?.fields) fields = [...options.fields, ...fields];
35
-
36
- return publicApi.customer
37
- .detail({ ...options, fields })
38
- .then(data => {
39
- customerProfileAction(data);
40
-
41
- return data;
42
- });
43
- }
44
-
45
- export function signup(payload: SignupCustomer) {
46
- return publicApi.customer.signup(payload).then(data => {
47
- signupAction();
48
- return data;
49
- });
50
- }
51
-
52
- export function signinByEmail(payload: SigninCustomerByEmail) {
53
- return publicApi.customer.signinByEmail(payload).then(data => {
54
- loginAction();
55
- return data;
56
- });
57
- }
58
-
59
- export function signinByDocument(payload: SigninCustomerByDocument) {
60
- return publicApi.customer.signinByDocument(payload).then(data => {
61
- loginAction();
62
- return data;
63
- });
64
- }
65
-
66
- export function addNewsletter(payload: CustomerLead) {
67
- return publicApi.customer.addNewsletter(payload).then(data => {
68
- generateLead(payload);
69
- return data;
70
- });
71
- }
1
+ import publicApi from '../../Api';
2
+
3
+ import type { TrackingCustomerFields } from './types';
4
+
5
+ import { customerProfileAction } from '../events/actions/customerProfile';
6
+ import { generateLead } from '../events/actions/generateLead';
7
+ import { loginAction } from '../events/actions/login';
8
+ import { signupAction } from '../events/actions/signup';
9
+
10
+ import type { CustomerLead } from '../types';
11
+ import type {
12
+ ApiParams,
13
+ CustomerConditionFields,
14
+ CustomerFields,
15
+ CustomerSortFields,
16
+ SigninCustomerByDocument,
17
+ SigninCustomerByEmail,
18
+ SignupCustomer,
19
+ } from '../../Api/types';
20
+
21
+ export function detail(
22
+ options?: Pick<
23
+ ApiParams<
24
+ TrackingCustomerFields,
25
+ CustomerSortFields,
26
+ CustomerConditionFields
27
+ >,
28
+ 'condition' | 'fields' | 'order'
29
+ >,
30
+ ) {
31
+
32
+ let fields: Array<CustomerFields> = ['addresses', 'flags'];
33
+
34
+ if (options?.fields) fields = [...options.fields, ...fields];
35
+
36
+ return publicApi.customer
37
+ .detail({ ...options, fields })
38
+ .then(data => {
39
+ customerProfileAction(data);
40
+
41
+ return data;
42
+ });
43
+ }
44
+
45
+ export function signup(payload: SignupCustomer) {
46
+ return publicApi.customer.signup(payload).then(data => {
47
+ signupAction();
48
+ return data;
49
+ });
50
+ }
51
+
52
+ export function signinByEmail(payload: SigninCustomerByEmail) {
53
+ return publicApi.customer.signinByEmail(payload).then(data => {
54
+ loginAction();
55
+ return data;
56
+ });
57
+ }
58
+
59
+ export function signinByDocument(payload: SigninCustomerByDocument) {
60
+ return publicApi.customer.signinByDocument(payload).then(data => {
61
+ loginAction();
62
+ return data;
63
+ });
64
+ }
65
+
66
+ export function addNewsletter(payload: CustomerLead) {
67
+ return publicApi.customer.addNewsletter(payload).then(data => {
68
+ generateLead(payload);
69
+ return data;
70
+ });
71
+ }
@@ -1,11 +1,11 @@
1
- import type { CustomerFields, ProductFields } from '../../Api/types';
2
-
3
- export type TrackingCustomerFields = Exclude<
4
- CustomerFields,
5
- 'addresses' | 'documents'
6
- >;
7
-
8
- export type TrackingProductFields = Exclude<
9
- ProductFields,
10
- 'price' | 'variation' | 'mainCategory' | 'brand'
11
- >;
1
+ import type { CustomerFields, ProductFields } from '../../Api/types';
2
+
3
+ export type TrackingCustomerFields = Exclude<
4
+ CustomerFields,
5
+ 'addresses' | 'documents'
6
+ >;
7
+
8
+ export type TrackingProductFields = Exclude<
9
+ ProductFields,
10
+ 'price' | 'variation' | 'mainCategory' | 'brand'
11
+ >;
@@ -1,31 +1,31 @@
1
- import { getAddedCartItems, getVariant, totalValue } from '../../utils/cart';
2
- import { pushDatalayer } from '../../utils/pushDatalayer';
3
-
4
- import type { CartResponse } from '../../../Api/types';
5
-
6
- export function addPaymentInfoAction(
7
- paymentMethod: string,
8
- cartPayload: CartResponse,
9
- ) {
10
- pushDatalayer({
11
- event: 'add_payment_info',
12
- ecommerce: {
13
- currency: 'BRL',
14
- value: totalValue(cartPayload),
15
- coupon: cartPayload.discountMap.coupon?.discountMainCode || '',
16
- payment_type: paymentMethod,
17
- items: getAddedCartItems(cartPayload).map(item => {
18
- return {
19
- item_category: '',
20
- coupon: cartPayload.discountMap.coupon?.discountMainCode || '',
21
- item_brand: `${item.product.brandId}`,
22
- item_id: item.product.productId,
23
- item_name: item.product.name,
24
- item_variant: getVariant(item),
25
- price: item.unitValue,
26
- quantity: item.quantity,
27
- };
28
- }),
29
- },
30
- });
31
- }
1
+ import { getAddedCartItems, getVariant, totalValue } from '../../utils/cart';
2
+ import { pushDatalayer } from '../../utils/pushDatalayer';
3
+
4
+ import type { CartResponse } from '../../../Api/types';
5
+
6
+ export function addPaymentInfoAction(
7
+ paymentMethod: string,
8
+ cartPayload: CartResponse,
9
+ ) {
10
+ pushDatalayer({
11
+ event: 'add_payment_info',
12
+ ecommerce: {
13
+ currency: 'BRL',
14
+ value: totalValue(cartPayload),
15
+ coupon: cartPayload.discountMap.coupon?.discountMainCode || '',
16
+ payment_type: paymentMethod,
17
+ items: getAddedCartItems(cartPayload).map(item => {
18
+ return {
19
+ item_category: '',
20
+ coupon: cartPayload.discountMap.coupon?.discountMainCode || '',
21
+ item_brand: `${item.product.brandId}`,
22
+ item_id: item.product.productId,
23
+ item_name: item.product.name,
24
+ item_variant: getVariant(item),
25
+ price: item.unitValue,
26
+ quantity: item.quantity,
27
+ };
28
+ }),
29
+ },
30
+ });
31
+ }
@@ -1,27 +1,27 @@
1
- import { getAddedCartItems, getVariant, totalValue } from '../../utils/cart';
2
- import { pushDatalayer } from '../../utils/pushDatalayer';
3
-
4
- import type { CartResponse } from '../../../Api/types';
5
-
6
- export function addShippingInfoAction(cartPayload: CartResponse) {
7
- pushDatalayer({
8
- event: 'add_shipping_info',
9
- ecommerce: {
10
- currency: 'BRL',
11
- value: totalValue(cartPayload),
12
- coupon: cartPayload.discountMap.coupon?.discountMainCode || '',
13
- items: getAddedCartItems(cartPayload).map(item => {
14
- return {
15
- item_category: '',
16
- coupon: cartPayload.discountMap.coupon?.discountMainCode || '',
17
- item_brand: `${item.product.brandId}`,
18
- item_id: item.product.productId,
19
- item_name: item.product.name,
20
- item_variant: getVariant(item),
21
- price: item.unitValue,
22
- quantity: item.quantity,
23
- };
24
- }),
25
- },
26
- });
27
- }
1
+ import { getAddedCartItems, getVariant, totalValue } from '../../utils/cart';
2
+ import { pushDatalayer } from '../../utils/pushDatalayer';
3
+
4
+ import type { CartResponse } from '../../../Api/types';
5
+
6
+ export function addShippingInfoAction(cartPayload: CartResponse) {
7
+ pushDatalayer({
8
+ event: 'add_shipping_info',
9
+ ecommerce: {
10
+ currency: 'BRL',
11
+ value: totalValue(cartPayload),
12
+ coupon: cartPayload.discountMap.coupon?.discountMainCode || '',
13
+ items: getAddedCartItems(cartPayload).map(item => {
14
+ return {
15
+ item_category: '',
16
+ coupon: cartPayload.discountMap.coupon?.discountMainCode || '',
17
+ item_brand: `${item.product.brandId}`,
18
+ item_id: item.product.productId,
19
+ item_name: item.product.name,
20
+ item_variant: getVariant(item),
21
+ price: item.unitValue,
22
+ quantity: item.quantity,
23
+ };
24
+ }),
25
+ },
26
+ });
27
+ }
@@ -1,35 +1,35 @@
1
- import { getAddedCartItems, getVariant, totalValue } from '../../utils/cart';
2
- import { pushDatalayer } from '../../utils/pushDatalayer';
3
-
4
- import type { UpsertTrackingCartRequest } from '../../types';
5
- import type { CartResponse } from '../../../Api/types';
6
-
7
- export function addToCartAction(
8
- upsertPayload: UpsertTrackingCartRequest,
9
- cartPayload: CartResponse,
10
- ) {
11
- if (!getAddedCartItems(cartPayload, upsertPayload).length) return;
12
-
13
- pushDatalayer({
14
- event: 'add_to_cart',
15
- ecommerce: {
16
- currency: 'BRL',
17
- value: totalValue(cartPayload, upsertPayload),
18
- items: getAddedCartItems(cartPayload, upsertPayload).map(item => {
19
- return {
20
- item_category: '',
21
- coupon: cartPayload.discountMap.coupon?.discountMainCode || '',
22
- item_brand: `${item.product.brandId}`,
23
- item_id: item.product.productId,
24
- item_name: item.product.name,
25
- item_variant: getVariant(item),
26
- price: item.unitValue,
27
- quantity:
28
- item.quantity > item.oldQuantity!
29
- ? item.quantity - item.oldQuantity!
30
- : item.oldQuantity! - item.quantity,
31
- };
32
- }),
33
- },
34
- });
35
- }
1
+ import { getAddedCartItems, getVariant, totalValue } from '../../utils/cart';
2
+ import { pushDatalayer } from '../../utils/pushDatalayer';
3
+
4
+ import type { UpsertTrackingCartRequest } from '../../types';
5
+ import type { CartResponse } from '../../../Api/types';
6
+
7
+ export function addToCartAction(
8
+ upsertPayload: UpsertTrackingCartRequest,
9
+ cartPayload: CartResponse,
10
+ ) {
11
+ if (!getAddedCartItems(cartPayload, upsertPayload).length) return;
12
+
13
+ pushDatalayer({
14
+ event: 'add_to_cart',
15
+ ecommerce: {
16
+ currency: 'BRL',
17
+ value: totalValue(cartPayload, upsertPayload),
18
+ items: getAddedCartItems(cartPayload, upsertPayload).map(item => {
19
+ return {
20
+ item_category: '',
21
+ coupon: cartPayload.discountMap.coupon?.discountMainCode || '',
22
+ item_brand: `${item.product.brandId}`,
23
+ item_id: item.product.productId,
24
+ item_name: item.product.name,
25
+ item_variant: getVariant(item),
26
+ price: item.unitValue,
27
+ quantity:
28
+ item.quantity > item.oldQuantity!
29
+ ? item.quantity - item.oldQuantity!
30
+ : item.oldQuantity! - item.quantity,
31
+ };
32
+ }),
33
+ },
34
+ });
35
+ }
@@ -1,28 +1,28 @@
1
- import { getAddedCartItems, getVariant, totalValue } from '../../utils/cart';
2
- import { pushDatalayer } from '../../utils/pushDatalayer';
3
-
4
- import type { CartResponse } from '../../../Api/types';
5
-
6
- export function beginCheckoutAction(cartPayload: CartResponse) {
7
- pushDatalayer({
8
- event: 'begin_checkout',
9
- ecommerce: {
10
- currency: 'BRL',
11
- value: totalValue(cartPayload),
12
- shipping_tier: 'Ground',
13
- coupon: cartPayload.discountMap.coupon?.discountMainCode || '',
14
- items: getAddedCartItems(cartPayload).map(item => {
15
- return {
16
- item_category: '',
17
- coupon: cartPayload.discountMap.coupon?.discountMainCode || '',
18
- item_brand: `${item.product.brandId}`,
19
- item_id: item.product.productId,
20
- item_name: item.product.name,
21
- item_variant: getVariant(item),
22
- price: item.unitValue,
23
- quantity: item.quantity,
24
- };
25
- }),
26
- },
27
- });
28
- }
1
+ import { getAddedCartItems, getVariant, totalValue } from '../../utils/cart';
2
+ import { pushDatalayer } from '../../utils/pushDatalayer';
3
+
4
+ import type { CartResponse } from '../../../Api/types';
5
+
6
+ export function beginCheckoutAction(cartPayload: CartResponse) {
7
+ pushDatalayer({
8
+ event: 'begin_checkout',
9
+ ecommerce: {
10
+ currency: 'BRL',
11
+ value: totalValue(cartPayload),
12
+ shipping_tier: 'Ground',
13
+ coupon: cartPayload.discountMap.coupon?.discountMainCode || '',
14
+ items: getAddedCartItems(cartPayload).map(item => {
15
+ return {
16
+ item_category: '',
17
+ coupon: cartPayload.discountMap.coupon?.discountMainCode || '',
18
+ item_brand: `${item.product.brandId}`,
19
+ item_id: item.product.productId,
20
+ item_name: item.product.name,
21
+ item_variant: getVariant(item),
22
+ price: item.unitValue,
23
+ quantity: item.quantity,
24
+ };
25
+ }),
26
+ },
27
+ });
28
+ }
@@ -1,36 +1,36 @@
1
- import { pushDatalayer } from '../../utils/pushDatalayer';
2
-
3
- import type { CustomerResponse } from '../../../Api/types';
4
-
5
- export function customerProfileAction(payload?: CustomerResponse) {
6
- if (!payload) {
7
- pushDatalayer({
8
- event: 'customer_profile',
9
- customer: {
10
- id: 0,
11
- birthdate: '',
12
- email: '',
13
- name: 'Visitante',
14
- gender: 'undefined',
15
- flags: null,
16
- address: null,
17
- loginStatus: false,
18
- },
19
- });
20
- return;
21
- }
22
-
23
- pushDatalayer({
24
- event: 'customer_profile',
25
- customer: {
26
- id: payload.id,
27
- birthdate: payload.birthdate,
28
- email: payload.email,
29
- name: payload.nameCorporateName,
30
- gender: payload.gender,
31
- flags: payload.flags,
32
- address: payload.addresses,
33
- loginStatus: true,
34
- },
35
- });
36
- }
1
+ import { pushDatalayer } from '../../utils/pushDatalayer';
2
+
3
+ import type { CustomerResponse } from '../../../Api/types';
4
+
5
+ export function customerProfileAction(payload?: CustomerResponse) {
6
+ if (!payload) {
7
+ pushDatalayer({
8
+ event: 'customer_profile',
9
+ customer: {
10
+ id: 0,
11
+ birthdate: '',
12
+ email: '',
13
+ name: 'Visitante',
14
+ gender: 'undefined',
15
+ flags: null,
16
+ address: null,
17
+ loginStatus: false,
18
+ },
19
+ });
20
+ return;
21
+ }
22
+
23
+ pushDatalayer({
24
+ event: 'customer_profile',
25
+ customer: {
26
+ id: payload.id,
27
+ birthdate: payload.birthdate,
28
+ email: payload.email,
29
+ name: payload.nameCorporateName,
30
+ gender: payload.gender,
31
+ flags: payload.flags,
32
+ address: payload.addresses,
33
+ loginStatus: true,
34
+ },
35
+ });
36
+ }
@@ -1,12 +1,12 @@
1
- import { pushDatalayer } from '../../utils/pushDatalayer';
2
-
3
- import type { CustomerLead } from '../../types';
4
-
5
- export function generateLead(customer: CustomerLead) {
6
- pushDatalayer({
7
- event: 'generate_lead',
8
- name: customer.name,
9
- email: customer.email,
10
- phone: customer.phone,
11
- });
12
- }
1
+ import { pushDatalayer } from '../../utils/pushDatalayer';
2
+
3
+ import type { CustomerLead } from '../../types';
4
+
5
+ export function generateLead(customer: CustomerLead) {
6
+ pushDatalayer({
7
+ event: 'generate_lead',
8
+ name: customer.name,
9
+ email: customer.email,
10
+ phone: customer.phone,
11
+ });
12
+ }