@redneckz/wildless-cms-uni-blocks 0.14.1040 → 0.14.1042

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 (61) hide show
  1. package/bundle/bundle.umd.js +49 -91
  2. package/bundle/bundle.umd.min.js +1 -1
  3. package/bundle/retail/api/getTaskById.d.ts +1 -1
  4. package/bundle/retail/utils/productTypeToTaskType.d.ts +3 -0
  5. package/dist/components/ApplicationLeadForm/useApplicationLeadApi.js +16 -19
  6. package/dist/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  7. package/dist/retail/api/getTaskById.d.ts +1 -1
  8. package/dist/retail/api/getTaskById.js +4 -1
  9. package/dist/retail/api/getTaskById.js.map +1 -1
  10. package/dist/retail/components/DraftDialog/utils.js +20 -18
  11. package/dist/retail/components/DraftDialog/utils.js.map +1 -1
  12. package/dist/retail/utils/productTypeToTaskType.d.ts +3 -0
  13. package/dist/retail/utils/productTypeToTaskType.js +13 -0
  14. package/dist/retail/utils/productTypeToTaskType.js.map +1 -0
  15. package/lib/components/ApplicationLeadForm/useApplicationLeadApi.js +16 -19
  16. package/lib/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  17. package/lib/retail/api/getTaskById.d.ts +1 -1
  18. package/lib/retail/api/getTaskById.js +4 -1
  19. package/lib/retail/api/getTaskById.js.map +1 -1
  20. package/lib/retail/components/DraftDialog/utils.js +20 -18
  21. package/lib/retail/components/DraftDialog/utils.js.map +1 -1
  22. package/lib/retail/utils/productTypeToTaskType.d.ts +3 -0
  23. package/lib/retail/utils/productTypeToTaskType.js +10 -0
  24. package/lib/retail/utils/productTypeToTaskType.js.map +1 -0
  25. package/mobile/bundle/bundle.umd.js +49 -91
  26. package/mobile/bundle/bundle.umd.min.js +1 -1
  27. package/mobile/bundle/retail/api/getTaskById.d.ts +1 -1
  28. package/mobile/bundle/retail/utils/productTypeToTaskType.d.ts +3 -0
  29. package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.js +16 -19
  30. package/mobile/dist/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  31. package/mobile/dist/retail/api/getTaskById.d.ts +1 -1
  32. package/mobile/dist/retail/api/getTaskById.js +4 -1
  33. package/mobile/dist/retail/api/getTaskById.js.map +1 -1
  34. package/mobile/dist/retail/components/DraftDialog/utils.js +20 -18
  35. package/mobile/dist/retail/components/DraftDialog/utils.js.map +1 -1
  36. package/mobile/dist/retail/utils/productTypeToTaskType.d.ts +3 -0
  37. package/mobile/dist/retail/utils/productTypeToTaskType.js +13 -0
  38. package/mobile/dist/retail/utils/productTypeToTaskType.js.map +1 -0
  39. package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.js +16 -19
  40. package/mobile/lib/components/ApplicationLeadForm/useApplicationLeadApi.js.map +1 -1
  41. package/mobile/lib/retail/api/getTaskById.d.ts +1 -1
  42. package/mobile/lib/retail/api/getTaskById.js +4 -1
  43. package/mobile/lib/retail/api/getTaskById.js.map +1 -1
  44. package/mobile/lib/retail/components/DraftDialog/utils.js +20 -18
  45. package/mobile/lib/retail/components/DraftDialog/utils.js.map +1 -1
  46. package/mobile/lib/retail/utils/productTypeToTaskType.d.ts +3 -0
  47. package/mobile/lib/retail/utils/productTypeToTaskType.js +10 -0
  48. package/mobile/lib/retail/utils/productTypeToTaskType.js.map +1 -0
  49. package/mobile/src/components/ApplicationForm/ApplicationForm.example.json +5 -1
  50. package/mobile/src/components/ApplicationLeadForm/useApplicationLeadApi.tsx +15 -24
  51. package/mobile/src/retail/api/getTaskById.ts +7 -2
  52. package/mobile/src/retail/components/DraftDialog/utils.ts +20 -18
  53. package/mobile/src/retail/utils/productTypeToTaskType.ts +13 -0
  54. package/package.json +1 -1
  55. package/src/components/ApplicationForm/ApplicationForm.example.json +5 -1
  56. package/src/components/ApplicationForm/ApplicationForm.fixture.tsx +5 -1
  57. package/src/components/ApplicationLeadForm/useApplicationLeadApi.tsx +15 -24
  58. package/src/icons/IconName.ts +4 -4
  59. package/src/retail/api/getTaskById.ts +7 -2
  60. package/src/retail/components/DraftDialog/utils.ts +20 -18
  61. package/src/retail/utils/productTypeToTaskType.ts +13 -0
@@ -6895,7 +6895,9 @@
6895
6895
  };
6896
6896
 
6897
6897
  const getTaskById = async (body) => {
6898
- const res = await fetchRetailJSON('/user-data/getTaskById', 'POST', body);
6898
+ const isNewMicroservice = checkNewMicroservice();
6899
+ const endpoint = isNewMicroservice ? '/public-data/getTaskById' : '/user-data/getTaskById';
6900
+ const res = await fetchRetailJSON(endpoint, 'POST', body);
6899
6901
  return res || undefined;
6900
6902
  };
6901
6903
 
@@ -7385,25 +7387,27 @@
7385
7387
  : undefined;
7386
7388
  };
7387
7389
  const getProductData = (taskType) => {
7388
- if (taskType === 'debit') {
7389
- return {
7390
- nextStepLink: '/debit-card-lead',
7391
- newTaskLink: '/natural/debetcards',
7392
- description: 'На дебетовую карту',
7393
- };
7394
- }
7395
- else if (taskType === 'credit') {
7396
- return {
7397
- nextStepLink: '/credit-lead',
7398
- newTaskLink: '/natural/loans/all-goals',
7399
- description: 'На получение кредита',
7400
- };
7390
+ switch (taskType) {
7391
+ case 'debit':
7392
+ return {
7393
+ nextStepLink: '/debit-card-lead',
7394
+ newTaskLink: '/natural/debetcards',
7395
+ description: 'На дебетовую карту',
7396
+ };
7397
+ case 'credit':
7398
+ return {
7399
+ nextStepLink: '/credit-lead',
7400
+ newTaskLink: '/natural/loans/all-goals',
7401
+ description: 'На получение кредита',
7402
+ };
7403
+ case 'card':
7404
+ default:
7405
+ return {
7406
+ nextStepLink: '/credit-card-lead',
7407
+ newTaskLink: '/natural/creditcards/svoya',
7408
+ description: 'На получение кредитной карты',
7409
+ };
7401
7410
  }
7402
- return {
7403
- nextStepLink: '/credit-card-lead',
7404
- newTaskLink: '/natural/creditcards/svoya',
7405
- description: 'На получение кредитной карты',
7406
- };
7407
7411
  };
7408
7412
 
7409
7413
  const parseDraftTask = (task) => {
@@ -7538,59 +7542,6 @@
7538
7542
  };
7539
7543
  };
7540
7544
 
7541
- const draftTaskCard = async () => {
7542
- // TODO: Заглушка - бэкенд в разработке
7543
- return [];
7544
- };
7545
-
7546
- const draftTaskCredit = async () => {
7547
- const res = await fetchRetailJSON('/public-data/draftTaskCredit', 'GET');
7548
- return res ? [res] : [];
7549
- };
7550
-
7551
- const draftTaskDebit = async () => {
7552
- // TODO: Заглушка - бэкенд в разработке
7553
- return [];
7554
- };
7555
-
7556
- const collectDrafts = (creditResults, cardResults, debitResults) => {
7557
- const drafts = [];
7558
- const results = [
7559
- { result: creditResults, type: 'credit' },
7560
- { result: cardResults, type: 'card' },
7561
- { result: debitResults, type: 'debit' },
7562
- ];
7563
- results.forEach(({ result, type }) => {
7564
- if (result.status === 'fulfilled' && result.value.length > 0) {
7565
- drafts.push({ task: result.value[0], type });
7566
- }
7567
- });
7568
- return drafts;
7569
- };
7570
- const findLatestDraft = (drafts) => {
7571
- return drafts.reduce((latest, current) => {
7572
- const latestDate = new Date(latest.task.createdDate || 0);
7573
- const currentDate = new Date(current.task.createdDate || 0);
7574
- return currentDate > latestDate ? current : latest;
7575
- });
7576
- };
7577
- const useDraftSearch = () => {
7578
- const searchDrafts = useCallback(async () => {
7579
- const [creditResults, cardResults, debitResults] = await Promise.allSettled([
7580
- draftTaskCredit(),
7581
- draftTaskCard(),
7582
- draftTaskDebit(),
7583
- ]);
7584
- const drafts = collectDrafts(creditResults, cardResults, debitResults);
7585
- if (drafts.length === 0) {
7586
- return { draft: null, taskType: undefined };
7587
- }
7588
- const latestDraft = findLatestDraft(drafts);
7589
- return { draft: latestDraft.task, taskType: latestDraft.type };
7590
- }, []);
7591
- return { searchDrafts };
7592
- };
7593
-
7594
7545
  // TODO Не должно быть импортов из бизнес-слоя в API слой. Только наоборот.
7595
7546
  const getUpdateUserProfileData = (profileId, formData, consents) => {
7596
7547
  const { name = '', surname = '', middleName = '', limitedBirthday = '', phone = '', email = '', } = formData;
@@ -7608,6 +7559,16 @@
7608
7559
  };
7609
7560
  };
7610
7561
 
7562
+ const productTypeToTaskType = (productType) => {
7563
+ if (productType === 'debitCard') {
7564
+ return 'debit';
7565
+ }
7566
+ if (productType === 'creditCard') {
7567
+ return 'card';
7568
+ }
7569
+ return 'credit';
7570
+ };
7571
+
7611
7572
  const getCreditLeadFormTaskData = ({ participantId, taskId, profileId, formData, marketingInfo, consents, }) => {
7612
7573
  const taskSource = getTaskSource(marketingInfo?.utm_source);
7613
7574
  const participantInfo = getParticipant({ participantId, profileId, formData, consents });
@@ -7739,7 +7700,6 @@
7739
7700
  const consentBkiDialog = useConsentBkiDialog(goToNextStep);
7740
7701
  const verifyPhoneDialog = useDialog(VerifyPhoneDialog);
7741
7702
  const draftDialog = useDraftDialog();
7742
- const { searchDrafts } = useDraftSearch();
7743
7703
  const handleFailSendForm = () => {
7744
7704
  verifyPhoneDialog.close();
7745
7705
  changeSubmitFormStatus(false);
@@ -7788,7 +7748,7 @@
7788
7748
  draftDialog.open({
7789
7749
  task,
7790
7750
  isFromLead: true,
7791
- taskType: productType === 'debitCard' ? 'debit' : 'credit',
7751
+ taskType: productTypeToTaskType(productType),
7792
7752
  sendAspects,
7793
7753
  onClose: sendCurrentTask,
7794
7754
  });
@@ -7857,7 +7817,6 @@
7857
7817
  common,
7858
7818
  draftDialog,
7859
7819
  sendCurrentTask,
7860
- searchDrafts,
7861
7820
  });
7862
7821
  const acceptedConsents = getAcceptedConsents(transformedFormData, productType);
7863
7822
  verifyPhoneDialog.open({
@@ -7901,25 +7860,24 @@
7901
7860
  onFail: handleFailSendForm,
7902
7861
  });
7903
7862
  };
7904
- const createHandleSuccessVerifyNew = ({ common, draftDialog, sendCurrentTask, searchDrafts, }) => async () => {
7905
- const { verifyPhoneDialog, sendAspects, handleFailSendForm } = common;
7863
+ const createHandleSuccessVerifyNew = ({ common, draftDialog, sendCurrentTask, }) => async () => {
7864
+ const { verifyPhoneDialog, sendAspects, handleFailSendForm, userId, programId, productType } = common;
7906
7865
  try {
7907
- const { draft, taskType } = await searchDrafts();
7908
- verifyPhoneDialog.close();
7909
- if (!draft) {
7866
+ const lastTaskId = await getLastTaskStatus({ userId, programId });
7867
+ if (lastTaskId) {
7868
+ const task = await getTaskById({ taskId: lastTaskId });
7869
+ verifyPhoneDialog.close();
7910
7870
  draftDialog.open({
7911
- task: undefined,
7912
- taskType: null,
7871
+ task,
7872
+ isFromLead: true,
7873
+ taskType: productTypeToTaskType(productType),
7874
+ sendAspects,
7875
+ onClose: sendCurrentTask,
7913
7876
  });
7914
- return;
7915
7877
  }
7916
- draftDialog.open({
7917
- task: draft,
7918
- taskType,
7919
- isFromLead: true,
7920
- sendAspects,
7921
- onClose: sendCurrentTask,
7922
- });
7878
+ else {
7879
+ await sendCurrentTask();
7880
+ }
7923
7881
  }
7924
7882
  catch {
7925
7883
  handleFailSendForm();
@@ -14776,7 +14734,7 @@
14776
14734
  slots: () => [HEADER_SLOT, FOOTER_SLOT, STICKY_FOOTER_SLOT],
14777
14735
  });
14778
14736
 
14779
- const packageVersion = "0.14.1039";
14737
+ const packageVersion = "0.14.1041";
14780
14738
 
14781
14739
  exports.Blocks = Blocks;
14782
14740
  exports.ContentPage = ContentPage;