@redneckz/wildless-cms-uni-blocks 0.16.6-credit → 0.16.7-credit

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 (122) hide show
  1. package/bundle/bundle.umd.js +36 -26
  2. package/bundle/bundle.umd.min.js +1 -1
  3. package/bundle/components/ApplicationLeadForm/getLeadFormTaskData.d.ts +3 -1
  4. package/bundle/components/ApplicationLeadForm/useLeadFormStore.d.ts +3 -0
  5. package/bundle/retail/api/saveReferalInfo.d.ts +2 -4
  6. package/bundle/retail/hooks/useRetailFormStore.d.ts +1 -0
  7. package/bundle/retail/model/LeadFormState.d.ts +0 -3
  8. package/bundle/retail/model/ReferalData.d.ts +6 -0
  9. package/bundle/utils/getSessionQuery.d.ts +1 -0
  10. package/dist/components/ApplicationLeadForm/getInitialFormState.js +0 -3
  11. package/dist/components/ApplicationLeadForm/getInitialFormState.js.map +1 -1
  12. package/dist/components/ApplicationLeadForm/getLeadFormTaskData.d.ts +3 -1
  13. package/dist/components/ApplicationLeadForm/getLeadFormTaskData.js +2 -2
  14. package/dist/components/ApplicationLeadForm/getLeadFormTaskData.js.map +1 -1
  15. package/dist/components/ApplicationLeadForm/useApplicationLeadApi.js +8 -7
  16. package/dist/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  17. package/dist/components/ApplicationLeadForm/useInitApplicationLead.js +28 -14
  18. package/dist/components/ApplicationLeadForm/useInitApplicationLead.js.map +1 -1
  19. package/dist/components/ApplicationLeadForm/useLeadFormStore.d.ts +3 -0
  20. package/dist/components/ApplicationLeadForm/useLeadFormStore.js.map +1 -1
  21. package/dist/retail/api/saveReferalInfo.d.ts +2 -4
  22. package/dist/retail/api/saveReferalInfo.js.map +1 -1
  23. package/dist/retail/hooks/useRetailFormStore.d.ts +1 -0
  24. package/dist/retail/model/LeadFormState.d.ts +0 -3
  25. package/dist/retail/model/ReferalData.d.ts +6 -0
  26. package/dist/retail/model/ReferalData.js +2 -0
  27. package/dist/retail/model/ReferalData.js.map +1 -0
  28. package/dist/utils/getSessionQuery.d.ts +1 -0
  29. package/dist/utils/getSessionQuery.js +4 -4
  30. package/dist/utils/getSessionQuery.js.map +1 -1
  31. package/lib/components/ApplicationLeadForm/getInitialFormState.js +0 -3
  32. package/lib/components/ApplicationLeadForm/getInitialFormState.js.map +1 -1
  33. package/lib/components/ApplicationLeadForm/getLeadFormTaskData.d.ts +3 -1
  34. package/lib/components/ApplicationLeadForm/getLeadFormTaskData.js +2 -2
  35. package/lib/components/ApplicationLeadForm/getLeadFormTaskData.js.map +1 -1
  36. package/lib/components/ApplicationLeadForm/useApplicationLeadApi.js +8 -7
  37. package/lib/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  38. package/lib/components/ApplicationLeadForm/useInitApplicationLead.js +28 -14
  39. package/lib/components/ApplicationLeadForm/useInitApplicationLead.js.map +1 -1
  40. package/lib/components/ApplicationLeadForm/useLeadFormStore.d.ts +3 -0
  41. package/lib/components/ApplicationLeadForm/useLeadFormStore.js.map +1 -1
  42. package/lib/components/OfficesAtmsMap/OfficesAtmsMapLayout.d.ts +1 -1
  43. package/lib/retail/api/saveReferalInfo.d.ts +2 -4
  44. package/lib/retail/api/saveReferalInfo.js.map +1 -1
  45. package/lib/retail/hooks/useRetailFormStore.d.ts +1 -0
  46. package/lib/retail/model/LeadFormState.d.ts +0 -3
  47. package/lib/retail/model/ReferalData.d.ts +6 -0
  48. package/lib/retail/model/ReferalData.js +2 -0
  49. package/lib/retail/model/ReferalData.js.map +1 -0
  50. package/lib/utils/getSessionQuery.d.ts +1 -0
  51. package/lib/utils/getSessionQuery.js +1 -1
  52. package/lib/utils/getSessionQuery.js.map +1 -1
  53. package/mobile/bundle/bundle.umd.js +36 -26
  54. package/mobile/bundle/bundle.umd.min.js +1 -1
  55. package/mobile/bundle/components/ApplicationLeadForm/getLeadFormTaskData.d.ts +3 -1
  56. package/mobile/bundle/components/ApplicationLeadForm/useLeadFormStore.d.ts +3 -0
  57. package/mobile/bundle/retail/api/saveReferalInfo.d.ts +2 -4
  58. package/mobile/bundle/retail/hooks/useRetailFormStore.d.ts +1 -0
  59. package/mobile/bundle/retail/model/LeadFormState.d.ts +0 -3
  60. package/mobile/bundle/retail/model/ReferalData.d.ts +6 -0
  61. package/mobile/bundle/utils/getSessionQuery.d.ts +1 -0
  62. package/mobile/dist/components/ApplicationLeadForm/getInitialFormState.js +0 -3
  63. package/mobile/dist/components/ApplicationLeadForm/getInitialFormState.js.map +1 -1
  64. package/mobile/dist/components/ApplicationLeadForm/getLeadFormTaskData.d.ts +3 -1
  65. package/mobile/dist/components/ApplicationLeadForm/getLeadFormTaskData.js +2 -2
  66. package/mobile/dist/components/ApplicationLeadForm/getLeadFormTaskData.js.map +1 -1
  67. package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.js +8 -7
  68. package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  69. package/mobile/dist/components/ApplicationLeadForm/useInitApplicationLead.js +28 -14
  70. package/mobile/dist/components/ApplicationLeadForm/useInitApplicationLead.js.map +1 -1
  71. package/mobile/dist/components/ApplicationLeadForm/useLeadFormStore.d.ts +3 -0
  72. package/mobile/dist/components/ApplicationLeadForm/useLeadFormStore.js.map +1 -1
  73. package/mobile/dist/retail/api/saveReferalInfo.d.ts +2 -4
  74. package/mobile/dist/retail/api/saveReferalInfo.js.map +1 -1
  75. package/mobile/dist/retail/hooks/useRetailFormStore.d.ts +1 -0
  76. package/mobile/dist/retail/model/LeadFormState.d.ts +0 -3
  77. package/mobile/dist/retail/model/ReferalData.d.ts +6 -0
  78. package/mobile/dist/retail/model/ReferalData.js +2 -0
  79. package/mobile/dist/retail/model/ReferalData.js.map +1 -0
  80. package/mobile/dist/utils/getSessionQuery.d.ts +1 -0
  81. package/mobile/dist/utils/getSessionQuery.js +4 -4
  82. package/mobile/dist/utils/getSessionQuery.js.map +1 -1
  83. package/mobile/lib/components/ApplicationLeadForm/getInitialFormState.js +0 -3
  84. package/mobile/lib/components/ApplicationLeadForm/getInitialFormState.js.map +1 -1
  85. package/mobile/lib/components/ApplicationLeadForm/getLeadFormTaskData.d.ts +3 -1
  86. package/mobile/lib/components/ApplicationLeadForm/getLeadFormTaskData.js +2 -2
  87. package/mobile/lib/components/ApplicationLeadForm/getLeadFormTaskData.js.map +1 -1
  88. package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.js +8 -7
  89. package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  90. package/mobile/lib/components/ApplicationLeadForm/useInitApplicationLead.js +28 -14
  91. package/mobile/lib/components/ApplicationLeadForm/useInitApplicationLead.js.map +1 -1
  92. package/mobile/lib/components/ApplicationLeadForm/useLeadFormStore.d.ts +3 -0
  93. package/mobile/lib/components/ApplicationLeadForm/useLeadFormStore.js.map +1 -1
  94. package/mobile/lib/retail/api/saveReferalInfo.d.ts +2 -4
  95. package/mobile/lib/retail/api/saveReferalInfo.js.map +1 -1
  96. package/mobile/lib/retail/hooks/useRetailFormStore.d.ts +1 -0
  97. package/mobile/lib/retail/model/LeadFormState.d.ts +0 -3
  98. package/mobile/lib/retail/model/ReferalData.d.ts +6 -0
  99. package/mobile/lib/retail/model/ReferalData.js +2 -0
  100. package/mobile/lib/retail/model/ReferalData.js.map +1 -0
  101. package/mobile/lib/utils/getSessionQuery.d.ts +1 -0
  102. package/mobile/lib/utils/getSessionQuery.js +1 -1
  103. package/mobile/lib/utils/getSessionQuery.js.map +1 -1
  104. package/mobile/src/components/ApplicationLeadForm/getInitialFormState.tsx +0 -3
  105. package/mobile/src/components/ApplicationLeadForm/getLeadFormTaskData.ts +4 -1
  106. package/mobile/src/components/ApplicationLeadForm/useApplicationLeadApi.tsx +11 -6
  107. package/mobile/src/components/ApplicationLeadForm/useInitApplicationLead.ts +35 -15
  108. package/mobile/src/components/ApplicationLeadForm/useLeadFormStore.ts +2 -0
  109. package/mobile/src/retail/api/saveReferalInfo.ts +2 -4
  110. package/mobile/src/retail/model/LeadFormState.ts +0 -3
  111. package/mobile/src/retail/model/ReferalData.ts +7 -0
  112. package/mobile/src/utils/getSessionQuery.ts +1 -1
  113. package/package.json +1 -1
  114. package/src/components/ApplicationLeadForm/getInitialFormState.tsx +0 -3
  115. package/src/components/ApplicationLeadForm/getLeadFormTaskData.ts +4 -1
  116. package/src/components/ApplicationLeadForm/useApplicationLeadApi.tsx +11 -6
  117. package/src/components/ApplicationLeadForm/useInitApplicationLead.ts +35 -15
  118. package/src/components/ApplicationLeadForm/useLeadFormStore.ts +2 -0
  119. package/src/retail/api/saveReferalInfo.ts +2 -4
  120. package/src/retail/model/LeadFormState.ts +0 -3
  121. package/src/retail/model/ReferalData.ts +7 -0
  122. package/src/utils/getSessionQuery.ts +1 -1
@@ -1,6 +1,8 @@
1
+ /* eslint-disable max-lines-per-function */
1
2
  import { useCallback, useEffect, useMemo } from '@redneckz/uni-jsx/lib/hooks';
2
3
  import { useSetter } from '../../hooks/useSetter.js';
3
4
  import { esiaRequestProfile } from '../../retail/api/esiaRequestProfile.js';
5
+ import { QUERY_STORAGE_KEY } from '../../utils/getSessionQuery.js';
4
6
  import { EsiaStatuses } from './ApplicationLeadFormContent.js';
5
7
  import { getInitialFormState } from './getInitialFormState.js';
6
8
  import { parseEsiaProfile } from './parseEsiaProfile.js';
@@ -31,25 +33,22 @@ export const useInitApplicationLead = ({ inputs, productType, setEsiaStatus, esi
31
33
  setEsiaStatus(EsiaStatuses.Error);
32
34
  }
33
35
  }, []);
34
- const saveReferalData = useCallback((referalData) => {
35
- saveForm((_) => ({
36
- ..._,
37
- ...referalData,
38
- }));
39
- }, []);
40
36
  useEffect(() => {
41
37
  leadFormStore.productType = productType;
42
- const params = new URLSearchParams(decodeURIComponent(globalThis.location?.search));
43
- const code = params.get('code');
44
- const state = params.get('state');
45
- const referalCode = params.get('referalCode');
38
+ const { code, state, referalCode, refererCode, productId } = getLeadQueryParams(leadFormStore.referalData);
46
39
  if (referalCode) {
47
- const referalData = {
48
- refererCode: params.get('refererCode'),
40
+ leadFormStore.referalData = {
41
+ refererCode,
49
42
  referalCode,
50
- productId: params.get('productId'),
43
+ productId,
44
+ };
45
+ }
46
+ else if (!code) {
47
+ leadFormStore.referalData = {
48
+ refererCode: null,
49
+ referalCode: null,
50
+ productId: null,
51
51
  };
52
- saveReferalData(referalData);
53
52
  }
54
53
  if (code && state) {
55
54
  requestEsiaProfile(code, state);
@@ -61,4 +60,19 @@ export const useInitApplicationLead = ({ inputs, productType, setEsiaStatus, esi
61
60
  }, []);
62
61
  return initialFormState;
63
62
  };
63
+ const getLeadQueryParams = (referalData) => {
64
+ const queryStorage = new URLSearchParams(decodeURIComponent(globalThis.sessionStorage?.getItem(QUERY_STORAGE_KEY) || ''));
65
+ const code = queryStorage.get('code');
66
+ const state = queryStorage.get('state');
67
+ const referalCode = code ? referalData?.referalCode : queryStorage.get('referalCode');
68
+ const refererCode = code ? referalData?.refererCode : queryStorage.get('refererCode');
69
+ const productId = code ? referalData?.productId : queryStorage.get('productId');
70
+ return {
71
+ code,
72
+ state,
73
+ referalCode,
74
+ refererCode,
75
+ productId,
76
+ };
77
+ };
64
78
  //# sourceMappingURL=useInitApplicationLead.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useInitApplicationLead.js","sourceRoot":"","sources":["../../../src/components/ApplicationLeadForm/useInitApplicationLead.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAGzE,OAAO,EAAE,YAAY,EAAoB,MAAM,8BAA8B,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAA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AE,CAAC,CAAC;YACf,GAAG,CAAC;YACJ,GAAG,WAAW;SACf,CAAC,CAAC,CAAC;IACN,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,SAAS,CAAC,GAAG,EAAE;QACb,aAAa,CAAC,WAAW,GAAG,WAAW,CAAC;QAExC,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,kBAAkB,CAAC,UAAU,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;QACpF,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAChC,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAClC,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QAE9C,IAAI,WAAW,EAAE;YACf,MAAM,WAAW,GAAG;gBAClB,WAAW,EAAE,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC;gBACtC,WAAW;gBACX,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC;aACnC,CAAC;YACF,eAAe,CAAC,WAAW,CAAC,CAAC;SAC9B;QAED,IAAI,IAAI,IAAI,KAAK,EAAE;YACjB,kBAAkB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;SACjC;aAAM;YACL,cAAc,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;YACzC,cAAc,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;SAC3C;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,gBAAgB,CAAC;AAC1B,CAAC,CAAC"}
1
+ {"version":3,"file":"useInitApplicationLead.js","sourceRoot":"","sources":["../../../src/components/ApplicationLeadForm/useInitApplicationLead.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;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AAC,OAAO,CAAC,CAAC;IACxC,MAAM,WAAW,GAAG,IAAI,CAAC,CAAC,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IACtF,MAAM,WAAW,GAAG,IAAI,CAAC,CAAC,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IACtF,MAAM,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAEhF,OAAO;QACL,IAAI;QACJ,KAAK;QACL,WAAW;QACX,WAAW;QACX,SAAS;KACV,CAAC;AACJ,CAAC,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { type LeadFormState } from '../../retail/model/LeadFormState';
2
+ import { type ReferalData } from '../../retail/model/ReferalData';
2
3
  import { type ProductType } from './ApplicationLeadFormContent';
3
4
  export interface LeadFormStoreSlice {
4
5
  leadForm: LeadFormState;
@@ -7,6 +8,7 @@ export interface LeadFormStoreSlice {
7
8
  participantId: number;
8
9
  programId: string;
9
10
  productType: ProductType;
11
+ referalData: ReferalData;
10
12
  }
11
13
  export declare const useLeadFormStore: () => {
12
14
  leadForm: LeadFormState | null;
@@ -15,4 +17,5 @@ export declare const useLeadFormStore: () => {
15
17
  participantId: number | null;
16
18
  programId: string | null;
17
19
  productType: ProductType | null;
20
+ referalData: ReferalData | null;
18
21
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useLeadFormStore.js","sourceRoot":"","sources":["../../../src/components/ApplicationLeadForm/useLeadFormStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAa1E,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,EAAE,CAAC,aAAa,EAAsB,CAAC"}
1
+ {"version":3,"file":"useLeadFormStore.js","sourceRoot":"","sources":["../../../src/components/ApplicationLeadForm/useLeadFormStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAe1E,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,EAAE,CAAC,aAAa,EAAsB,CAAC"}
@@ -1,7 +1,5 @@
1
- export declare type SaveReferalInfo = {
1
+ import { type ReferalData } from '../model/ReferalData';
2
+ export declare type SaveReferalInfo = ReferalData & {
2
3
  taskId: number;
3
- refererCode?: string;
4
- referalCode?: string;
5
- productId?: string;
6
4
  };
7
5
  export declare const saveReferalInfo: (body: SaveReferalInfo) => Promise<Response>;
@@ -1 +1 @@
1
- {"version":3,"file":"saveReferalInfo.js","sourceRoot":"","sources":["../../../src/retail/api/saveReferalInfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AASxC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAqB,EAAE,EAAE,CACvD,SAAS,CAAC,0BAA0B,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC"}
1
+ {"version":3,"file":"saveReferalInfo.js","sourceRoot":"","sources":["../../../src/retail/api/saveReferalInfo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAMxC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAqB,EAAE,EAAE,CACvD,SAAS,CAAC,0BAA0B,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC"}
@@ -36,4 +36,5 @@ export declare const useRetailFormStore: () => {
36
36
  participantId: number | null;
37
37
  programId: string | null;
38
38
  productType: import("../../components/ApplicationLeadForm/ApplicationLeadFormContent").ProductType | null;
39
+ referalData: import("../model/ReferalData").ReferalData | null;
39
40
  };
@@ -179,7 +179,4 @@ export interface LeadFormState extends FormRetailConsents, FormStateDeliveryType
179
179
  regionHasDelivery?: boolean;
180
180
  files?: File[];
181
181
  deliveryTime?: string;
182
- refererCode?: string;
183
- referalCode?: string;
184
- productId?: string;
185
182
  }
@@ -0,0 +1,6 @@
1
+ import { type Nullable } from '../../utils/Nullable';
2
+ export declare type ReferalData = {
3
+ refererCode?: Nullable<string>;
4
+ referalCode?: Nullable<string>;
5
+ productId?: Nullable<string>;
6
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ReferalData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReferalData.js","sourceRoot":"","sources":["../../../src/retail/model/ReferalData.ts"],"names":[],"mappings":""}
@@ -1 +1,2 @@
1
+ export declare const QUERY_STORAGE_KEY = "rshb-query-params";
1
2
  export declare function saveSessionQuery(): string;
@@ -1,4 +1,4 @@
1
- const QUERY_STORAGE_KEY = 'rshb-query-params';
1
+ export const QUERY_STORAGE_KEY = 'rshb-query-params';
2
2
  export function saveSessionQuery() {
3
3
  const result = globalThis.location?.search || globalThis.sessionStorage?.getItem(QUERY_STORAGE_KEY) || '';
4
4
  if (result) {
@@ -1 +1 @@
1
- {"version":3,"file":"getSessionQuery.js","sourceRoot":"","sources":["../../src/utils/getSessionQuery.ts"],"names":[],"mappings":"AAAA,MAAM,iBAAiB,GAAG,mBAAmB,CAAC;AAE9C,MAAM,UAAU,gBAAgB;IAC9B,MAAM,MAAM,GACV,UAAU,CAAC,QAAQ,EAAE,MAAM,IAAI,UAAU,CAAC,cAAc,EAAE,OAAO,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC;IAE7F,IAAI,MAAM,EAAE;QACV,UAAU,CAAC,cAAc,EAAE,OAAO,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;KAC/D;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
1
+ {"version":3,"file":"getSessionQuery.js","sourceRoot":"","sources":["../../src/utils/getSessionQuery.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAAG,mBAAmB,CAAC;AAErD,MAAM,UAAU,gBAAgB;IAC9B,MAAM,MAAM,GACV,UAAU,CAAC,QAAQ,EAAE,MAAM,IAAI,UAAU,CAAC,cAAc,EAAE,OAAO,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC;IAE7F,IAAI,MAAM,EAAE;QACV,UAAU,CAAC,cAAc,EAAE,OAAO,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;KAC/D;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -16,9 +16,6 @@ const initialFormState = {
16
16
  consentInformMaterialsFlg: false,
17
17
  consentPhotoFlg: false,
18
18
  consentFATCA: false,
19
- refererCode: '',
20
- referalCode: '',
21
- productId: '',
22
19
  };
23
20
 
24
21
  export const getInitialFormState = (
@@ -4,6 +4,7 @@ import { getParticipantContacts } from '../../retail/adaptors/utils';
4
4
  import { type CreateUserTaskDebitBody } from '../../retail/api/createUserTaskDebit';
5
5
  import { type MarketingInfo, type UpdateUserTaskBody } from '../../retail/api/updateUserTask';
6
6
  import { type LeadFormState } from '../../retail/model/LeadFormState';
7
+ import { type ReferalData } from '../../retail/model/ReferalData';
7
8
  import { formatDate } from '../../utils/formatDate';
8
9
  import { formatPhone } from '../../utils/formatPhone';
9
10
  import { debitProgrammIdToCardCodesMap } from '../DebitForm/utils';
@@ -13,6 +14,7 @@ type getLeadFormTaskDataProps = {
13
14
  taskId: number;
14
15
  profileId: number;
15
16
  formData: LeadFormState;
17
+ referalCode?: ReferalData['refererCode'];
16
18
  };
17
19
 
18
20
  export const getCreditLeadFormTaskData = ({
@@ -20,8 +22,9 @@ export const getCreditLeadFormTaskData = ({
20
22
  taskId,
21
23
  profileId,
22
24
  formData,
25
+ referalCode,
23
26
  }: getLeadFormTaskDataProps): UpdateUserTaskBody => {
24
- const { name, surname, middleName, limitedBirthday, phone, email, referalCode } = formData;
27
+ const { name, surname, middleName, limitedBirthday, phone, email } = formData;
25
28
  const navigator = locationNavigator();
26
29
  const taskSource = referalCode ? 'ReferalSF' : navigator.origin;
27
30
 
@@ -15,12 +15,14 @@ import { useConsentBkiDialog } from '../../retail/components/ConsentBkiDialog/us
15
15
  import { useDraftDialog } from '../../retail/components/DraftDialog/useDraftDialog';
16
16
  import { VerifyPhoneDialog } from '../../retail/components/VerifyPhoneDialog/VerifyPhoneDialog';
17
17
  import { type FormRetailConsents, type LeadFormState } from '../../retail/model/LeadFormState';
18
+ import { type ReferalData } from '../../retail/model/ReferalData';
18
19
  import { getUpdateUserProfileData } from '../../retail/utils/getUpdateUserProfile';
19
20
  import { useDialog } from '../../ui-kit/DialogManager/useDialog';
20
21
  import { formatPhone } from '../../utils/formatPhone';
21
22
  import { type ProductType } from './ApplicationLeadFormContent';
22
23
  import { productTypeToConsentsMap } from './consents';
23
24
  import { getCreditLeadFormTaskData, getDebitLeadFormTaskData } from './getLeadFormTaskData';
25
+ import { useLeadFormStore } from './useLeadFormStore';
24
26
  import { useSaveUserData, type UserData } from './useSaveUserData';
25
27
  import { useSendLeadFormAspects } from './useSendLeadFormAspects';
26
28
 
@@ -40,6 +42,8 @@ export const useApplicationLeadApi = ({
40
42
  const [isSending, { setTrue: startSending, setFalse: endSending }] = useBool(false);
41
43
  const [ok, setOK] = useState<boolean | undefined>();
42
44
  const saveUserData = useSaveUserData();
45
+ const leadFormStore = useLeadFormStore();
46
+
43
47
  const sendAspects = useSendLeadFormAspects({ data });
44
48
  const navigator = locationNavigator();
45
49
 
@@ -58,6 +62,7 @@ export const useApplicationLeadApi = ({
58
62
  const profileId = await createUserProfile({
59
63
  profile: { phone: formatPhone(transformedFormData.phone as string) },
60
64
  });
65
+ const referalData = leadFormStore.referalData;
61
66
 
62
67
  if (!profileId) {
63
68
  throw new Error();
@@ -69,6 +74,7 @@ export const useApplicationLeadApi = ({
69
74
  profileId,
70
75
  formData: transformedFormData,
71
76
  productType,
77
+ referalData,
72
78
  saveUserData,
73
79
  sendAspects,
74
80
  });
@@ -130,6 +136,7 @@ const updateUserData = async ({
130
136
  profileId,
131
137
  formData,
132
138
  productType,
139
+ referalData,
133
140
  saveUserData,
134
141
  sendAspects,
135
142
  }: {
@@ -137,15 +144,14 @@ const updateUserData = async ({
137
144
  profileId: number;
138
145
  formData: LeadFormState;
139
146
  productType: ProductType;
147
+ referalData: ReferalData | null;
140
148
  saveUserData: (userData: UserData) => void;
141
149
  sendAspects: (profileId: number, taskId: number) => void;
142
150
  }) => {
143
151
  let taskId: number;
144
152
  let participantId: number;
145
- const refererCode = formData.refererCode;
146
- const referalCode = formData.referalCode;
147
- const productId = formData.productId;
148
153
  const transformedConsents = transformConsentsFields(formData, productType);
154
+ const referalCode = referalData?.referalCode;
149
155
 
150
156
  await updateUserProfile(getUpdateUserProfileData(profileId, formData, transformedConsents));
151
157
 
@@ -169,14 +175,13 @@ const updateUserData = async ({
169
175
  taskId,
170
176
  profileId,
171
177
  formData,
178
+ referalCode,
172
179
  }),
173
180
  );
174
181
  if (referalCode) {
175
182
  await saveReferalInfo({
176
183
  taskId,
177
- refererCode,
178
- referalCode,
179
- productId,
184
+ ...referalData,
180
185
  });
181
186
  }
182
187
  }
@@ -1,8 +1,11 @@
1
+ /* eslint-disable max-lines-per-function */
1
2
  import { useCallback, useEffect, useMemo } from '@redneckz/uni-jsx/lib/hooks';
2
3
  import { useSetter } from '../../hooks/useSetter';
3
4
  import { esiaRequestProfile } from '../../retail/api/esiaRequestProfile';
4
5
  import { type LeadFormState } from '../../retail/model/LeadFormState';
6
+ import { type ReferalData } from '../../retail/model/ReferalData';
5
7
  import { type FieldRetailDef } from '../../retail/model/RetailFormContent';
8
+ import { QUERY_STORAGE_KEY } from '../../utils/getSessionQuery';
6
9
  import { EsiaStatuses, type ProductType } from './ApplicationLeadFormContent';
7
10
  import { getInitialFormState } from './getInitialFormState';
8
11
  import { parseEsiaProfile } from './parseEsiaProfile';
@@ -54,28 +57,25 @@ export const useInitApplicationLead = ({
54
57
  }
55
58
  }, []);
56
59
 
57
- const saveReferalData = useCallback((referalData: Record<string, string | null>) => {
58
- saveForm((_) => ({
59
- ..._,
60
- ...referalData,
61
- }));
62
- }, []);
63
-
64
60
  useEffect(() => {
65
61
  leadFormStore.productType = productType;
66
62
 
67
- const params = new URLSearchParams(decodeURIComponent(globalThis.location?.search));
68
- const code = params.get('code');
69
- const state = params.get('state');
70
- const referalCode = params.get('referalCode');
63
+ const { code, state, referalCode, refererCode, productId } = getLeadQueryParams(
64
+ leadFormStore.referalData,
65
+ );
71
66
 
72
67
  if (referalCode) {
73
- const referalData = {
74
- refererCode: params.get('refererCode'),
68
+ leadFormStore.referalData = {
69
+ refererCode,
75
70
  referalCode,
76
- productId: params.get('productId'),
71
+ productId,
72
+ };
73
+ } else if (!code) {
74
+ leadFormStore.referalData = {
75
+ refererCode: null,
76
+ referalCode: null,
77
+ productId: null,
77
78
  };
78
- saveReferalData(referalData);
79
79
  }
80
80
 
81
81
  if (code && state) {
@@ -88,3 +88,23 @@ export const useInitApplicationLead = ({
88
88
 
89
89
  return initialFormState;
90
90
  };
91
+
92
+ const getLeadQueryParams = (referalData: ReferalData | null) => {
93
+ const queryStorage = new URLSearchParams(
94
+ decodeURIComponent(globalThis.sessionStorage?.getItem(QUERY_STORAGE_KEY) || ''),
95
+ );
96
+
97
+ const code = queryStorage.get('code');
98
+ const state = queryStorage.get('state');
99
+ const referalCode = code ? referalData?.referalCode : queryStorage.get('referalCode');
100
+ const refererCode = code ? referalData?.refererCode : queryStorage.get('refererCode');
101
+ const productId = code ? referalData?.productId : queryStorage.get('productId');
102
+
103
+ return {
104
+ code,
105
+ state,
106
+ referalCode,
107
+ refererCode,
108
+ productId,
109
+ };
110
+ };
@@ -1,5 +1,6 @@
1
1
  import { useLocalStore } from '@redneckz/uni-jsx/lib/Store/useLocalStore';
2
2
  import { type LeadFormState } from '../../retail/model/LeadFormState';
3
+ import { type ReferalData } from '../../retail/model/ReferalData';
3
4
  import { type ProductType } from './ApplicationLeadFormContent';
4
5
 
5
6
  export interface LeadFormStoreSlice {
@@ -9,6 +10,7 @@ export interface LeadFormStoreSlice {
9
10
  participantId: number;
10
11
  programId: string;
11
12
  productType: ProductType;
13
+ referalData: ReferalData;
12
14
  }
13
15
 
14
16
  export const useLeadFormStore = () => useLocalStore<LeadFormStoreSlice>();
@@ -1,10 +1,8 @@
1
+ import { type ReferalData } from '../model/ReferalData';
1
2
  import { doRequest } from './doRequest';
2
3
 
3
- export type SaveReferalInfo = {
4
+ export type SaveReferalInfo = ReferalData & {
4
5
  taskId: number;
5
- refererCode?: string;
6
- referalCode?: string;
7
- productId?: string;
8
6
  };
9
7
 
10
8
  export const saveReferalInfo = (body: SaveReferalInfo) =>
@@ -193,7 +193,4 @@ export interface LeadFormState extends FormRetailConsents, FormStateDeliveryType
193
193
  regionHasDelivery?: boolean;
194
194
  files?: File[];
195
195
  deliveryTime?: string;
196
- refererCode?: string;
197
- referalCode?: string;
198
- productId?: string;
199
196
  }
@@ -0,0 +1,7 @@
1
+ import { type Nullable } from '../../utils/Nullable';
2
+
3
+ export type ReferalData = {
4
+ refererCode?: Nullable<string>;
5
+ referalCode?: Nullable<string>;
6
+ productId?: Nullable<string>;
7
+ };
@@ -1,4 +1,4 @@
1
- const QUERY_STORAGE_KEY = 'rshb-query-params';
1
+ export const QUERY_STORAGE_KEY = 'rshb-query-params';
2
2
 
3
3
  export function saveSessionQuery() {
4
4
  const result =
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redneckz/wildless-cms-uni-blocks",
3
- "version": "0.16.6-credit",
3
+ "version": "0.16.7-credit",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "ЦК",
@@ -16,9 +16,6 @@ const initialFormState = {
16
16
  consentInformMaterialsFlg: false,
17
17
  consentPhotoFlg: false,
18
18
  consentFATCA: false,
19
- refererCode: '',
20
- referalCode: '',
21
- productId: '',
22
19
  };
23
20
 
24
21
  export const getInitialFormState = (
@@ -4,6 +4,7 @@ import { getParticipantContacts } from '../../retail/adaptors/utils';
4
4
  import { type CreateUserTaskDebitBody } from '../../retail/api/createUserTaskDebit';
5
5
  import { type MarketingInfo, type UpdateUserTaskBody } from '../../retail/api/updateUserTask';
6
6
  import { type LeadFormState } from '../../retail/model/LeadFormState';
7
+ import { type ReferalData } from '../../retail/model/ReferalData';
7
8
  import { formatDate } from '../../utils/formatDate';
8
9
  import { formatPhone } from '../../utils/formatPhone';
9
10
  import { debitProgrammIdToCardCodesMap } from '../DebitForm/utils';
@@ -13,6 +14,7 @@ type getLeadFormTaskDataProps = {
13
14
  taskId: number;
14
15
  profileId: number;
15
16
  formData: LeadFormState;
17
+ referalCode?: ReferalData['refererCode'];
16
18
  };
17
19
 
18
20
  export const getCreditLeadFormTaskData = ({
@@ -20,8 +22,9 @@ export const getCreditLeadFormTaskData = ({
20
22
  taskId,
21
23
  profileId,
22
24
  formData,
25
+ referalCode,
23
26
  }: getLeadFormTaskDataProps): UpdateUserTaskBody => {
24
- const { name, surname, middleName, limitedBirthday, phone, email, referalCode } = formData;
27
+ const { name, surname, middleName, limitedBirthday, phone, email } = formData;
25
28
  const navigator = locationNavigator();
26
29
  const taskSource = referalCode ? 'ReferalSF' : navigator.origin;
27
30
 
@@ -15,12 +15,14 @@ import { useConsentBkiDialog } from '../../retail/components/ConsentBkiDialog/us
15
15
  import { useDraftDialog } from '../../retail/components/DraftDialog/useDraftDialog';
16
16
  import { VerifyPhoneDialog } from '../../retail/components/VerifyPhoneDialog/VerifyPhoneDialog';
17
17
  import { type FormRetailConsents, type LeadFormState } from '../../retail/model/LeadFormState';
18
+ import { type ReferalData } from '../../retail/model/ReferalData';
18
19
  import { getUpdateUserProfileData } from '../../retail/utils/getUpdateUserProfile';
19
20
  import { useDialog } from '../../ui-kit/DialogManager/useDialog';
20
21
  import { formatPhone } from '../../utils/formatPhone';
21
22
  import { type ProductType } from './ApplicationLeadFormContent';
22
23
  import { productTypeToConsentsMap } from './consents';
23
24
  import { getCreditLeadFormTaskData, getDebitLeadFormTaskData } from './getLeadFormTaskData';
25
+ import { useLeadFormStore } from './useLeadFormStore';
24
26
  import { useSaveUserData, type UserData } from './useSaveUserData';
25
27
  import { useSendLeadFormAspects } from './useSendLeadFormAspects';
26
28
 
@@ -40,6 +42,8 @@ export const useApplicationLeadApi = ({
40
42
  const [isSending, { setTrue: startSending, setFalse: endSending }] = useBool(false);
41
43
  const [ok, setOK] = useState<boolean | undefined>();
42
44
  const saveUserData = useSaveUserData();
45
+ const leadFormStore = useLeadFormStore();
46
+
43
47
  const sendAspects = useSendLeadFormAspects({ data });
44
48
  const navigator = locationNavigator();
45
49
 
@@ -58,6 +62,7 @@ export const useApplicationLeadApi = ({
58
62
  const profileId = await createUserProfile({
59
63
  profile: { phone: formatPhone(transformedFormData.phone as string) },
60
64
  });
65
+ const referalData = leadFormStore.referalData;
61
66
 
62
67
  if (!profileId) {
63
68
  throw new Error();
@@ -69,6 +74,7 @@ export const useApplicationLeadApi = ({
69
74
  profileId,
70
75
  formData: transformedFormData,
71
76
  productType,
77
+ referalData,
72
78
  saveUserData,
73
79
  sendAspects,
74
80
  });
@@ -130,6 +136,7 @@ const updateUserData = async ({
130
136
  profileId,
131
137
  formData,
132
138
  productType,
139
+ referalData,
133
140
  saveUserData,
134
141
  sendAspects,
135
142
  }: {
@@ -137,15 +144,14 @@ const updateUserData = async ({
137
144
  profileId: number;
138
145
  formData: LeadFormState;
139
146
  productType: ProductType;
147
+ referalData: ReferalData | null;
140
148
  saveUserData: (userData: UserData) => void;
141
149
  sendAspects: (profileId: number, taskId: number) => void;
142
150
  }) => {
143
151
  let taskId: number;
144
152
  let participantId: number;
145
- const refererCode = formData.refererCode;
146
- const referalCode = formData.referalCode;
147
- const productId = formData.productId;
148
153
  const transformedConsents = transformConsentsFields(formData, productType);
154
+ const referalCode = referalData?.referalCode;
149
155
 
150
156
  await updateUserProfile(getUpdateUserProfileData(profileId, formData, transformedConsents));
151
157
 
@@ -169,14 +175,13 @@ const updateUserData = async ({
169
175
  taskId,
170
176
  profileId,
171
177
  formData,
178
+ referalCode,
172
179
  }),
173
180
  );
174
181
  if (referalCode) {
175
182
  await saveReferalInfo({
176
183
  taskId,
177
- refererCode,
178
- referalCode,
179
- productId,
184
+ ...referalData,
180
185
  });
181
186
  }
182
187
  }
@@ -1,8 +1,11 @@
1
+ /* eslint-disable max-lines-per-function */
1
2
  import { useCallback, useEffect, useMemo } from '@redneckz/uni-jsx/lib/hooks';
2
3
  import { useSetter } from '../../hooks/useSetter';
3
4
  import { esiaRequestProfile } from '../../retail/api/esiaRequestProfile';
4
5
  import { type LeadFormState } from '../../retail/model/LeadFormState';
6
+ import { type ReferalData } from '../../retail/model/ReferalData';
5
7
  import { type FieldRetailDef } from '../../retail/model/RetailFormContent';
8
+ import { QUERY_STORAGE_KEY } from '../../utils/getSessionQuery';
6
9
  import { EsiaStatuses, type ProductType } from './ApplicationLeadFormContent';
7
10
  import { getInitialFormState } from './getInitialFormState';
8
11
  import { parseEsiaProfile } from './parseEsiaProfile';
@@ -54,28 +57,25 @@ export const useInitApplicationLead = ({
54
57
  }
55
58
  }, []);
56
59
 
57
- const saveReferalData = useCallback((referalData: Record<string, string | null>) => {
58
- saveForm((_) => ({
59
- ..._,
60
- ...referalData,
61
- }));
62
- }, []);
63
-
64
60
  useEffect(() => {
65
61
  leadFormStore.productType = productType;
66
62
 
67
- const params = new URLSearchParams(decodeURIComponent(globalThis.location?.search));
68
- const code = params.get('code');
69
- const state = params.get('state');
70
- const referalCode = params.get('referalCode');
63
+ const { code, state, referalCode, refererCode, productId } = getLeadQueryParams(
64
+ leadFormStore.referalData,
65
+ );
71
66
 
72
67
  if (referalCode) {
73
- const referalData = {
74
- refererCode: params.get('refererCode'),
68
+ leadFormStore.referalData = {
69
+ refererCode,
75
70
  referalCode,
76
- productId: params.get('productId'),
71
+ productId,
72
+ };
73
+ } else if (!code) {
74
+ leadFormStore.referalData = {
75
+ refererCode: null,
76
+ referalCode: null,
77
+ productId: null,
77
78
  };
78
- saveReferalData(referalData);
79
79
  }
80
80
 
81
81
  if (code && state) {
@@ -88,3 +88,23 @@ export const useInitApplicationLead = ({
88
88
 
89
89
  return initialFormState;
90
90
  };
91
+
92
+ const getLeadQueryParams = (referalData: ReferalData | null) => {
93
+ const queryStorage = new URLSearchParams(
94
+ decodeURIComponent(globalThis.sessionStorage?.getItem(QUERY_STORAGE_KEY) || ''),
95
+ );
96
+
97
+ const code = queryStorage.get('code');
98
+ const state = queryStorage.get('state');
99
+ const referalCode = code ? referalData?.referalCode : queryStorage.get('referalCode');
100
+ const refererCode = code ? referalData?.refererCode : queryStorage.get('refererCode');
101
+ const productId = code ? referalData?.productId : queryStorage.get('productId');
102
+
103
+ return {
104
+ code,
105
+ state,
106
+ referalCode,
107
+ refererCode,
108
+ productId,
109
+ };
110
+ };
@@ -1,5 +1,6 @@
1
1
  import { useLocalStore } from '@redneckz/uni-jsx/lib/Store/useLocalStore';
2
2
  import { type LeadFormState } from '../../retail/model/LeadFormState';
3
+ import { type ReferalData } from '../../retail/model/ReferalData';
3
4
  import { type ProductType } from './ApplicationLeadFormContent';
4
5
 
5
6
  export interface LeadFormStoreSlice {
@@ -9,6 +10,7 @@ export interface LeadFormStoreSlice {
9
10
  participantId: number;
10
11
  programId: string;
11
12
  productType: ProductType;
13
+ referalData: ReferalData;
12
14
  }
13
15
 
14
16
  export const useLeadFormStore = () => useLocalStore<LeadFormStoreSlice>();