@redneckz/wildless-cms-uni-blocks 0.14.636 → 0.14.637

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 (39) hide show
  1. package/bundle/api/RetailAPI/updateProfileEsia.d.ts +7 -7
  2. package/bundle/bundle.umd.js +54 -4
  3. package/bundle/bundle.umd.min.js +1 -1
  4. package/bundle/components/ApplicationLeadForm/pasreEsiaProfile.d.ts +3 -0
  5. package/dist/api/RetailAPI/updateProfileEsia.d.ts +7 -7
  6. package/dist/components/ApplicationLeadForm/pasreEsiaProfile.d.ts +3 -0
  7. package/dist/components/ApplicationLeadForm/pasreEsiaProfile.js +52 -0
  8. package/dist/components/ApplicationLeadForm/pasreEsiaProfile.js.map +1 -0
  9. package/dist/components/ApplicationLeadForm/useInitApplicationLead.js +6 -3
  10. package/dist/components/ApplicationLeadForm/useInitApplicationLead.js.map +1 -1
  11. package/lib/api/RetailAPI/updateProfileEsia.d.ts +7 -7
  12. package/lib/components/ApplicationLeadForm/pasreEsiaProfile.d.ts +3 -0
  13. package/lib/components/ApplicationLeadForm/pasreEsiaProfile.js +49 -0
  14. package/lib/components/ApplicationLeadForm/pasreEsiaProfile.js.map +1 -0
  15. package/lib/components/ApplicationLeadForm/useInitApplicationLead.js +6 -3
  16. package/lib/components/ApplicationLeadForm/useInitApplicationLead.js.map +1 -1
  17. package/mobile/bundle/api/RetailAPI/updateProfileEsia.d.ts +7 -7
  18. package/mobile/bundle/bundle.umd.js +54 -4
  19. package/mobile/bundle/bundle.umd.min.js +1 -1
  20. package/mobile/bundle/components/ApplicationLeadForm/pasreEsiaProfile.d.ts +3 -0
  21. package/mobile/dist/api/RetailAPI/updateProfileEsia.d.ts +7 -7
  22. package/mobile/dist/components/ApplicationLeadForm/pasreEsiaProfile.d.ts +3 -0
  23. package/mobile/dist/components/ApplicationLeadForm/pasreEsiaProfile.js +52 -0
  24. package/mobile/dist/components/ApplicationLeadForm/pasreEsiaProfile.js.map +1 -0
  25. package/mobile/dist/components/ApplicationLeadForm/useInitApplicationLead.js +6 -3
  26. package/mobile/dist/components/ApplicationLeadForm/useInitApplicationLead.js.map +1 -1
  27. package/mobile/lib/api/RetailAPI/updateProfileEsia.d.ts +7 -7
  28. package/mobile/lib/components/ApplicationLeadForm/pasreEsiaProfile.d.ts +3 -0
  29. package/mobile/lib/components/ApplicationLeadForm/pasreEsiaProfile.js +49 -0
  30. package/mobile/lib/components/ApplicationLeadForm/pasreEsiaProfile.js.map +1 -0
  31. package/mobile/lib/components/ApplicationLeadForm/useInitApplicationLead.js +6 -3
  32. package/mobile/lib/components/ApplicationLeadForm/useInitApplicationLead.js.map +1 -1
  33. package/mobile/src/api/RetailAPI/updateProfileEsia.ts +7 -7
  34. package/mobile/src/components/ApplicationLeadForm/pasreEsiaProfile.ts +69 -0
  35. package/mobile/src/components/ApplicationLeadForm/useInitApplicationLead.ts +8 -3
  36. package/package.json +1 -1
  37. package/src/api/RetailAPI/updateProfileEsia.ts +7 -7
  38. package/src/components/ApplicationLeadForm/pasreEsiaProfile.ts +69 -0
  39. package/src/components/ApplicationLeadForm/useInitApplicationLead.ts +8 -3
@@ -0,0 +1,3 @@
1
+ import { type UpdateProfileEsiaResponse } from '../../api/RetailAPI/updateProfileEsia';
2
+ import { type FormState } from './getInitialFormState';
3
+ export declare const parseEsiaProfile: (esiaProfile: UpdateProfileEsiaResponse) => FormState;
@@ -11,7 +11,7 @@ export declare type UpdateProfileEsiaResponse = {
11
11
  surname: string;
12
12
  name: string;
13
13
  midname: string;
14
- birthDate: string;
14
+ birthDate: Date;
15
15
  phone: string;
16
16
  email: string;
17
17
  esiaAccountType: {
@@ -39,11 +39,11 @@ export declare type UpdateProfileEsiaResponse = {
39
39
  value: string;
40
40
  };
41
41
  city: string;
42
- locality: null;
42
+ locality: string;
43
43
  street: string;
44
44
  house: string;
45
- building: null;
46
- block: null;
45
+ building: string;
46
+ block: string;
47
47
  apartment: string;
48
48
  };
49
49
  addressFact: {
@@ -55,11 +55,11 @@ export declare type UpdateProfileEsiaResponse = {
55
55
  value: string;
56
56
  };
57
57
  city: string;
58
- locality: null;
58
+ locality: string;
59
59
  street: string;
60
60
  house: string;
61
- building: null;
62
- block: null;
61
+ building: string;
62
+ block: string;
63
63
  apartment: string;
64
64
  };
65
65
  };
@@ -0,0 +1,3 @@
1
+ import { type UpdateProfileEsiaResponse } from '../../api/RetailAPI/updateProfileEsia';
2
+ import { type FormState } from './getInitialFormState';
3
+ export declare const parseEsiaProfile: (esiaProfile: UpdateProfileEsiaResponse) => FormState;
@@ -0,0 +1,52 @@
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ exports.parseEsiaProfile = void 0;
3
+ const normalizePhone_1 = require("../../ui-kit/PhoneInput/normalizePhone");
4
+ const parseEsiaProfile = (esiaProfile) => {
5
+ const { profile, addInfo, document, addressRegistration, addressFact } = esiaProfile;
6
+ return {
7
+ name: profile?.name,
8
+ surname: profile?.surname,
9
+ middleName: profile?.midname,
10
+ birthday: profile?.birthDate,
11
+ phone: (0, normalizePhone_1.normalizePhone)(profile?.phone),
12
+ email: profile?.email,
13
+ dulIssueDateField: document?.dulIssueDate,
14
+ dulIssuedBy: document?.dulIssuedBy,
15
+ dulNumber: document?.dulNumber,
16
+ dulSerie: document?.dulSerie,
17
+ dulSubdivisionCode: document?.dulSubdivisionCode,
18
+ snils: addInfo?.snils,
19
+ birthPlace: addInfo?.birthPlace,
20
+ addressRegistration: buildAddress(addressRegistration),
21
+ addressFact: buildAddress(addressFact),
22
+ };
23
+ };
24
+ exports.parseEsiaProfile = parseEsiaProfile;
25
+ const concatFullAddress = (address) => {
26
+ return address.reduce((acc, value) => {
27
+ if (value) {
28
+ return acc ? `${acc}, ${value}` : value;
29
+ }
30
+ return acc;
31
+ }, '');
32
+ };
33
+ const buildAddress = (fields) => {
34
+ const { postcode, region, regionCode, locality, city, street, house, building, block, apartment, } = fields;
35
+ const place = locality || city;
36
+ const fullAddress = concatFullAddress([
37
+ postcode,
38
+ region,
39
+ place,
40
+ street ? `ул ${street}` : undefined,
41
+ house ? `д ${house}` : undefined,
42
+ block ? `к ${block}` : undefined,
43
+ building ? `стр ${building}` : undefined,
44
+ apartment ? `кв ${apartment}` : undefined,
45
+ ]);
46
+ return {
47
+ ...fields,
48
+ regionCode: regionCode?.key,
49
+ fullAddress,
50
+ };
51
+ };
52
+ //# sourceMappingURL=pasreEsiaProfile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pasreEsiaProfile.js","sourceRoot":"","sources":["../../../src/components/ApplicationLeadForm/pasreEsiaProfile.ts"],"names":[],"mappings":";;AACA,2EAAwE;AAGjE,MAAM,gBAAgB,GAAG,CAAC,WAAsC,EAAa,EAAE;IACpF,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,WAAW,EAAE,GAAG,WAAW,CAAC;IAErF,OAAO;QACL,IAAI,EAAE,OAAO,EAAE,IAAI;QACnB,OAAO,EAAE,OAAO,EAAE,OAAO;QACzB,UAAU,EAAE,OAAO,EAAE,OAAO;QAC5B,QAAQ,EAAE,OAAO,EAAE,SAAS;QAC5B,KAAK,EAAE,IAAA,+BAAc,EAAC,OAAO,EAAE,KAAK,CAAC;QACrC,KAAK,EAAE,OAAO,EAAE,KAAK;QACrB,iBAAiB,EAAE,QAAQ,EAAE,YAAY;QACzC,WAAW,EAAE,QAAQ,EAAE,WAAW;QAClC,SAAS,EAAE,QAAQ,EAAE,SAAS;QAC9B,QAAQ,EAAE,QAAQ,EAAE,QAAQ;QAC5B,kBAAkB,EAAE,QAAQ,EAAE,kBAAkB;QAChD,KAAK,EAAE,OAAO,EAAE,KAAK;QACrB,UAAU,EAAE,OAAO,EAAE,UAAU;QAC/B,mBAAmB,EAAE,YAAY,CAAC,mBAAmB,CAAC;QACtD,WAAW,EAAE,YAAY,CAAC,WAAW,CAAC;KACvC,CAAC;AACJ,CAAC,CAAC;AApBW,QAAA,gBAAgB,oBAoB3B;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ProfileEsia_1 = require("../../api/RetailAPI/updateProfileEsia");
5
5
  const useLocalStorage_1 = require("../../hooks/useLocalStorage");
6
+ const pasreEsiaProfile_1 = require("./pasreEsiaProfile");
6
7
  const useInitApplicationLead = (nextStepLink) => {
7
8
  const [isLoading, setIsLoading] = (0, hooks_1.useState)(false);
8
9
  const [profileId] = (0, useLocalStorage_1.useLocalStorage)('profileId');
9
- const [, setEsiaData] = (0, useLocalStorage_1.useLocalStorage)('esiaData');
10
+ const [leadForm, setLeadForm] = (0, useLocalStorage_1.useLocalStorage)('leadForm');
10
11
  const params = new URLSearchParams(decodeURIComponent(globalThis.location?.search));
11
12
  const code = params.get('code');
12
13
  const state = params.get('state');
@@ -18,7 +19,10 @@ const useInitApplicationLead = (nextStepLink) => {
18
19
  state,
19
20
  redirectUri: globalThis.location?.href,
20
21
  });
21
- setEsiaData(JSON.stringify(data));
22
+ setLeadForm({
23
+ ...leadForm,
24
+ ...(0, pasreEsiaProfile_1.parseEsiaProfile)(data),
25
+ });
22
26
  globalThis.location.href = nextStepLink;
23
27
  }
24
28
  }, []);
@@ -28,7 +32,6 @@ const useInitApplicationLead = (nextStepLink) => {
28
32
  updateEsiaProfile();
29
33
  }
30
34
  else {
31
- setEsiaData('');
32
35
  sessionStorage.removeItem('accessToken');
33
36
  sessionStorage.removeItem('refreshToken');
34
37
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useInitApplicationLead.js","sourceRoot":"","sources":["../../../src/components/ApplicationLeadForm/useInitApplicationLead.ts"],"names":[],"mappings":";;AAAA,uDAA+E;AAE/E,6EAA0E;AAC1E,iEAA8D;AAEvD,MAAM,sBAAsB,GAAG,CAAC,YAAoB,EAAE,EAAE;IAC7D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAClD,MAAM,CAAC,SAAS,CAAC,GAAG,IAAA,iCAAe,EAAS,WAAW,CAAC,CAAC;IACzD,MAAM,CAAC,EAAE,WAAW,CAAC,GAAG,IAAA,iCAAe,EAAC,UAAU,CAAC,CAAC;IACpD,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,kBAAkB,CAAC,UAAU,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;IACpF,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAChC,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAElC,MAAM,iBAAiB,GAAG,IAAA,mBAAW,EAAC,KAAK,IAAI,EAAE;QAC/C,IAAI,SAAS,IAAI,IAAI,IAAI,KAAK,EAAE;YAC9B,MAAM,IAAI,GAAG,MAAM,IAAA,qCAAiB,EAAC;gBACnC,SAAS,EAAE,SAAS;gBACpB,IAAI;gBACJ,KAAK;gBACL,WAAW,EAAE,UAAU,CAAC,QAAQ,EAAE,IAAI;aACvC,CAAC,CAAC;YAEH,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;YAClC,UAAU,CAAC,QAAQ,CAAC,IAAI,GAAG,YAAY,CAAC;SACzC;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,IAAI,EAAE;YACR,YAAY,CAAC,IAAI,CAAC,CAAC;YACnB,iBAAiB,EAAE,CAAC;SACrB;aAAM;YACL,WAAW,CAAC,EAAE,CAAC,CAAC;YAChB,cAAc,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;YACzC,cAAc,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;SAC3C;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL,SAAS;KACV,CAAC;AACJ,CAAC,CAAC;AApCW,QAAA,sBAAsB,0BAoCjC"}
1
+ {"version":3,"file":"useInitApplicationLead.js","sourceRoot":"","sources":["../../../src/components/ApplicationLeadForm/useInitApplicationLead.ts"],"names":[],"mappings":";;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UAAU,CAAC,aAAa,CAAC,CAAC;YACzC,cAAc,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;SAC3C;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL,SAAS;KACV,CAAC;AACJ,CAAC,CAAC;AAvCW,QAAA,sBAAsB,0BAuCjC"}
@@ -11,7 +11,7 @@ export declare type UpdateProfileEsiaResponse = {
11
11
  surname: string;
12
12
  name: string;
13
13
  midname: string;
14
- birthDate: string;
14
+ birthDate: Date;
15
15
  phone: string;
16
16
  email: string;
17
17
  esiaAccountType: {
@@ -39,11 +39,11 @@ export declare type UpdateProfileEsiaResponse = {
39
39
  value: string;
40
40
  };
41
41
  city: string;
42
- locality: null;
42
+ locality: string;
43
43
  street: string;
44
44
  house: string;
45
- building: null;
46
- block: null;
45
+ building: string;
46
+ block: string;
47
47
  apartment: string;
48
48
  };
49
49
  addressFact: {
@@ -55,11 +55,11 @@ export declare type UpdateProfileEsiaResponse = {
55
55
  value: string;
56
56
  };
57
57
  city: string;
58
- locality: null;
58
+ locality: string;
59
59
  street: string;
60
60
  house: string;
61
- building: null;
62
- block: null;
61
+ building: string;
62
+ block: string;
63
63
  apartment: string;
64
64
  };
65
65
  };
@@ -0,0 +1,3 @@
1
+ import { type UpdateProfileEsiaResponse } from '../../api/RetailAPI/updateProfileEsia';
2
+ import { type FormState } from './getInitialFormState';
3
+ export declare const parseEsiaProfile: (esiaProfile: UpdateProfileEsiaResponse) => FormState;
@@ -0,0 +1,49 @@
1
+ import { normalizePhone } from '../../ui-kit/PhoneInput/normalizePhone.js';
2
+ export const parseEsiaProfile = (esiaProfile) => {
3
+ const { profile, addInfo, document, addressRegistration, addressFact } = esiaProfile;
4
+ return {
5
+ name: profile?.name,
6
+ surname: profile?.surname,
7
+ middleName: profile?.midname,
8
+ birthday: profile?.birthDate,
9
+ phone: normalizePhone(profile?.phone),
10
+ email: profile?.email,
11
+ dulIssueDateField: document?.dulIssueDate,
12
+ dulIssuedBy: document?.dulIssuedBy,
13
+ dulNumber: document?.dulNumber,
14
+ dulSerie: document?.dulSerie,
15
+ dulSubdivisionCode: document?.dulSubdivisionCode,
16
+ snils: addInfo?.snils,
17
+ birthPlace: addInfo?.birthPlace,
18
+ addressRegistration: buildAddress(addressRegistration),
19
+ addressFact: buildAddress(addressFact),
20
+ };
21
+ };
22
+ const concatFullAddress = (address) => {
23
+ return address.reduce((acc, value) => {
24
+ if (value) {
25
+ return acc ? `${acc}, ${value}` : value;
26
+ }
27
+ return acc;
28
+ }, '');
29
+ };
30
+ const buildAddress = (fields) => {
31
+ const { postcode, region, regionCode, locality, city, street, house, building, block, apartment, } = fields;
32
+ const place = locality || city;
33
+ const fullAddress = concatFullAddress([
34
+ postcode,
35
+ region,
36
+ place,
37
+ street ? `ул ${street}` : undefined,
38
+ house ? `д ${house}` : undefined,
39
+ block ? `к ${block}` : undefined,
40
+ building ? `стр ${building}` : undefined,
41
+ apartment ? `кв ${apartment}` : undefined,
42
+ ]);
43
+ return {
44
+ ...fields,
45
+ regionCode: regionCode?.key,
46
+ fullAddress,
47
+ };
48
+ };
49
+ //# sourceMappingURL=pasreEsiaProfile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pasreEsiaProfile.js","sourceRoot":"","sources":["../../../src/components/ApplicationLeadForm/pasreEsiaProfile.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAGxE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,WAAsC,EAAa,EAAE;IACpF,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,WAAW,EAAE,GAAG,WAAW,CAAC;IAErF,OAAO;QACL,IAAI,EAAE,OAAO,EAAE,IAAI;QACnB,OAAO,EAAE,OAAO,EAAE,OAAO;QACzB,UAAU,EAAE,OAAO,EAAE,OAAO;QAC5B,QAAQ,EAAE,OAAO,EAAE,SAAS;QAC5B,KAAK,EAAE,cA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,CAAC,CAAC,SAAS;QAChC,KAAK,CAAC,CAAC,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS;QAChC,QAAQ,CAAC,CAAC,CAAC,OAAO,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS;QACxC,SAAS,CAAC,CAAC,CAAC,MAAM,SAAS,EAAE,CAAC,CAAC,CAAC,SAAS;KAC1C,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,MAAM;QACT,UAAU,EAAE,UAAU,EAAE,GAAG;QAC3B,WAAW;KACZ,CAAC;AACJ,CAAC,CAAC"}
@@ -1,10 +1,11 @@
1
1
  import { useCallback, useEffect, useState } from '@redneckz/uni-jsx/lib/hooks';
2
2
  import { updateProfileEsia } from '../../api/RetailAPI/updateProfileEsia.js';
3
3
  import { useLocalStorage } from '../../hooks/useLocalStorage.js';
4
+ import { parseEsiaProfile } from './pasreEsiaProfile.js';
4
5
  export const useInitApplicationLead = (nextStepLink) => {
5
6
  const [isLoading, setIsLoading] = useState(false);
6
7
  const [profileId] = useLocalStorage('profileId');
7
- const [, setEsiaData] = useLocalStorage('esiaData');
8
+ const [leadForm, setLeadForm] = useLocalStorage('leadForm');
8
9
  const params = new URLSearchParams(decodeURIComponent(globalThis.location?.search));
9
10
  const code = params.get('code');
10
11
  const state = params.get('state');
@@ -16,7 +17,10 @@ export const useInitApplicationLead = (nextStepLink) => {
16
17
  state,
17
18
  redirectUri: globalThis.location?.href,
18
19
  });
19
- setEsiaData(JSON.stringify(data));
20
+ setLeadForm({
21
+ ...leadForm,
22
+ ...parseEsiaProfile(data),
23
+ });
20
24
  globalThis.location.href = nextStepLink;
21
25
  }
22
26
  }, []);
@@ -26,7 +30,6 @@ export const useInitApplicationLead = (nextStepLink) => {
26
30
  updateEsiaProfile();
27
31
  }
28
32
  else {
29
- setEsiaData('');
30
33
  sessionStorage.removeItem('accessToken');
31
34
  sessionStorage.removeItem('refreshToken');
32
35
  }
@@ -1 +1 @@
1
- {"version":3,"file":"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AAC,GAAG,EAAE;QACb,IAAI,IAAI,EAAE;YACR,YAAY,CAAC,IAAI,CAAC,CAAC;YACnB,iBAAiB,EAAE,CAAC;SACrB;aAAM;YACL,WAAW,CAAC,EAAE,CAAC,CAAC;YAChB,cAAc,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;YACzC,cAAc,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;SAC3C;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL,SAAS;KACV,CAAC;AACJ,CAAC,CAAC"}
1
+ {"version":3,"file":"useInitApplicationLead.js","sourceRoot":"","sources":["../../../src/components/ApplicationLeadForm/useInitApplicationLead.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAE/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,YAAoB,EAAE,EAAE;IAC7D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClD,MAAM,CAAC,SAAS,CAAC,GAAG,eAAe,CAAS,WAAW,CAAC,CAAC;IACzD,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,eAAe,CAAY,UAAU,CAAC,CAAC;IACvE,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,kBAAkB,CAAC,UAAU,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;IACpF,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAChC,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAElC,MAAM,iBAAiB,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QAC/C,IAAI,SAAS,IAAI,IAAI,IAAI,KAAK,EAAE;YAC9B,MAAM,IAAI,GAAG,MAAM,iBAAiB,CAAC;gBACnC,SAAS,EAAE,SAAS;gBACpB,IAAI;gBACJ,KAAK;gBACL,WAAW,EAAE,UAAU,CAAC,QAAQ,EAAE,IAAI;aACvC,CAAC,CAAC;YAEH,WAAW,CAAC;gBACV,GAAG,QAAQ;gBACX,GAAG,gBAAgB,CAAC,IAAI,CAAC;aAC1B,CAAC,CAAC;YAEH,UAAU,CAAC,QAAQ,CAAC,IAAI,GAAG,YAAY,CAAC;SACzC;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,IAAI,EAAE;YACR,YAAY,CAAC,IAAI,CAAC,CAAC;YACnB,iBAAiB,EAAE,CAAC;SACrB;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;QACL,SAAS;KACV,CAAC;AACJ,CAAC,CAAC"}
@@ -14,7 +14,7 @@ export type UpdateProfileEsiaResponse = {
14
14
  surname: string;
15
15
  name: string;
16
16
  midname: string;
17
- birthDate: string;
17
+ birthDate: Date;
18
18
  phone: string;
19
19
  email: string;
20
20
  esiaAccountType: {
@@ -42,11 +42,11 @@ export type UpdateProfileEsiaResponse = {
42
42
  value: string;
43
43
  };
44
44
  city: string;
45
- locality: null;
45
+ locality: string;
46
46
  street: string;
47
47
  house: string;
48
- building: null;
49
- block: null;
48
+ building: string;
49
+ block: string;
50
50
  apartment: string;
51
51
  };
52
52
  addressFact: {
@@ -58,11 +58,11 @@ export type UpdateProfileEsiaResponse = {
58
58
  value: string;
59
59
  };
60
60
  city: string;
61
- locality: null;
61
+ locality: string;
62
62
  street: string;
63
63
  house: string;
64
- building: null;
65
- block: null;
64
+ building: string;
65
+ block: string;
66
66
  apartment: string;
67
67
  };
68
68
  };
@@ -0,0 +1,69 @@
1
+ import { type UpdateProfileEsiaResponse } from '../../api/RetailAPI/updateProfileEsia';
2
+ import { normalizePhone } from '../../ui-kit/PhoneInput/normalizePhone';
3
+ import { type Address, type FormState } from './getInitialFormState';
4
+
5
+ export const parseEsiaProfile = (esiaProfile: UpdateProfileEsiaResponse): FormState => {
6
+ const { profile, addInfo, document, addressRegistration, addressFact } = esiaProfile;
7
+
8
+ return {
9
+ name: profile?.name,
10
+ surname: profile?.surname,
11
+ middleName: profile?.midname,
12
+ birthday: profile?.birthDate,
13
+ phone: normalizePhone(profile?.phone),
14
+ email: profile?.email,
15
+ dulIssueDateField: document?.dulIssueDate,
16
+ dulIssuedBy: document?.dulIssuedBy,
17
+ dulNumber: document?.dulNumber,
18
+ dulSerie: document?.dulSerie,
19
+ dulSubdivisionCode: document?.dulSubdivisionCode,
20
+ snils: addInfo?.snils,
21
+ birthPlace: addInfo?.birthPlace,
22
+ addressRegistration: buildAddress(addressRegistration),
23
+ addressFact: buildAddress(addressFact),
24
+ };
25
+ };
26
+
27
+ const concatFullAddress = (address: Array<string | undefined>): string => {
28
+ return address.reduce((acc: string, value) => {
29
+ if (value) {
30
+ return acc ? `${acc}, ${value}` : value;
31
+ }
32
+
33
+ return acc;
34
+ }, '');
35
+ };
36
+
37
+ const buildAddress = (fields: UpdateProfileEsiaResponse['addressRegistration']): Address => {
38
+ const {
39
+ postcode,
40
+ region,
41
+ regionCode,
42
+ locality,
43
+ city,
44
+ street,
45
+ house,
46
+ building,
47
+ block,
48
+ apartment,
49
+ } = fields;
50
+
51
+ const place = locality || city;
52
+
53
+ const fullAddress = concatFullAddress([
54
+ postcode,
55
+ region,
56
+ place,
57
+ street ? `ул ${street}` : undefined,
58
+ house ? `д ${house}` : undefined,
59
+ block ? `к ${block}` : undefined,
60
+ building ? `стр ${building}` : undefined,
61
+ apartment ? `кв ${apartment}` : undefined,
62
+ ]);
63
+
64
+ return {
65
+ ...fields,
66
+ regionCode: regionCode?.key,
67
+ fullAddress,
68
+ };
69
+ };
@@ -2,11 +2,13 @@ import { useCallback, useEffect, useState } from '@redneckz/uni-jsx/lib/hooks';
2
2
 
3
3
  import { updateProfileEsia } from '../../api/RetailAPI/updateProfileEsia';
4
4
  import { useLocalStorage } from '../../hooks/useLocalStorage';
5
+ import { type FormState } from './getInitialFormState';
6
+ import { parseEsiaProfile } from './pasreEsiaProfile';
5
7
 
6
8
  export const useInitApplicationLead = (nextStepLink: string) => {
7
9
  const [isLoading, setIsLoading] = useState(false);
8
10
  const [profileId] = useLocalStorage<string>('profileId');
9
- const [, setEsiaData] = useLocalStorage('esiaData');
11
+ const [leadForm, setLeadForm] = useLocalStorage<FormState>('leadForm');
10
12
  const params = new URLSearchParams(decodeURIComponent(globalThis.location?.search));
11
13
  const code = params.get('code');
12
14
  const state = params.get('state');
@@ -20,7 +22,11 @@ export const useInitApplicationLead = (nextStepLink: string) => {
20
22
  redirectUri: globalThis.location?.href,
21
23
  });
22
24
 
23
- setEsiaData(JSON.stringify(data));
25
+ setLeadForm({
26
+ ...leadForm,
27
+ ...parseEsiaProfile(data),
28
+ });
29
+
24
30
  globalThis.location.href = nextStepLink;
25
31
  }
26
32
  }, []);
@@ -30,7 +36,6 @@ export const useInitApplicationLead = (nextStepLink: string) => {
30
36
  setIsLoading(true);
31
37
  updateEsiaProfile();
32
38
  } else {
33
- setEsiaData('');
34
39
  sessionStorage.removeItem('accessToken');
35
40
  sessionStorage.removeItem('refreshToken');
36
41
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redneckz/wildless-cms-uni-blocks",
3
- "version": "0.14.636",
3
+ "version": "0.14.637",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "ЦК",
@@ -14,7 +14,7 @@ export type UpdateProfileEsiaResponse = {
14
14
  surname: string;
15
15
  name: string;
16
16
  midname: string;
17
- birthDate: string;
17
+ birthDate: Date;
18
18
  phone: string;
19
19
  email: string;
20
20
  esiaAccountType: {
@@ -42,11 +42,11 @@ export type UpdateProfileEsiaResponse = {
42
42
  value: string;
43
43
  };
44
44
  city: string;
45
- locality: null;
45
+ locality: string;
46
46
  street: string;
47
47
  house: string;
48
- building: null;
49
- block: null;
48
+ building: string;
49
+ block: string;
50
50
  apartment: string;
51
51
  };
52
52
  addressFact: {
@@ -58,11 +58,11 @@ export type UpdateProfileEsiaResponse = {
58
58
  value: string;
59
59
  };
60
60
  city: string;
61
- locality: null;
61
+ locality: string;
62
62
  street: string;
63
63
  house: string;
64
- building: null;
65
- block: null;
64
+ building: string;
65
+ block: string;
66
66
  apartment: string;
67
67
  };
68
68
  };
@@ -0,0 +1,69 @@
1
+ import { type UpdateProfileEsiaResponse } from '../../api/RetailAPI/updateProfileEsia';
2
+ import { normalizePhone } from '../../ui-kit/PhoneInput/normalizePhone';
3
+ import { type Address, type FormState } from './getInitialFormState';
4
+
5
+ export const parseEsiaProfile = (esiaProfile: UpdateProfileEsiaResponse): FormState => {
6
+ const { profile, addInfo, document, addressRegistration, addressFact } = esiaProfile;
7
+
8
+ return {
9
+ name: profile?.name,
10
+ surname: profile?.surname,
11
+ middleName: profile?.midname,
12
+ birthday: profile?.birthDate,
13
+ phone: normalizePhone(profile?.phone),
14
+ email: profile?.email,
15
+ dulIssueDateField: document?.dulIssueDate,
16
+ dulIssuedBy: document?.dulIssuedBy,
17
+ dulNumber: document?.dulNumber,
18
+ dulSerie: document?.dulSerie,
19
+ dulSubdivisionCode: document?.dulSubdivisionCode,
20
+ snils: addInfo?.snils,
21
+ birthPlace: addInfo?.birthPlace,
22
+ addressRegistration: buildAddress(addressRegistration),
23
+ addressFact: buildAddress(addressFact),
24
+ };
25
+ };
26
+
27
+ const concatFullAddress = (address: Array<string | undefined>): string => {
28
+ return address.reduce((acc: string, value) => {
29
+ if (value) {
30
+ return acc ? `${acc}, ${value}` : value;
31
+ }
32
+
33
+ return acc;
34
+ }, '');
35
+ };
36
+
37
+ const buildAddress = (fields: UpdateProfileEsiaResponse['addressRegistration']): Address => {
38
+ const {
39
+ postcode,
40
+ region,
41
+ regionCode,
42
+ locality,
43
+ city,
44
+ street,
45
+ house,
46
+ building,
47
+ block,
48
+ apartment,
49
+ } = fields;
50
+
51
+ const place = locality || city;
52
+
53
+ const fullAddress = concatFullAddress([
54
+ postcode,
55
+ region,
56
+ place,
57
+ street ? `ул ${street}` : undefined,
58
+ house ? `д ${house}` : undefined,
59
+ block ? `к ${block}` : undefined,
60
+ building ? `стр ${building}` : undefined,
61
+ apartment ? `кв ${apartment}` : undefined,
62
+ ]);
63
+
64
+ return {
65
+ ...fields,
66
+ regionCode: regionCode?.key,
67
+ fullAddress,
68
+ };
69
+ };
@@ -2,11 +2,13 @@ import { useCallback, useEffect, useState } from '@redneckz/uni-jsx/lib/hooks';
2
2
 
3
3
  import { updateProfileEsia } from '../../api/RetailAPI/updateProfileEsia';
4
4
  import { useLocalStorage } from '../../hooks/useLocalStorage';
5
+ import { type FormState } from './getInitialFormState';
6
+ import { parseEsiaProfile } from './pasreEsiaProfile';
5
7
 
6
8
  export const useInitApplicationLead = (nextStepLink: string) => {
7
9
  const [isLoading, setIsLoading] = useState(false);
8
10
  const [profileId] = useLocalStorage<string>('profileId');
9
- const [, setEsiaData] = useLocalStorage('esiaData');
11
+ const [leadForm, setLeadForm] = useLocalStorage<FormState>('leadForm');
10
12
  const params = new URLSearchParams(decodeURIComponent(globalThis.location?.search));
11
13
  const code = params.get('code');
12
14
  const state = params.get('state');
@@ -20,7 +22,11 @@ export const useInitApplicationLead = (nextStepLink: string) => {
20
22
  redirectUri: globalThis.location?.href,
21
23
  });
22
24
 
23
- setEsiaData(JSON.stringify(data));
25
+ setLeadForm({
26
+ ...leadForm,
27
+ ...parseEsiaProfile(data),
28
+ });
29
+
24
30
  globalThis.location.href = nextStepLink;
25
31
  }
26
32
  }, []);
@@ -30,7 +36,6 @@ export const useInitApplicationLead = (nextStepLink: string) => {
30
36
  setIsLoading(true);
31
37
  updateEsiaProfile();
32
38
  } else {
33
- setEsiaData('');
34
39
  sessionStorage.removeItem('accessToken');
35
40
  sessionStorage.removeItem('refreshToken');
36
41
  }