@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
@@ -6903,7 +6903,9 @@
6903
6903
  };
6904
6904
 
6905
6905
  const getTaskById = async (body) => {
6906
- const res = await fetchRetailJSON('/user-data/getTaskById', 'POST', body);
6906
+ const isNewMicroservice = checkNewMicroservice();
6907
+ const endpoint = isNewMicroservice ? '/public-data/getTaskById' : '/user-data/getTaskById';
6908
+ const res = await fetchRetailJSON(endpoint, 'POST', body);
6907
6909
  return res || undefined;
6908
6910
  };
6909
6911
 
@@ -7393,25 +7395,27 @@
7393
7395
  : undefined;
7394
7396
  };
7395
7397
  const getProductData = (taskType) => {
7396
- if (taskType === 'debit') {
7397
- return {
7398
- nextStepLink: '/debit-card-lead',
7399
- newTaskLink: '/natural/debetcards',
7400
- description: 'На дебетовую карту',
7401
- };
7402
- }
7403
- else if (taskType === 'credit') {
7404
- return {
7405
- nextStepLink: '/credit-lead',
7406
- newTaskLink: '/natural/loans/all-goals',
7407
- description: 'На получение кредита',
7408
- };
7398
+ switch (taskType) {
7399
+ case 'debit':
7400
+ return {
7401
+ nextStepLink: '/debit-card-lead',
7402
+ newTaskLink: '/natural/debetcards',
7403
+ description: 'На дебетовую карту',
7404
+ };
7405
+ case 'credit':
7406
+ return {
7407
+ nextStepLink: '/credit-lead',
7408
+ newTaskLink: '/natural/loans/all-goals',
7409
+ description: 'На получение кредита',
7410
+ };
7411
+ case 'card':
7412
+ default:
7413
+ return {
7414
+ nextStepLink: '/credit-card-lead',
7415
+ newTaskLink: '/natural/creditcards/svoya',
7416
+ description: 'На получение кредитной карты',
7417
+ };
7409
7418
  }
7410
- return {
7411
- nextStepLink: '/credit-card-lead',
7412
- newTaskLink: '/natural/creditcards/svoya',
7413
- description: 'На получение кредитной карты',
7414
- };
7415
7419
  };
7416
7420
 
7417
7421
  const parseDraftTask = (task) => {
@@ -7546,59 +7550,6 @@
7546
7550
  };
7547
7551
  };
7548
7552
 
7549
- const draftTaskCard = async () => {
7550
- // TODO: Заглушка - бэкенд в разработке
7551
- return [];
7552
- };
7553
-
7554
- const draftTaskCredit = async () => {
7555
- const res = await fetchRetailJSON('/public-data/draftTaskCredit', 'GET');
7556
- return res ? [res] : [];
7557
- };
7558
-
7559
- const draftTaskDebit = async () => {
7560
- // TODO: Заглушка - бэкенд в разработке
7561
- return [];
7562
- };
7563
-
7564
- const collectDrafts = (creditResults, cardResults, debitResults) => {
7565
- const drafts = [];
7566
- const results = [
7567
- { result: creditResults, type: 'credit' },
7568
- { result: cardResults, type: 'card' },
7569
- { result: debitResults, type: 'debit' },
7570
- ];
7571
- results.forEach(({ result, type }) => {
7572
- if (result.status === 'fulfilled' && result.value.length > 0) {
7573
- drafts.push({ task: result.value[0], type });
7574
- }
7575
- });
7576
- return drafts;
7577
- };
7578
- const findLatestDraft = (drafts) => {
7579
- return drafts.reduce((latest, current) => {
7580
- const latestDate = new Date(latest.task.createdDate || 0);
7581
- const currentDate = new Date(current.task.createdDate || 0);
7582
- return currentDate > latestDate ? current : latest;
7583
- });
7584
- };
7585
- const useDraftSearch = () => {
7586
- const searchDrafts = useCallback(async () => {
7587
- const [creditResults, cardResults, debitResults] = await Promise.allSettled([
7588
- draftTaskCredit(),
7589
- draftTaskCard(),
7590
- draftTaskDebit(),
7591
- ]);
7592
- const drafts = collectDrafts(creditResults, cardResults, debitResults);
7593
- if (drafts.length === 0) {
7594
- return { draft: null, taskType: undefined };
7595
- }
7596
- const latestDraft = findLatestDraft(drafts);
7597
- return { draft: latestDraft.task, taskType: latestDraft.type };
7598
- }, []);
7599
- return { searchDrafts };
7600
- };
7601
-
7602
7553
  // TODO Не должно быть импортов из бизнес-слоя в API слой. Только наоборот.
7603
7554
  const getUpdateUserProfileData = (profileId, formData, consents) => {
7604
7555
  const { name = '', surname = '', middleName = '', limitedBirthday = '', phone = '', email = '', } = formData;
@@ -7616,6 +7567,16 @@
7616
7567
  };
7617
7568
  };
7618
7569
 
7570
+ const productTypeToTaskType = (productType) => {
7571
+ if (productType === 'debitCard') {
7572
+ return 'debit';
7573
+ }
7574
+ if (productType === 'creditCard') {
7575
+ return 'card';
7576
+ }
7577
+ return 'credit';
7578
+ };
7579
+
7619
7580
  const getCreditLeadFormTaskData = ({ participantId, taskId, profileId, formData, marketingInfo, consents, }) => {
7620
7581
  const taskSource = getTaskSource(marketingInfo?.utm_source);
7621
7582
  const participantInfo = getParticipant({ participantId, profileId, formData, consents });
@@ -7747,7 +7708,6 @@
7747
7708
  const consentBkiDialog = useConsentBkiDialog(goToNextStep);
7748
7709
  const verifyPhoneDialog = useDialog(VerifyPhoneDialog);
7749
7710
  const draftDialog = useDraftDialog();
7750
- const { searchDrafts } = useDraftSearch();
7751
7711
  const handleFailSendForm = () => {
7752
7712
  verifyPhoneDialog.close();
7753
7713
  changeSubmitFormStatus(false);
@@ -7796,7 +7756,7 @@
7796
7756
  draftDialog.open({
7797
7757
  task,
7798
7758
  isFromLead: true,
7799
- taskType: productType === 'debitCard' ? 'debit' : 'credit',
7759
+ taskType: productTypeToTaskType(productType),
7800
7760
  sendAspects,
7801
7761
  onClose: sendCurrentTask,
7802
7762
  });
@@ -7865,7 +7825,6 @@
7865
7825
  common,
7866
7826
  draftDialog,
7867
7827
  sendCurrentTask,
7868
- searchDrafts,
7869
7828
  });
7870
7829
  const acceptedConsents = getAcceptedConsents(transformedFormData, productType);
7871
7830
  verifyPhoneDialog.open({
@@ -7909,25 +7868,24 @@
7909
7868
  onFail: handleFailSendForm,
7910
7869
  });
7911
7870
  };
7912
- const createHandleSuccessVerifyNew = ({ common, draftDialog, sendCurrentTask, searchDrafts, }) => async () => {
7913
- const { verifyPhoneDialog, sendAspects, handleFailSendForm } = common;
7871
+ const createHandleSuccessVerifyNew = ({ common, draftDialog, sendCurrentTask, }) => async () => {
7872
+ const { verifyPhoneDialog, sendAspects, handleFailSendForm, userId, programId, productType } = common;
7914
7873
  try {
7915
- const { draft, taskType } = await searchDrafts();
7916
- verifyPhoneDialog.close();
7917
- if (!draft) {
7874
+ const lastTaskId = await getLastTaskStatus({ userId, programId });
7875
+ if (lastTaskId) {
7876
+ const task = await getTaskById({ taskId: lastTaskId });
7877
+ verifyPhoneDialog.close();
7918
7878
  draftDialog.open({
7919
- task: undefined,
7920
- taskType: null,
7879
+ task,
7880
+ isFromLead: true,
7881
+ taskType: productTypeToTaskType(productType),
7882
+ sendAspects,
7883
+ onClose: sendCurrentTask,
7921
7884
  });
7922
- return;
7923
7885
  }
7924
- draftDialog.open({
7925
- task: draft,
7926
- taskType,
7927
- isFromLead: true,
7928
- sendAspects,
7929
- onClose: sendCurrentTask,
7930
- });
7886
+ else {
7887
+ await sendCurrentTask();
7888
+ }
7931
7889
  }
7932
7890
  catch {
7933
7891
  handleFailSendForm();
@@ -14546,7 +14504,7 @@
14546
14504
  slots: () => [HEADER_SLOT, FOOTER_SLOT, STICKY_FOOTER_SLOT],
14547
14505
  });
14548
14506
 
14549
- const packageVersion = "0.14.1039";
14507
+ const packageVersion = "0.14.1041";
14550
14508
 
14551
14509
  exports.Blocks = Blocks;
14552
14510
  exports.ContentPage = ContentPage;