@redneckz/wildless-cms-uni-blocks 0.14.972 → 0.14.973

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 (170) hide show
  1. package/bundle/bundle.umd.js +133 -15
  2. package/bundle/bundle.umd.min.js +1 -1
  3. package/bundle/components/ApplicationLeadForm/getLeadFormTaskData.d.ts +7 -1
  4. package/bundle/components/ApplicationLeadForm/useInitApplicationLead.d.ts +1 -0
  5. package/bundle/retail/api/createUserTaskDebit.d.ts +1 -0
  6. package/bundle/retail/api/getClaimChannel.d.ts +8 -0
  7. package/bundle/retail/hooks/useBiblioglobusDefaultRegion.d.ts +14 -0
  8. package/bundle/retail/utils/filterPaymentSystems.d.ts +4 -0
  9. package/bundle/retail/utils/hasDelivery.d.ts +10 -0
  10. package/bundle/utils/getSlugFromUrl.d.ts +1 -0
  11. package/dist/components/ApplicationLeadForm/getLeadFormTaskData.d.ts +7 -1
  12. package/dist/components/ApplicationLeadForm/getLeadFormTaskData.js +2 -1
  13. package/dist/components/ApplicationLeadForm/getLeadFormTaskData.js.map +1 -1
  14. package/dist/components/ApplicationLeadForm/useApplicationLeadApi.js +24 -4
  15. package/dist/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  16. package/dist/components/ApplicationLeadForm/useInitApplicationLead.d.ts +1 -0
  17. package/dist/components/ApplicationLeadForm/useInitApplicationLead.js +4 -0
  18. package/dist/components/ApplicationLeadForm/useInitApplicationLead.js.map +1 -1
  19. package/dist/retail/api/createUserTaskDebit.d.ts +1 -0
  20. package/dist/retail/api/createUserTaskDebit.js.map +1 -1
  21. package/dist/retail/api/getClaimChannel.d.ts +8 -0
  22. package/dist/retail/api/getClaimChannel.js +9 -0
  23. package/dist/retail/api/getClaimChannel.js.map +1 -0
  24. package/dist/retail/components/Fields/AddressRetailField.js +20 -0
  25. package/dist/retail/components/Fields/AddressRetailField.js.map +1 -1
  26. package/dist/retail/components/Fields/PaymentSystemField.js +14 -2
  27. package/dist/retail/components/Fields/PaymentSystemField.js.map +1 -1
  28. package/dist/retail/components/Fields/RegionRetailField.js +20 -7
  29. package/dist/retail/components/Fields/RegionRetailField.js.map +1 -1
  30. package/dist/retail/hooks/useBiblioglobusDefaultRegion.d.ts +14 -0
  31. package/dist/retail/hooks/useBiblioglobusDefaultRegion.js +34 -0
  32. package/dist/retail/hooks/useBiblioglobusDefaultRegion.js.map +1 -0
  33. package/dist/retail/utils/filterPaymentSystems.d.ts +4 -0
  34. package/dist/retail/utils/filterPaymentSystems.js +13 -0
  35. package/dist/retail/utils/filterPaymentSystems.js.map +1 -0
  36. package/dist/retail/utils/hasDelivery.d.ts +10 -0
  37. package/dist/retail/utils/hasDelivery.js +13 -0
  38. package/dist/retail/utils/hasDelivery.js.map +1 -0
  39. package/dist/utils/getSlugFromUrl.d.ts +1 -0
  40. package/dist/utils/getSlugFromUrl.js +12 -0
  41. package/dist/utils/getSlugFromUrl.js.map +1 -0
  42. package/lib/components/ApplicationLeadForm/getLeadFormTaskData.d.ts +7 -1
  43. package/lib/components/ApplicationLeadForm/getLeadFormTaskData.js +2 -1
  44. package/lib/components/ApplicationLeadForm/getLeadFormTaskData.js.map +1 -1
  45. package/lib/components/ApplicationLeadForm/useApplicationLeadApi.js +24 -4
  46. package/lib/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  47. package/lib/components/ApplicationLeadForm/useInitApplicationLead.d.ts +1 -0
  48. package/lib/components/ApplicationLeadForm/useInitApplicationLead.js +4 -0
  49. package/lib/components/ApplicationLeadForm/useInitApplicationLead.js.map +1 -1
  50. package/lib/retail/api/createUserTaskDebit.d.ts +1 -0
  51. package/lib/retail/api/createUserTaskDebit.js.map +1 -1
  52. package/lib/retail/api/getClaimChannel.d.ts +8 -0
  53. package/lib/retail/api/getClaimChannel.js +6 -0
  54. package/lib/retail/api/getClaimChannel.js.map +1 -0
  55. package/lib/retail/components/Fields/AddressRetailField.js +20 -0
  56. package/lib/retail/components/Fields/AddressRetailField.js.map +1 -1
  57. package/lib/retail/components/Fields/PaymentSystemField.js +14 -2
  58. package/lib/retail/components/Fields/PaymentSystemField.js.map +1 -1
  59. package/lib/retail/components/Fields/RegionRetailField.js +20 -7
  60. package/lib/retail/components/Fields/RegionRetailField.js.map +1 -1
  61. package/lib/retail/hooks/useBiblioglobusDefaultRegion.d.ts +14 -0
  62. package/lib/retail/hooks/useBiblioglobusDefaultRegion.js +31 -0
  63. package/lib/retail/hooks/useBiblioglobusDefaultRegion.js.map +1 -0
  64. package/lib/retail/utils/filterPaymentSystems.d.ts +4 -0
  65. package/lib/retail/utils/filterPaymentSystems.js +10 -0
  66. package/lib/retail/utils/filterPaymentSystems.js.map +1 -0
  67. package/lib/retail/utils/hasDelivery.d.ts +10 -0
  68. package/lib/retail/utils/hasDelivery.js +9 -0
  69. package/lib/retail/utils/hasDelivery.js.map +1 -0
  70. package/lib/utils/getSlugFromUrl.d.ts +1 -0
  71. package/lib/utils/getSlugFromUrl.js +9 -0
  72. package/lib/utils/getSlugFromUrl.js.map +1 -0
  73. package/mobile/bundle/bundle.umd.js +133 -15
  74. package/mobile/bundle/bundle.umd.min.js +1 -1
  75. package/mobile/bundle/components/ApplicationLeadForm/getLeadFormTaskData.d.ts +7 -1
  76. package/mobile/bundle/components/ApplicationLeadForm/useInitApplicationLead.d.ts +1 -0
  77. package/mobile/bundle/retail/api/createUserTaskDebit.d.ts +1 -0
  78. package/mobile/bundle/retail/api/getClaimChannel.d.ts +8 -0
  79. package/mobile/bundle/retail/hooks/useBiblioglobusDefaultRegion.d.ts +14 -0
  80. package/mobile/bundle/retail/utils/filterPaymentSystems.d.ts +4 -0
  81. package/mobile/bundle/retail/utils/hasDelivery.d.ts +10 -0
  82. package/mobile/bundle/utils/getSlugFromUrl.d.ts +1 -0
  83. package/mobile/dist/components/ApplicationLeadForm/getLeadFormTaskData.d.ts +7 -1
  84. package/mobile/dist/components/ApplicationLeadForm/getLeadFormTaskData.js +2 -1
  85. package/mobile/dist/components/ApplicationLeadForm/getLeadFormTaskData.js.map +1 -1
  86. package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.js +24 -4
  87. package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  88. package/mobile/dist/components/ApplicationLeadForm/useInitApplicationLead.d.ts +1 -0
  89. package/mobile/dist/components/ApplicationLeadForm/useInitApplicationLead.js +4 -0
  90. package/mobile/dist/components/ApplicationLeadForm/useInitApplicationLead.js.map +1 -1
  91. package/mobile/dist/retail/api/createUserTaskDebit.d.ts +1 -0
  92. package/mobile/dist/retail/api/createUserTaskDebit.js.map +1 -1
  93. package/mobile/dist/retail/api/getClaimChannel.d.ts +8 -0
  94. package/mobile/dist/retail/api/getClaimChannel.js +9 -0
  95. package/mobile/dist/retail/api/getClaimChannel.js.map +1 -0
  96. package/mobile/dist/retail/components/Fields/AddressRetailField.js +20 -0
  97. package/mobile/dist/retail/components/Fields/AddressRetailField.js.map +1 -1
  98. package/mobile/dist/retail/components/Fields/PaymentSystemField.js +14 -2
  99. package/mobile/dist/retail/components/Fields/PaymentSystemField.js.map +1 -1
  100. package/mobile/dist/retail/components/Fields/RegionRetailField.js +20 -7
  101. package/mobile/dist/retail/components/Fields/RegionRetailField.js.map +1 -1
  102. package/mobile/dist/retail/hooks/useBiblioglobusDefaultRegion.d.ts +14 -0
  103. package/mobile/dist/retail/hooks/useBiblioglobusDefaultRegion.js +34 -0
  104. package/mobile/dist/retail/hooks/useBiblioglobusDefaultRegion.js.map +1 -0
  105. package/mobile/dist/retail/utils/filterPaymentSystems.d.ts +4 -0
  106. package/mobile/dist/retail/utils/filterPaymentSystems.js +13 -0
  107. package/mobile/dist/retail/utils/filterPaymentSystems.js.map +1 -0
  108. package/mobile/dist/retail/utils/hasDelivery.d.ts +10 -0
  109. package/mobile/dist/retail/utils/hasDelivery.js +13 -0
  110. package/mobile/dist/retail/utils/hasDelivery.js.map +1 -0
  111. package/mobile/dist/utils/getSlugFromUrl.d.ts +1 -0
  112. package/mobile/dist/utils/getSlugFromUrl.js +12 -0
  113. package/mobile/dist/utils/getSlugFromUrl.js.map +1 -0
  114. package/mobile/lib/components/ApplicationLeadForm/getLeadFormTaskData.d.ts +7 -1
  115. package/mobile/lib/components/ApplicationLeadForm/getLeadFormTaskData.js +2 -1
  116. package/mobile/lib/components/ApplicationLeadForm/getLeadFormTaskData.js.map +1 -1
  117. package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.js +24 -4
  118. package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  119. package/mobile/lib/components/ApplicationLeadForm/useInitApplicationLead.d.ts +1 -0
  120. package/mobile/lib/components/ApplicationLeadForm/useInitApplicationLead.js +4 -0
  121. package/mobile/lib/components/ApplicationLeadForm/useInitApplicationLead.js.map +1 -1
  122. package/mobile/lib/retail/api/createUserTaskDebit.d.ts +1 -0
  123. package/mobile/lib/retail/api/createUserTaskDebit.js.map +1 -1
  124. package/mobile/lib/retail/api/getClaimChannel.d.ts +8 -0
  125. package/mobile/lib/retail/api/getClaimChannel.js +6 -0
  126. package/mobile/lib/retail/api/getClaimChannel.js.map +1 -0
  127. package/mobile/lib/retail/components/Fields/AddressRetailField.js +20 -0
  128. package/mobile/lib/retail/components/Fields/AddressRetailField.js.map +1 -1
  129. package/mobile/lib/retail/components/Fields/PaymentSystemField.js +14 -2
  130. package/mobile/lib/retail/components/Fields/PaymentSystemField.js.map +1 -1
  131. package/mobile/lib/retail/components/Fields/RegionRetailField.js +20 -7
  132. package/mobile/lib/retail/components/Fields/RegionRetailField.js.map +1 -1
  133. package/mobile/lib/retail/hooks/useBiblioglobusDefaultRegion.d.ts +14 -0
  134. package/mobile/lib/retail/hooks/useBiblioglobusDefaultRegion.js +31 -0
  135. package/mobile/lib/retail/hooks/useBiblioglobusDefaultRegion.js.map +1 -0
  136. package/mobile/lib/retail/utils/filterPaymentSystems.d.ts +4 -0
  137. package/mobile/lib/retail/utils/filterPaymentSystems.js +10 -0
  138. package/mobile/lib/retail/utils/filterPaymentSystems.js.map +1 -0
  139. package/mobile/lib/retail/utils/hasDelivery.d.ts +10 -0
  140. package/mobile/lib/retail/utils/hasDelivery.js +9 -0
  141. package/mobile/lib/retail/utils/hasDelivery.js.map +1 -0
  142. package/mobile/lib/utils/getSlugFromUrl.d.ts +1 -0
  143. package/mobile/lib/utils/getSlugFromUrl.js +9 -0
  144. package/mobile/lib/utils/getSlugFromUrl.js.map +1 -0
  145. package/mobile/src/components/ApplicationLeadForm/getLeadFormTaskData.ts +14 -5
  146. package/mobile/src/components/ApplicationLeadForm/useApplicationLeadApi.tsx +32 -3
  147. package/mobile/src/components/ApplicationLeadForm/useInitApplicationLead.ts +6 -0
  148. package/mobile/src/retail/api/createUserTaskDebit.ts +1 -0
  149. package/mobile/src/retail/api/getClaimChannel.ts +18 -0
  150. package/mobile/src/retail/components/Fields/AddressRetailField.tsx +26 -0
  151. package/mobile/src/retail/components/Fields/PaymentSystemField.tsx +21 -2
  152. package/mobile/src/retail/components/Fields/RegionRetailField.tsx +22 -7
  153. package/mobile/src/retail/hooks/useBiblioglobusDefaultRegion.ts +56 -0
  154. package/mobile/src/retail/utils/filterPaymentSystems.ts +14 -0
  155. package/mobile/src/retail/utils/hasDelivery.ts +22 -0
  156. package/mobile/src/utils/getSlugFromUrl.ts +10 -0
  157. package/package.json +2 -2
  158. package/src/components/ApplicationLeadForm/getLeadFormTaskData.ts +14 -5
  159. package/src/components/ApplicationLeadForm/useApplicationLeadApi.tsx +32 -3
  160. package/src/components/ApplicationLeadForm/useInitApplicationLead.ts +6 -0
  161. package/src/icons/IconName.ts +4 -4
  162. package/src/retail/api/createUserTaskDebit.ts +1 -0
  163. package/src/retail/api/getClaimChannel.ts +18 -0
  164. package/src/retail/components/Fields/AddressRetailField.tsx +26 -0
  165. package/src/retail/components/Fields/PaymentSystemField.tsx +21 -2
  166. package/src/retail/components/Fields/RegionRetailField.tsx +22 -7
  167. package/src/retail/hooks/useBiblioglobusDefaultRegion.ts +56 -0
  168. package/src/retail/utils/filterPaymentSystems.ts +14 -0
  169. package/src/retail/utils/hasDelivery.ts +22 -0
  170. package/src/utils/getSlugFromUrl.ts +10 -0
@@ -8,6 +8,7 @@ import { createDraftTask } from '../../retail/api/createDraftTask';
8
8
  import { createParticipant } from '../../retail/api/createParticipant';
9
9
  import { createUserProfile } from '../../retail/api/createUserProfile';
10
10
  import { createUserTaskDebit } from '../../retail/api/createUserTaskDebit';
11
+ import { getClaimChannel } from '../../retail/api/getClaimChannel';
11
12
  import { getLastTaskStatus } from '../../retail/api/getLastTaskStatus';
12
13
  import { getTaskById } from '../../retail/api/getTaskById';
13
14
  import { saveReferalInfo } from '../../retail/api/saveReferalInfo';
@@ -18,9 +19,11 @@ import { useDraftDialog } from '../../retail/components/DraftDialog/useDraftDial
18
19
  import { VerifyPhoneDialog } from '../../retail/components/VerifyPhoneDialog/VerifyPhoneDialog';
19
20
  import { type FormRetailConsents, type LeadFormState } from '../../retail/model/LeadFormState';
20
21
  import { type ReferalData } from '../../retail/model/ReferalData';
22
+ import { BIBLIOGLOBUS_SLUG } from '../../retail/utils/filterPaymentSystems';
21
23
  import { getUpdateUserProfileData } from '../../retail/utils/getUpdateUserProfile';
22
24
  import { useDialog } from '../../ui-kit/DialogManager/useDialog';
23
25
  import { formatPhone } from '../../utils/formatPhone';
26
+ import { getCardSlugFromUrl } from '../../utils/getSlugFromUrl';
24
27
  import { type ProductType } from './ApplicationLeadFormContent';
25
28
  import { productTypeToConsentsMap } from './consents';
26
29
  import { getCreditLeadFormTaskData, getDebitLeadFormTaskData } from './getLeadFormTaskData';
@@ -76,6 +79,7 @@ export const useApplicationLeadApi = ({
76
79
 
77
80
  const referalData = leadFormStore.referalData;
78
81
  const marketingInfo = sessionStore.marketingInfo;
82
+ const referrerUrl = sessionStore.referrerUrl;
79
83
 
80
84
  if (!profileId) {
81
85
  throw new Error();
@@ -91,6 +95,7 @@ export const useApplicationLeadApi = ({
91
95
  marketingInfo,
92
96
  saveUserData,
93
97
  sendAspects,
98
+ referrerUrl,
94
99
  });
95
100
  verifyPhoneDialog.close();
96
101
  if (productType === 'debitCard') {
@@ -214,6 +219,18 @@ const getAcceptedConsents = (formData: LeadFormState, productType: ProductType):
214
219
  .map((_) => consents[_]?.text);
215
220
  };
216
221
 
222
+ // Padding line to fix eslint padding-line-between-statements
223
+
224
+ const computeClaimChannel = async (slug: string | null): Promise<string | undefined> => {
225
+ if (slug !== BIBLIOGLOBUS_SLUG) {
226
+ return undefined;
227
+ }
228
+
229
+ const claimData = await getClaimChannel();
230
+
231
+ return claimData.find((item) => item.key === slug)?.code;
232
+ };
233
+
217
234
  const updateUserData = async ({
218
235
  programId,
219
236
  profileId,
@@ -223,6 +240,7 @@ const updateUserData = async ({
223
240
  marketingInfo,
224
241
  saveUserData,
225
242
  sendAspects,
243
+ referrerUrl,
226
244
  }: {
227
245
  programId: string;
228
246
  profileId: number;
@@ -232,17 +250,27 @@ const updateUserData = async ({
232
250
  marketingInfo: MarketingInfo | null;
233
251
  saveUserData: (userData: UserData) => void;
234
252
  sendAspects: (profileId: number, taskId: number) => void;
253
+ referrerUrl: string | null;
235
254
  }) => {
236
- let taskId: number;
237
- let participantId: number;
238
255
  const transformedConsents = transformConsentsFields(formData, productType);
256
+ const slug = getCardSlugFromUrl(referrerUrl as string);
239
257
 
240
258
  await updateUserProfile(getUpdateUserProfileData(profileId, formData, transformedConsents));
241
259
 
242
260
  try {
261
+ let taskId: number;
262
+ let participantId: number;
263
+
243
264
  if (productType === 'debitCard') {
265
+ const claimChannelCode = await computeClaimChannel(slug);
266
+
244
267
  const debitData = await createUserTaskDebit(
245
- getDebitLeadFormTaskData(formData, programId, marketingInfo),
268
+ getDebitLeadFormTaskData({
269
+ formData,
270
+ programId,
271
+ marketingInfo,
272
+ claimChannelCode,
273
+ }),
246
274
  );
247
275
 
248
276
  taskId = debitData.taskId;
@@ -265,6 +293,7 @@ const updateUserData = async ({
265
293
  }),
266
294
  );
267
295
  }
296
+
268
297
  if (referalData?.referalCode) {
269
298
  await saveReferalInfo({
270
299
  taskId,
@@ -25,6 +25,7 @@ type InitApplicationLeadProps = {
25
25
  export interface ApplicationLeadStore {
26
26
  marketingInfo: MarketingInfo | null;
27
27
  isNewMicroservice: boolean | null;
28
+ referrerUrl: string | null;
28
29
  }
29
30
 
30
31
  export const useInitApplicationLead = ({
@@ -78,6 +79,11 @@ export const useInitApplicationLead = ({
78
79
 
79
80
  sessionStore.marketingInfo = getMarketingInfo(queryFromStorage, sessionStore);
80
81
  sessionStore.isNewMicroservice = isNewMicroservice || null;
82
+
83
+ const referrer = globalThis.document.referrer;
84
+ if (referrer) {
85
+ sessionStore.referrerUrl = referrer as string;
86
+ }
81
87
  }, [queryFromStorage]);
82
88
 
83
89
  useEffect(() => {
@@ -11,6 +11,7 @@ export type CreateUserTaskDebitBody = {
11
11
  participants: Participant[];
12
12
  marketingInfo?: Nullable<MarketingInfo>;
13
13
  };
14
+ claimChannelCode?: string;
14
15
  };
15
16
 
16
17
  export type CreateUserTaskDebitResponse = {
@@ -0,0 +1,18 @@
1
+ import { fetchRetailJSON } from './doRequest';
2
+
3
+ export type GetClaimChannelResponse = {
4
+ code: string;
5
+ deliveryEmail: string;
6
+ description: string;
7
+ id: number;
8
+ key: string;
9
+ };
10
+
11
+ export const getClaimChannel = async (): Promise<GetClaimChannelResponse[]> => {
12
+ const res = await fetchRetailJSON<GetClaimChannelResponse[]>(
13
+ 'light-api-cash/v1/claimChannel/',
14
+ 'GET',
15
+ );
16
+
17
+ return res || ([] as GetClaimChannelResponse[]);
18
+ };
@@ -1,18 +1,26 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
2
  import { useEffect, useState } from '@redneckz/uni-jsx/lib/hooks';
3
+ import { useSessionStore } from '@redneckz/uni-jsx/lib/Store/useSessionStore';
3
4
  import { getOfficePoint } from '../../../components/OfficesAtmsMap/renderOfficeCard';
4
5
  import { useOfficesAtmsMapData } from '../../../components/OfficesAtmsMap/useOfficesAtmsMapData';
5
6
  import { ClientOnly } from '../../../ui-kit/ClientOnly';
6
7
  import { type CustomFieldProps } from '../../../ui-kit/FormField/CustomFieldProps';
7
8
  import { SelectControl } from '../../../ui-kit/Select/SelectControl';
8
9
  import { YandexMap } from '../../../ui-kit/YandexMap/YandexMap';
10
+ import { getCardSlugFromUrl } from '../../../utils/getSlugFromUrl';
9
11
  import { fetchRegionOffices, type OfficeType } from '../../api/regionOffices';
10
12
  import { useLeadFormData } from '../../hooks/useLeadFormData';
13
+ import { BIBLIOGLOBUS_SLUG } from '../../utils/filterPaymentSystems';
14
+
15
+ const BIBLIOGLOBUS_OFFICE_ID = '714680716';
11
16
 
12
17
  export const AddressRetailField = JSX<CustomFieldProps>(({ field, input }) => {
13
18
  const [offices, setOffices] = useState<OfficeType[]>([]);
14
19
  const { data } = useLeadFormData('REGION_RF');
15
20
 
21
+ const sessionStore = useSessionStore<{ referrerUrl?: string }>();
22
+ const referrerUrl = sessionStore.referrerUrl;
23
+
16
24
  const regionValue = field('regionRetail')?.value || {};
17
25
  const addressField = field(input?.name ?? '');
18
26
 
@@ -27,6 +35,24 @@ export const AddressRetailField = JSX<CustomFieldProps>(({ field, input }) => {
27
35
  }
28
36
  }, [regionValue.key]);
29
37
 
38
+ // Логика для biblioglobus - выбор отделения по умолчанию
39
+ useEffect(() => {
40
+ if (!referrerUrl || !offices.length) {
41
+ return;
42
+ }
43
+
44
+ const slug = getCardSlugFromUrl(referrerUrl);
45
+ if (slug === BIBLIOGLOBUS_SLUG) {
46
+ const defaultOffice = offices.find(
47
+ (office) => office.id?.toString() === BIBLIOGLOBUS_OFFICE_ID,
48
+ );
49
+ addressField.onChange?.({
50
+ key: defaultOffice?.id?.toString() || '',
51
+ text: defaultOffice?.address || '',
52
+ });
53
+ }
54
+ }, [referrerUrl, offices]);
55
+
30
56
  const { points } = useOfficesAtmsMapData({
31
57
  data: offices,
32
58
  filtrationState: {},
@@ -1,11 +1,14 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
2
  import { useMemo, useState } from '@redneckz/uni-jsx/lib/hooks';
3
3
  import { useLocalStore } from '@redneckz/uni-jsx/lib/Store/useLocalStore';
4
+ import { useSessionStore } from '@redneckz/uni-jsx/lib/Store/useSessionStore';
4
5
  import { useAsyncEffect } from '../../../hooks/useAsyncEffect';
5
6
  import { type CustomFieldProps } from '../../../ui-kit/FormField/CustomFieldProps';
6
7
  import { RadioButtonGroupControl } from '../../../ui-kit/RadioButtonGroup/RadioButtonGroupControl';
7
8
  import { type Option } from '../../../ui-kit/Select/Option';
9
+ import { getCardSlugFromUrl } from '../../../utils/getSlugFromUrl';
8
10
  import { getPaymentSystems } from '../../api/getPaymentSystems';
11
+ import { filterPaymentSystems } from '../../utils/filterPaymentSystems';
9
12
 
10
13
  const optionKey = (option: { key?: string } | undefined) => option?.key;
11
14
 
@@ -13,12 +16,28 @@ export const PaymentSystemField = JSX<CustomFieldProps>(({ field, input }) => {
13
16
  const [paymentSystemOptions, setPaymentSystemOptions] = useState<Option[]>([]);
14
17
 
15
18
  const localStore = useLocalStore<{ programId: string }>();
19
+ const sessionStore = useSessionStore<{ referrerUrl?: string }>();
20
+
16
21
  useAsyncEffect(async () => {
17
22
  const { programId } = localStore;
18
- if (programId) {
19
- const fetchedPaymentSystems = await getPaymentSystems(programId);
23
+ if (!programId) {
24
+ return;
25
+ }
26
+
27
+ const fetchedPaymentSystems = await getPaymentSystems(programId);
28
+
29
+ const referrerUrl = sessionStore.referrerUrl;
30
+
31
+ if (!referrerUrl) {
20
32
  setPaymentSystemOptions(fetchedPaymentSystems ?? []);
33
+
34
+ return;
21
35
  }
36
+
37
+ const slug = getCardSlugFromUrl(referrerUrl);
38
+ const filteredSystems = filterPaymentSystems(fetchedPaymentSystems ?? [], slug);
39
+
40
+ setPaymentSystemOptions(filteredSystems);
22
41
  }, []);
23
42
 
24
43
  const items = useMemo(
@@ -1,19 +1,24 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
2
  import { useCallback, useEffect } from '@redneckz/uni-jsx/lib/hooks';
3
3
  import { useAsyncData } from '@redneckz/uni-jsx/lib/hooks/useAsyncData';
4
+ import { useSessionStore } from '@redneckz/uni-jsx/lib/Store/useSessionStore';
4
5
  import { type ProductType } from '../../../components/ApplicationLeadForm/ApplicationLeadFormContent';
5
6
  import { type CustomFieldProps } from '../../../ui-kit/FormField/CustomFieldProps';
6
7
  import { type Option } from '../../../ui-kit/Select/Option';
7
8
  import { SelectControl } from '../../../ui-kit/Select/SelectControl';
8
9
  import { getRegionsCardDelivery } from '../../api/getRegionsCardDelivery';
10
+ import { useBiblioglobusDefaultRegion } from '../../hooks/useBiblioglobusDefaultRegion';
9
11
  import { useLeadFormData } from '../../hooks/useLeadFormData';
10
12
  import { useRetailFormStore } from '../../hooks/useRetailFormStore';
13
+ import { calculateRegionHasDelivery, getRegionDeliveryStatus } from '../../utils/hasDelivery';
11
14
 
12
15
  export const RegionRetailField = JSX<CustomFieldProps>(({ field, input }) => {
13
16
  const { programId, productType } = useRetailFormStore();
14
17
  const { data: regions } = useLeadFormData('REGION_RF');
15
18
  const { data: regionsDelivery } = useAsyncData('regionsDelivery', getRegionsCardDelivery);
16
19
  const { data: productSettings } = useLeadFormData(getCurrentProductSettings(productType));
20
+ const sessionStore = useSessionStore<{ referrerUrl?: string }>();
21
+
17
22
  const isDebit = productType === 'debitCard';
18
23
  const isSalaryCard = programId === '38';
19
24
  const isEsiaAuth = Boolean(field('esiaAccountTypeCd')?.value?.key);
@@ -24,20 +29,30 @@ export const RegionRetailField = JSX<CustomFieldProps>(({ field, input }) => {
24
29
  const handleChangeRegionHasDelivery = field('regionHasDelivery')?.onChange;
25
30
  const handleChangeMethodObtain = field('methodObtain')?.onChange;
26
31
 
32
+ useBiblioglobusDefaultRegion({
33
+ referrerUrl: sessionStore.referrerUrl ?? undefined,
34
+ regions,
35
+ regionsDelivery,
36
+ onRegionChange: handleChangeRegion,
37
+ onRegionHasDeliveryChange: handleChangeRegionHasDelivery,
38
+ onMethodObtainChange: handleChangeMethodObtain,
39
+ });
40
+
27
41
  const onChange = useCallback(
28
42
  (value: Option) => {
29
- const regionHasDelivery = isDebit
30
- ? isEsiaAuth &&
31
- !isSalaryCard &&
32
- isDeliveryActive &&
33
- regionsDelivery?.find((_) => _.regionCode === value.key)?.deliveryFlg
34
- : isDeliveryActive && regionsDelivery?.find((_) => _.regionCode === value.key)?.deliveryFlg;
43
+ const regionHasDelivery = calculateRegionHasDelivery({
44
+ isDebit,
45
+ isEsiaAuth,
46
+ isSalaryCard,
47
+ isDeliveryActive,
48
+ regionDelivery: getRegionDeliveryStatus(regionsDelivery, value),
49
+ });
35
50
 
36
51
  handleChangeRegionHasDelivery?.(regionHasDelivery);
37
52
  handleChangeMethodObtain?.(regionHasDelivery ? 'courier' : 'office');
38
53
  handleChangeRegion?.(value);
39
54
  },
40
- [regionsDelivery, isDeliveryActive, isEsiaAuth],
55
+ [calculateRegionHasDelivery],
41
56
  );
42
57
 
43
58
  useEffect(() => {
@@ -0,0 +1,56 @@
1
+ import { useEffect } from '@redneckz/uni-jsx/lib/hooks';
2
+ import { type Option } from '../../ui-kit/Select/Option';
3
+ import { getCardSlugFromUrl } from '../../utils/getSlugFromUrl';
4
+ import { type DictionaryItem } from '../model/LeadFormData';
5
+ import { BIBLIOGLOBUS_SLUG } from '../utils/filterPaymentSystems';
6
+
7
+ export type RegionDelivery = { regionCode: string; deliveryFlg: boolean };
8
+
9
+ export const useBiblioglobusDefaultRegion = (args: {
10
+ referrerUrl?: string;
11
+ regions?: DictionaryItem[];
12
+ regionsDelivery?: RegionDelivery[];
13
+ onRegionChange?: (option: Option) => void;
14
+ onRegionHasDeliveryChange?: (value: boolean) => void;
15
+ onMethodObtainChange?: (value: string) => void;
16
+ }) => {
17
+ const {
18
+ referrerUrl,
19
+ regions,
20
+ regionsDelivery,
21
+ onRegionChange,
22
+ onRegionHasDeliveryChange,
23
+ onMethodObtainChange,
24
+ } = args;
25
+
26
+ const slug = referrerUrl ? getCardSlugFromUrl(referrerUrl) : '';
27
+ const defaultRegion = regions?.find((region) => region.key === 'REGION_77');
28
+ const regionHasDelivery = Boolean(
29
+ regionsDelivery?.find((rd) => rd.regionCode === 'REGION_77')?.deliveryFlg,
30
+ );
31
+ const isReady = Boolean(
32
+ referrerUrl &&
33
+ regions &&
34
+ regionsDelivery &&
35
+ slug === BIBLIOGLOBUS_SLUG &&
36
+ defaultRegion?.key &&
37
+ defaultRegion?.value,
38
+ );
39
+
40
+ useEffect(() => {
41
+ if (!isReady || !defaultRegion || !defaultRegion.key || !defaultRegion.value) {
42
+ return;
43
+ }
44
+
45
+ onRegionChange?.({ key: defaultRegion.key, text: defaultRegion.value });
46
+ onRegionHasDeliveryChange?.(regionHasDelivery);
47
+ onMethodObtainChange?.(regionHasDelivery ? 'courier' : 'office');
48
+ }, [
49
+ isReady,
50
+ defaultRegion,
51
+ regionHasDelivery,
52
+ onRegionChange,
53
+ onRegionHasDeliveryChange,
54
+ onMethodObtainChange,
55
+ ]);
56
+ };
@@ -0,0 +1,14 @@
1
+ import { type Option } from '../../ui-kit/Select/Option';
2
+
3
+ const BIBLIOGLOBUS_SLUG = 'biblioglobus';
4
+ const UNIONPAY_TEXT = 'UnionPay';
5
+
6
+ export const filterPaymentSystems = (systems: Option[], slug: string | null): Option[] => {
7
+ if (slug !== BIBLIOGLOBUS_SLUG) {
8
+ return systems;
9
+ }
10
+
11
+ return systems.filter((system) => system.text === UNIONPAY_TEXT);
12
+ };
13
+
14
+ export { BIBLIOGLOBUS_SLUG };
@@ -0,0 +1,22 @@
1
+ import { type Option } from '../../ui-kit/Select/Option';
2
+ import { type RegionDelivery } from '../hooks/useBiblioglobusDefaultRegion';
3
+
4
+ export const getRegionDeliveryStatus = (
5
+ regionsDelivery: RegionDelivery[] | undefined,
6
+ value: Option,
7
+ ) => regionsDelivery?.find((_) => _.regionCode === String(value.key))?.deliveryFlg;
8
+
9
+ export const calculateRegionHasDelivery = (args: {
10
+ isDebit: boolean;
11
+ isEsiaAuth: boolean;
12
+ isSalaryCard: boolean;
13
+ isDeliveryActive: boolean;
14
+ regionDelivery?: boolean;
15
+ }) => {
16
+ const { isDebit, isEsiaAuth, isSalaryCard, isDeliveryActive, regionDelivery } = args;
17
+ if (isDebit) {
18
+ return isEsiaAuth && !isSalaryCard && isDeliveryActive && regionDelivery;
19
+ }
20
+
21
+ return isDeliveryActive && regionDelivery;
22
+ };
@@ -0,0 +1,10 @@
1
+ export function getCardSlugFromUrl(url: string): string | null {
2
+ const lastSegment = url.split('/').filter(Boolean).pop();
3
+ if (!lastSegment) {
4
+ return null;
5
+ }
6
+
7
+ const parts = lastSegment.split('-');
8
+
9
+ return parts.length > 1 ? parts[parts.length - 1] : null;
10
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redneckz/wildless-cms-uni-blocks",
3
- "version": "0.14.972",
3
+ "version": "0.14.973",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "ЦК",
@@ -205,7 +205,7 @@
205
205
  "path": "lib/common.css"
206
206
  },
207
207
  {
208
- "limit": "105 kB",
208
+ "limit": "106 kB",
209
209
  "path": "bundle/bundle.umd.min.js"
210
210
  }
211
211
  ],
@@ -83,11 +83,19 @@ export const getParticipant = ({
83
83
  };
84
84
  };
85
85
 
86
- export const getDebitLeadFormTaskData = (
87
- formData: LeadFormState,
88
- programId: string,
89
- marketingInfo: MarketingInfo | null,
90
- ): CreateUserTaskDebitBody => {
86
+ type GetDebitLeadFormTaskDataProps = {
87
+ formData: LeadFormState;
88
+ programId: string;
89
+ marketingInfo: MarketingInfo | null;
90
+ claimChannelCode?: string;
91
+ };
92
+
93
+ export const getDebitLeadFormTaskData = ({
94
+ formData,
95
+ programId,
96
+ marketingInfo,
97
+ claimChannelCode,
98
+ }: GetDebitLeadFormTaskDataProps): CreateUserTaskDebitBody => {
91
99
  const { name, surname, middleName, limitedBirthday, phone, email } = formData;
92
100
  const taskSource = getTaskSource(marketingInfo?.utm_source);
93
101
 
@@ -111,6 +119,7 @@ export const getDebitLeadFormTaskData = (
111
119
  ],
112
120
  marketingInfo,
113
121
  },
122
+ ...(claimChannelCode ? { claimChannelCode } : {}),
114
123
  };
115
124
  };
116
125
 
@@ -8,6 +8,7 @@ import { createDraftTask } from '../../retail/api/createDraftTask';
8
8
  import { createParticipant } from '../../retail/api/createParticipant';
9
9
  import { createUserProfile } from '../../retail/api/createUserProfile';
10
10
  import { createUserTaskDebit } from '../../retail/api/createUserTaskDebit';
11
+ import { getClaimChannel } from '../../retail/api/getClaimChannel';
11
12
  import { getLastTaskStatus } from '../../retail/api/getLastTaskStatus';
12
13
  import { getTaskById } from '../../retail/api/getTaskById';
13
14
  import { saveReferalInfo } from '../../retail/api/saveReferalInfo';
@@ -18,9 +19,11 @@ import { useDraftDialog } from '../../retail/components/DraftDialog/useDraftDial
18
19
  import { VerifyPhoneDialog } from '../../retail/components/VerifyPhoneDialog/VerifyPhoneDialog';
19
20
  import { type FormRetailConsents, type LeadFormState } from '../../retail/model/LeadFormState';
20
21
  import { type ReferalData } from '../../retail/model/ReferalData';
22
+ import { BIBLIOGLOBUS_SLUG } from '../../retail/utils/filterPaymentSystems';
21
23
  import { getUpdateUserProfileData } from '../../retail/utils/getUpdateUserProfile';
22
24
  import { useDialog } from '../../ui-kit/DialogManager/useDialog';
23
25
  import { formatPhone } from '../../utils/formatPhone';
26
+ import { getCardSlugFromUrl } from '../../utils/getSlugFromUrl';
24
27
  import { type ProductType } from './ApplicationLeadFormContent';
25
28
  import { productTypeToConsentsMap } from './consents';
26
29
  import { getCreditLeadFormTaskData, getDebitLeadFormTaskData } from './getLeadFormTaskData';
@@ -76,6 +79,7 @@ export const useApplicationLeadApi = ({
76
79
 
77
80
  const referalData = leadFormStore.referalData;
78
81
  const marketingInfo = sessionStore.marketingInfo;
82
+ const referrerUrl = sessionStore.referrerUrl;
79
83
 
80
84
  if (!profileId) {
81
85
  throw new Error();
@@ -91,6 +95,7 @@ export const useApplicationLeadApi = ({
91
95
  marketingInfo,
92
96
  saveUserData,
93
97
  sendAspects,
98
+ referrerUrl,
94
99
  });
95
100
  verifyPhoneDialog.close();
96
101
  if (productType === 'debitCard') {
@@ -214,6 +219,18 @@ const getAcceptedConsents = (formData: LeadFormState, productType: ProductType):
214
219
  .map((_) => consents[_]?.text);
215
220
  };
216
221
 
222
+ // Padding line to fix eslint padding-line-between-statements
223
+
224
+ const computeClaimChannel = async (slug: string | null): Promise<string | undefined> => {
225
+ if (slug !== BIBLIOGLOBUS_SLUG) {
226
+ return undefined;
227
+ }
228
+
229
+ const claimData = await getClaimChannel();
230
+
231
+ return claimData.find((item) => item.key === slug)?.code;
232
+ };
233
+
217
234
  const updateUserData = async ({
218
235
  programId,
219
236
  profileId,
@@ -223,6 +240,7 @@ const updateUserData = async ({
223
240
  marketingInfo,
224
241
  saveUserData,
225
242
  sendAspects,
243
+ referrerUrl,
226
244
  }: {
227
245
  programId: string;
228
246
  profileId: number;
@@ -232,17 +250,27 @@ const updateUserData = async ({
232
250
  marketingInfo: MarketingInfo | null;
233
251
  saveUserData: (userData: UserData) => void;
234
252
  sendAspects: (profileId: number, taskId: number) => void;
253
+ referrerUrl: string | null;
235
254
  }) => {
236
- let taskId: number;
237
- let participantId: number;
238
255
  const transformedConsents = transformConsentsFields(formData, productType);
256
+ const slug = getCardSlugFromUrl(referrerUrl as string);
239
257
 
240
258
  await updateUserProfile(getUpdateUserProfileData(profileId, formData, transformedConsents));
241
259
 
242
260
  try {
261
+ let taskId: number;
262
+ let participantId: number;
263
+
243
264
  if (productType === 'debitCard') {
265
+ const claimChannelCode = await computeClaimChannel(slug);
266
+
244
267
  const debitData = await createUserTaskDebit(
245
- getDebitLeadFormTaskData(formData, programId, marketingInfo),
268
+ getDebitLeadFormTaskData({
269
+ formData,
270
+ programId,
271
+ marketingInfo,
272
+ claimChannelCode,
273
+ }),
246
274
  );
247
275
 
248
276
  taskId = debitData.taskId;
@@ -265,6 +293,7 @@ const updateUserData = async ({
265
293
  }),
266
294
  );
267
295
  }
296
+
268
297
  if (referalData?.referalCode) {
269
298
  await saveReferalInfo({
270
299
  taskId,
@@ -25,6 +25,7 @@ type InitApplicationLeadProps = {
25
25
  export interface ApplicationLeadStore {
26
26
  marketingInfo: MarketingInfo | null;
27
27
  isNewMicroservice: boolean | null;
28
+ referrerUrl: string | null;
28
29
  }
29
30
 
30
31
  export const useInitApplicationLead = ({
@@ -78,6 +79,11 @@ export const useInitApplicationLead = ({
78
79
 
79
80
  sessionStore.marketingInfo = getMarketingInfo(queryFromStorage, sessionStore);
80
81
  sessionStore.isNewMicroservice = isNewMicroservice || null;
82
+
83
+ const referrer = globalThis.document.referrer;
84
+ if (referrer) {
85
+ sessionStore.referrerUrl = referrer as string;
86
+ }
81
87
  }, [queryFromStorage]);
82
88
 
83
89
  useEffect(() => {