adata-ui 2.1.0 → 2.1.2

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 (307) hide show
  1. package/.editorconfig +12 -12
  2. package/.nuxtrc +1 -1
  3. package/.playground/app.config.ts +5 -5
  4. package/README.md +75 -75
  5. package/app.config.ts +4 -3
  6. package/app.vue +1 -0
  7. package/assets/styles/index.scss +104 -0
  8. package/assets/styles/modules/_base.scss +5 -0
  9. package/assets/styles/modules/_typography.scss +152 -0
  10. package/components/elements/README.md +1 -1
  11. package/components/elements/accordion/AAccordion.vue +13 -12
  12. package/components/elements/curve-block/ACurveBlock.vue +94 -19
  13. package/components/elements/feature-description/AFeatureDescription.vue +4 -4
  14. package/components/elements/illustrations/noAccess.vue +11 -2
  15. package/components/elements/photos-animation/APhotosAnimation.vue +3 -1
  16. package/components/elements/select/ASelect.vue +65 -9
  17. package/components/features/lang-switcher/lang-switcher.vue +8 -1
  18. package/components/features/payment/banner/BasicPlusLimitBanner.vue +104 -0
  19. package/components/features/payment/banner/PaymentBanner.vue +108 -0
  20. package/components/features/payment/process/PaymentKaspiQrSidePanel.vue +158 -0
  21. package/components/features/payment/process/PaymentKaspiRedirectSidePanel.vue +112 -0
  22. package/components/features/payment/process/PaymentMethodSidePanel.vue +121 -0
  23. package/components/features/payment/process/PaymentProcess.vue +138 -0
  24. package/components/features/payment/process/PaymentTopUpSidePanel.vue +130 -0
  25. package/components/features/pk-mobile-services/APkMobileServices.vue +21 -2
  26. package/components/forms/README.md +1 -1
  27. package/components/forms/checkbox/ACheckbox.vue +0 -2
  28. package/components/forms/radio-button/ARadioButton.vue +21 -13
  29. package/components/forms/request-demo/ARequestDemo.vue +21 -7
  30. package/components/modals/AConfirmationEmail.vue +40 -0
  31. package/components/modals/AnotherDeviceModal.vue +3 -2
  32. package/components/modals/ConnectingTariffModal.vue +0 -1
  33. package/components/modals/ContentNavigationModal.vue +148 -75
  34. package/components/modals/Insufficient-funds-modal.vue +5 -2
  35. package/components/modals/LimitReachedModal.vue +4 -3
  36. package/components/modals/ReportBugModal.vue +3 -3
  37. package/components/modals/Resend.vue +82 -0
  38. package/components/modals/SubmitApplicationModal.vue +4 -0
  39. package/components/modals/id/AuthModal.vue +78 -0
  40. package/components/modals/id/IdAutoLogoutModal.vue +45 -0
  41. package/components/modals/id/IdBanner.vue +58 -0
  42. package/components/modals/id/IdConfirmAccountOtpModal.vue +186 -0
  43. package/components/modals/id/IdConfirmSuccessfulModal.vue +41 -0
  44. package/components/modals/id/IdLoginModal.vue +316 -0
  45. package/components/modals/id/IdModals.vue +114 -0
  46. package/components/modals/id/IdNewPasswordModal.vue +129 -0
  47. package/components/modals/id/IdOtpInput.vue +155 -0
  48. package/components/modals/id/IdPasswordSuccessfulModal.vue +25 -0
  49. package/components/modals/id/IdRecoveryModal.vue +117 -0
  50. package/components/modals/id/IdRegistrationModal.vue +215 -0
  51. package/components/modals/id/IdResetPasswordOtpModal.vue +158 -0
  52. package/components/modals/id/IdTwoFactorModal.vue +130 -0
  53. package/components/navigation/README.md +1 -1
  54. package/components/navigation/bottom-navigation/ABottomNavigation.vue +34 -29
  55. package/components/navigation/footer/AFooter.vue +210 -57
  56. package/components/navigation/footer/ui/{new-footer-accordion.vue → a-footer-accordion.vue} +2 -4
  57. package/components/navigation/header/AHeader.vue +59 -51
  58. package/components/navigation/header/AlmatyContacts.vue +16 -14
  59. package/components/navigation/header/AstanaContacts.vue +13 -11
  60. package/components/navigation/header/CardGallery.vue +5 -4
  61. package/components/navigation/header/HeaderLink.vue +16 -8
  62. package/components/navigation/header/NavList.vue +21 -5
  63. package/components/navigation/header/ProductMenu.vue +8 -78
  64. package/components/navigation/header/ProfileMenu.vue +10 -5
  65. package/components/navigation/header/TopHeader.vue +2 -2
  66. package/components/navigation/mobile-navigation/AMobileNavigation.vue +3 -3
  67. package/components/navigation/pill-tabs/APillTabs.vue +18 -4
  68. package/components/navigation/pill-tabs/types.ts +1 -0
  69. package/components/navigation/side-navigation/ASideNavigation.vue +23 -21
  70. package/components/overlays/README.md +1 -1
  71. package/components/overlays/side-panel/ASidePanel.vue +439 -0
  72. package/components/overlays/tooltip/ATooltip.vue +149 -154
  73. package/components/utils/removeTrailingSlash.ts +7 -0
  74. package/composables/useBuyTariffs.ts +91 -0
  75. package/composables/useHeaderNavigationLinks.ts +174 -297
  76. package/composables/useIdModals.ts +36 -0
  77. package/composables/usePayment.ts +74 -0
  78. package/composables/useUrls.ts +21 -0
  79. package/eslint.config.mjs +45 -0
  80. package/icons/adata-logo.vue +1 -1
  81. package/icons/ai-assistant.vue +13 -0
  82. package/icons/akimat.vue +20 -0
  83. package/icons/arrow/arrow-bottom-left-on-square.vue +1 -1
  84. package/icons/arrow/arrow-circle-reset.vue +1 -1
  85. package/icons/arrow/arrow-corner.vue +1 -1
  86. package/icons/arrow/arrow-graph-down.vue +1 -1
  87. package/icons/arrow/arrow-graph-up.vue +1 -1
  88. package/icons/arrow/arrow-square-down.vue +1 -1
  89. package/icons/arrow/arrow-top-right-on-square.vue +1 -1
  90. package/icons/arrow-currency-gray.vue +1 -1
  91. package/icons/arrow-currency-green.vue +1 -1
  92. package/icons/arrow-currency-red.vue +1 -1
  93. package/icons/avatar.vue +1 -1
  94. package/icons/bank.vue +5 -0
  95. package/icons/block.vue +1 -1
  96. package/icons/bookmark/bookmark-filled.vue +1 -1
  97. package/icons/bookmark/bookmark.vue +1 -1
  98. package/icons/browsers/browser-duck.vue +1 -1
  99. package/icons/browsers/browser-google.vue +7 -1
  100. package/icons/browsers/browser-yandex.vue +1 -1
  101. package/icons/building-vector.vue +1 -1
  102. package/icons/calculator.vue +1 -1
  103. package/icons/calendar.vue +1 -1
  104. package/icons/car.vue +1 -1
  105. package/icons/chart-bar.vue +5 -0
  106. package/icons/chart-pie.vue +16 -0
  107. package/icons/check/check-circle.vue +1 -1
  108. package/icons/check/check.vue +1 -1
  109. package/icons/check/checkmark-circle.vue +1 -1
  110. package/icons/check-sb.vue +7 -0
  111. package/icons/checkbox/checkbox-active.vue +1 -1
  112. package/icons/checkbox/checkbox-empty.vue +1 -1
  113. package/icons/checkbox/checkbox-intermediate.vue +1 -1
  114. package/icons/chevron/chevron-down.vue +1 -1
  115. package/icons/chevron/chevron-left.vue +1 -1
  116. package/icons/chevron/chevron-right.vue +1 -1
  117. package/icons/chevron/chevron-up.vue +1 -1
  118. package/icons/chevron/double-chevron-right.vue +1 -1
  119. package/icons/clipboard-text.vue +1 -1
  120. package/icons/clock.vue +1 -1
  121. package/icons/company/company-bazis.vue +3 -3
  122. package/icons/company/company-bereke.vue +13 -13
  123. package/icons/company/company-bigroup.vue +5 -5
  124. package/icons/company/company-erg.vue +6 -6
  125. package/icons/company/company-forte.vue +11 -11
  126. package/icons/company/company-halyk.vue +4 -4
  127. package/icons/company/company-jusan.vue +20 -3
  128. package/icons/company/company-kaspi.vue +3 -3
  129. package/icons/company/company-mycar.vue +2 -2
  130. package/icons/company/company-samruk.vue +9 -9
  131. package/icons/company-egov-small.vue +1 -1
  132. package/icons/company.vue +1 -1
  133. package/icons/copy.vue +1 -1
  134. package/icons/currency/currency-dollar.vue +1 -1
  135. package/icons/currency/currency-down.vue +1 -1
  136. package/icons/currency/currency-eur.vue +1 -1
  137. package/icons/currency/currency-rub.vue +1 -1
  138. package/icons/currency/currency-tenge.vue +9 -0
  139. package/icons/currency/currency-usd.vue +1 -1
  140. package/icons/currency/currency-yuan.vue +1 -1
  141. package/icons/delete.vue +1 -1
  142. package/icons/document.vue +1 -1
  143. package/icons/download.vue +1 -1
  144. package/icons/edit.vue +1 -1
  145. package/icons/education.vue +1 -1
  146. package/icons/egov-small.vue +1 -1
  147. package/icons/excel-icon.vue +14 -0
  148. package/icons/expand-window.vue +1 -1
  149. package/icons/eye-closed.vue +1 -1
  150. package/icons/eye-open.vue +1 -1
  151. package/icons/eye-opened.vue +1 -1
  152. package/icons/file/file.vue +1 -1
  153. package/icons/filter.vue +1 -1
  154. package/icons/flag.vue +1 -1
  155. package/icons/gift.vue +1 -1
  156. package/icons/globe.vue +1 -1
  157. package/icons/google.vue +41 -0
  158. package/icons/hand/hand-thumb-up-filled.vue +1 -1
  159. package/icons/hand/hand-thumb-up.vue +1 -1
  160. package/icons/hand-with-phone/hand-with-phone-dark.vue +1 -1
  161. package/icons/hand-with-phone/hand-with-phone-light.vue +1 -1
  162. package/icons/handshake.vue +1 -1
  163. package/icons/hcheck.vue +1 -1
  164. package/icons/hdocument.vue +1 -1
  165. package/icons/history.vue +1 -1
  166. package/icons/horizontal-more.vue +1 -1
  167. package/icons/hot-line.vue +6 -0
  168. package/icons/hummer.vue +1 -1
  169. package/icons/info/info-circle.vue +1 -1
  170. package/icons/invoice.vue +1 -1
  171. package/icons/kaspi-qr.vue +13 -0
  172. package/icons/link-chain.vue +1 -1
  173. package/icons/link.vue +1 -1
  174. package/icons/linkedin.vue +24 -24
  175. package/icons/loader-circle.vue +1 -1
  176. package/icons/location.vue +1 -1
  177. package/icons/lock.vue +1 -1
  178. package/icons/logo.vue +1 -1
  179. package/icons/logout.vue +1 -1
  180. package/icons/magnify/magnifying-glass-minus.vue +1 -1
  181. package/icons/magnify/magnifying-glass-plus.vue +1 -1
  182. package/icons/magnify/magnifying-glass.vue +1 -1
  183. package/icons/mail.vue +1 -1
  184. package/icons/mailru.vue +34 -0
  185. package/icons/main-filter.vue +1 -1
  186. package/icons/map/map-pin-filled.vue +1 -1
  187. package/icons/map/map-pin-rect.vue +1 -1
  188. package/icons/map/map-pin.vue +1 -1
  189. package/icons/map-marker-start.vue +1 -1
  190. package/icons/medal.vue +1 -1
  191. package/icons/menu-filled.vue +1 -1
  192. package/icons/menu.vue +1 -1
  193. package/icons/message/message.vue +1 -1
  194. package/icons/minus/minus-circle.vue +1 -1
  195. package/icons/money.vue +1 -1
  196. package/icons/monitoring.vue +1 -1
  197. package/icons/moon.vue +1 -1
  198. package/icons/more.vue +1 -1
  199. package/icons/notification.vue +1 -1
  200. package/icons/paperclip.vue +1 -1
  201. package/icons/payment/payment-card.vue +1 -1
  202. package/icons/payment/payment-kaspi.vue +1 -1
  203. package/icons/person-vector.vue +1 -1
  204. package/icons/person-with-briefcase.vue +1 -1
  205. package/icons/phone-filled.vue +1 -1
  206. package/icons/phone.vue +1 -1
  207. package/icons/plus/plus-circle.vue +1 -1
  208. package/icons/plus/plus.vue +1 -1
  209. package/icons/profile.vue +1 -1
  210. package/icons/radio/radio-check.vue +1 -1
  211. package/icons/radio/radio-empty.vue +1 -1
  212. package/icons/receipt.vue +1 -1
  213. package/icons/sanctions.vue +8 -0
  214. package/icons/scales/scale.vue +1 -1
  215. package/icons/scales/scales.vue +1 -1
  216. package/icons/scales/standing-scales.vue +1 -1
  217. package/icons/search.vue +1 -1
  218. package/icons/share/share-alt.vue +1 -1
  219. package/icons/share/share.vue +1 -1
  220. package/icons/socials/face-book.vue +1 -1
  221. package/icons/socials/instagram.vue +1 -1
  222. package/icons/socials/telegram.vue +1 -1
  223. package/icons/socials/tik-tok.vue +1 -1
  224. package/icons/socials/youtube.vue +1 -1
  225. package/icons/sort/sort-asc.vue +1 -1
  226. package/icons/sort/sort-desc.vue +1 -1
  227. package/icons/splitting-arrows.vue +1 -1
  228. package/icons/star/star-filled.vue +1 -1
  229. package/icons/star/star-half-filled.vue +1 -1
  230. package/icons/star/star.vue +1 -1
  231. package/icons/sun.vue +14 -14
  232. package/icons/sviazi.vue +1 -1
  233. package/icons/tag.vue +1 -1
  234. package/icons/tasks.vue +10 -0
  235. package/icons/tender-search.vue +1 -1
  236. package/icons/toasts/check-circle-toast.vue +1 -1
  237. package/icons/toasts/warning-triangle-toast.vue +1 -1
  238. package/icons/trash.vue +1 -1
  239. package/icons/triangle.vue +1 -1
  240. package/icons/truck.vue +1 -1
  241. package/icons/user.vue +1 -1
  242. package/icons/users-focus.vue +1 -1
  243. package/icons/users.vue +1 -1
  244. package/icons/warning/warning-circle.vue +1 -1
  245. package/icons/warning/warning-triangle-filled.vue +1 -1
  246. package/icons/warning/warning-triangle.vue +1 -1
  247. package/icons/whatsapp.vue +1 -1
  248. package/icons/work-bag.vue +1 -1
  249. package/icons/work-case.vue +9 -0
  250. package/icons/work-search.vue +1 -1
  251. package/icons/work.vue +1 -1
  252. package/icons/x-mark.vue +1 -1
  253. package/icons/yandex.vue +28 -0
  254. package/illustrations/address-location.vue +1 -1
  255. package/illustrations/ball-with-chain.vue +1 -1
  256. package/illustrations/bill.vue +1 -1
  257. package/illustrations/buildings.vue +1 -1
  258. package/illustrations/calendar.vue +1 -1
  259. package/illustrations/chains.vue +1 -1
  260. package/illustrations/coin-percent.vue +1 -1
  261. package/illustrations/coins-stack.vue +1 -1
  262. package/illustrations/delete-dark.vue +1 -1
  263. package/illustrations/delete.vue +1 -1
  264. package/illustrations/doc-with-stamp.vue +1 -1
  265. package/illustrations/document.vue +1 -1
  266. package/illustrations/door.vue +1 -1
  267. package/illustrations/empty-box.vue +1 -1
  268. package/illustrations/empty-wallet.vue +1 -1
  269. package/illustrations/graph-in-coin.vue +1 -1
  270. package/illustrations/hammer.vue +1 -1
  271. package/illustrations/hand-cash.vue +1 -1
  272. package/illustrations/info.vue +1 -1
  273. package/illustrations/mail.vue +1 -1
  274. package/illustrations/ok.vue +1 -1
  275. package/illustrations/people-group.vue +1 -1
  276. package/illustrations/person-with-phone.vue +1 -1
  277. package/illustrations/person.vue +1 -1
  278. package/illustrations/phone-check.vue +1 -1
  279. package/illustrations/phone-payment-method.vue +1 -1
  280. package/illustrations/stop-hand.vue +1 -1
  281. package/illustrations/stop-sign.vue +1 -1
  282. package/illustrations/suit.vue +1 -1
  283. package/illustrations/suitcase.vue +1 -1
  284. package/illustrations/terminal-dark.vue +1 -1
  285. package/illustrations/terminal.vue +1 -1
  286. package/illustrations/trash-can.vue +1 -1
  287. package/illustrations/turn-on-tariff.vue +1 -1
  288. package/illustrations/two-persons.vue +1 -1
  289. package/lang/en.ts +475 -270
  290. package/lang/kk.ts +476 -271
  291. package/lang/ru.ts +315 -107
  292. package/layouts/default.vue +13 -13
  293. package/nuxt.config.ts +42 -14
  294. package/package.json +69 -53
  295. package/public/kaspi/logo.svg +4 -0
  296. package/shared/constans/pages.ts +17 -2
  297. package/tailwind.config.ts +163 -0
  298. package/vitest.config.ts +14 -0
  299. package/.eslintrc.cjs +0 -4
  300. package/.playground/app.vue +0 -9
  301. package/.playground/pages/index.vue +0 -13
  302. package/.prettierignore +0 -24
  303. package/.prettierrc +0 -10
  304. package/assets/styles/index.css +0 -226
  305. package/components/modals/AuthModal.vue +0 -50
  306. package/components/navigation/footer/NewFooter.vue +0 -276
  307. package/components/navigation/footer/ui/footer-acccordion.vue +0 -119
@@ -0,0 +1,78 @@
1
+ <script setup lang="ts">
2
+ import { useUrls } from '#adata-ui/composables/useUrls'
3
+
4
+ const emit = defineEmits<{
5
+ (e: 'close'): void
6
+ }>()
7
+ const { t } = useI18n()
8
+ const isOpen = useAuthModal()
9
+ const { myLayer } = useAppConfig()
10
+ const { login } = useUrls()
11
+
12
+ const { loginModal, registrationModal } = useIdModals()
13
+
14
+ function goAuth() {
15
+ if (myLayer.authMode !== 'local') {
16
+ if (window) {
17
+ let fullPath = encodeURIComponent(window.location.toString())
18
+ if (fullPath.includes('basic-info')) {
19
+ fullPath = fullPath.replace('%2Fcounterparty%2Fmain', '').replace('%2Fbasic-info', '')
20
+ }
21
+ window.location.href = `${login}?url=${fullPath}`
22
+ }
23
+ }
24
+ else {
25
+ isOpen.value = false
26
+ loginModal.value = true
27
+ }
28
+ }
29
+
30
+ function goRegister() {
31
+ if (myLayer.authMode !== 'local') {
32
+ if (window) {
33
+ let fullPath = encodeURIComponent(window.location.toString())
34
+ if (fullPath.includes('basic-info')) {
35
+ fullPath = fullPath.replace('%2Fcounterparty%2Fmain', '').replace('%2Fbasic-info', '')
36
+ }
37
+ window.location.href = `${login}register?url=${fullPath}`
38
+ }
39
+ }
40
+ else {
41
+ isOpen.value = false
42
+ registrationModal.value = true
43
+ }
44
+ }
45
+ </script>
46
+
47
+ <template>
48
+ <a-modal v-model="isOpen" :title="t('modals.auth.title')">
49
+ <div class="flex flex-col items-center gap-5 text-center text-sm">
50
+ <a-ill-door />
51
+ <div>{{ t('modals.auth.content') }}</div>
52
+ <a-button
53
+ block
54
+ variant="success"
55
+ @click="goAuth"
56
+ >
57
+ {{ t('modals.buttons.logIn') }}
58
+ </a-button>
59
+ <div>{{ t('modals.auth.firstTime') }}</div>
60
+ </div>
61
+ <template #footer>
62
+ <div class="flex gap-2">
63
+ <a-button
64
+ view="outline"
65
+ block
66
+ @click="emit('close')"
67
+ >
68
+ {{ t('modals.buttons.close') }}
69
+ </a-button>
70
+ <a-button block @click="goRegister">
71
+ {{ t('modals.buttons.register') }}
72
+ </a-button>
73
+ </div>
74
+ </template>
75
+ </a-modal>
76
+ </template>
77
+
78
+ <style scoped></style>
@@ -0,0 +1,45 @@
1
+ <script setup lang="ts">
2
+ const emit = defineEmits<{
3
+ (e: 'closed', value: boolean): void
4
+ }>()
5
+
6
+ const { t } = useI18n()
7
+
8
+ const { loginModal, autoLogoutModal } = useIdModals()
9
+
10
+ function onLogin() {
11
+ autoLogoutModal.value = false
12
+ loginModal.value = true
13
+ }
14
+
15
+ function onClose() {
16
+ emit('closed', true)
17
+ }
18
+ </script>
19
+
20
+ <template>
21
+ <div class="flex flex-col items-center gap-4 text-center">
22
+ <h2 class="text-2xl font-bold">
23
+ {{ t('modals.id.autoLogout.title') }}
24
+ </h2>
25
+ <a-ill-info class="size-[120px]" />
26
+ <p class="text-sm">
27
+ {{ t('modals.id.autoLogout.content') }}
28
+ </p>
29
+ <div class="flex w-full gap-2">
30
+ <a-button block view="outline" @click="onClose">
31
+ {{ t('actions.close') }}
32
+ </a-button>
33
+ <a-button
34
+ block
35
+ @click="onLogin"
36
+ >
37
+ {{ t('actions.login') }}
38
+ </a-button>
39
+ </div>
40
+ </div>
41
+ </template>
42
+
43
+ <style scoped>
44
+
45
+ </style>
@@ -0,0 +1,58 @@
1
+ <script setup lang="ts">
2
+ const { t } = useI18n()
3
+
4
+ const { registrationModal } = useIdModals()
5
+
6
+ function onRegister() {
7
+ registrationModal.value = true
8
+ }
9
+ </script>
10
+
11
+ <template>
12
+ <div class="gradient flex justify-between rounded-lg p-4 ring-1 ring-inset ring-blue-700/80 dark:bg-gray-800">
13
+ <div>
14
+ <p class="mb-2 font-semibold">
15
+ {{ t('modals.id.banners.auth.title') }}
16
+ </p>
17
+ <i18n-t
18
+ keypath="modals.id.banners.auth.subtitle"
19
+ tag="p"
20
+ class="text-sm text-gray-600 dark:text-gray-200"
21
+ >
22
+ <template #register>
23
+ <button class="font-semibold text-blue-700 dark:text-blue-500" @click="onRegister">
24
+ {{ t('modals.id.banners.auth.register') }}
25
+ </button>
26
+ </template>
27
+ </i18n-t>
28
+ </div>
29
+
30
+ <a-button
31
+ size="md"
32
+ class="self-end"
33
+ @click="onRegister"
34
+ >
35
+ {{ t('actions.register') }}
36
+ </a-button>
37
+ </div>
38
+ </template>
39
+
40
+ <style scoped>
41
+ .gradient {
42
+ background: linear-gradient(
43
+ 239.71deg,
44
+ #B3D5F9 -7.48%,
45
+ #E6F1FD 39.62%,
46
+ #CCE2FB 85.82%
47
+ );
48
+ }
49
+
50
+ .dark .gradient {
51
+ background: linear-gradient(
52
+ 239.71deg,
53
+ #17303F -7.48%,
54
+ #161617 39.62%,
55
+ #17303F 85.82%
56
+ );
57
+ }
58
+ </style>
@@ -0,0 +1,186 @@
1
+ <script setup lang="ts">
2
+ import { removeTrailingSlash } from '#adata-ui/components/utils/removeTrailingSlash'
3
+ import IdOtpInput from '#adata-ui/components/modals/id/IdOtpInput.vue'
4
+
5
+ const { $toast } = useNuxtApp()
6
+ const { t, locale } = useI18n()
7
+ const { commonAuth } = useAppConfig()
8
+
9
+ const { confirmAccountOtpModal, confirmSuccessfulModal, intermediateState } = useIdModals()
10
+
11
+ const authApiURL = commonAuth.authApiURL
12
+
13
+ const otp = ref(['', '', '', '', '', ''])
14
+ const otpFormatted = computed(() => {
15
+ return otp.value.join('')
16
+ })
17
+ const showError = ref(false)
18
+ const isLoading = ref(false)
19
+
20
+ async function loginUser() {
21
+ const login = await fetch(`${removeTrailingSlash(authApiURL)}/login`, {
22
+ method: 'POST',
23
+ credentials: 'include',
24
+ headers: {
25
+ 'Content-Type': 'application/json',
26
+ 'lang': locale.value,
27
+ },
28
+ body: JSON.stringify({
29
+ username: intermediateState.value.email,
30
+ password: intermediateState.value.password,
31
+ }),
32
+ })
33
+ await login.json().catch(() => ({}))
34
+
35
+ const response = await fetch(`${removeTrailingSlash(authApiURL)}/access/cookie`, {
36
+ method: 'GET',
37
+ credentials: 'include',
38
+ headers: {
39
+ lang: locale.value,
40
+ },
41
+ })
42
+ const { data: cookiesData } = await response.json()
43
+ if (cookiesData) {
44
+ const { access_token, expire_in } = cookiesData
45
+ const hostname = location.hostname.split('.').reverse()
46
+ useCookie('autoLogout').value = true
47
+
48
+ useCookie('accessToken', {
49
+ maxAge: expire_in,
50
+ domain: `.${hostname[1]}.${hostname[0]}`,
51
+ path: '/',
52
+ secure: true,
53
+ }).value = access_token
54
+ }
55
+ }
56
+
57
+ async function onConfirm() {
58
+ try {
59
+ isLoading.value = true
60
+
61
+ await $fetch(`${removeTrailingSlash(authApiURL)}/email/verify-otp`, {
62
+ method: 'GET',
63
+ credentials: 'include',
64
+ headers: {
65
+ lang: locale.value,
66
+ },
67
+ params: {
68
+ email: intermediateState.value.email,
69
+ otp_code: otpFormatted.value,
70
+ },
71
+ })
72
+
73
+ await loginUser()
74
+
75
+ confirmAccountOtpModal.value = false
76
+ confirmSuccessfulModal.value = true
77
+ }
78
+ catch (error) {
79
+ showError.value = true
80
+ }
81
+ finally {
82
+ isLoading.value = false
83
+ }
84
+ }
85
+
86
+ function resetOtp() {
87
+ otp.value = ['', '', '', '', '', '']
88
+ showError.value = false
89
+ }
90
+
91
+ function onClose() {
92
+ resetOtp()
93
+ confirmAccountOtpModal.value = false
94
+ }
95
+
96
+ const isResendLoading = ref(false)
97
+ async function onResend() {
98
+ try {
99
+ isResendLoading.value = true
100
+ await $fetch(`${removeTrailingSlash(authApiURL)}/email/resend-otp`, {
101
+ method: 'GET',
102
+ credentials: 'include',
103
+ headers: {
104
+ lang: locale.value,
105
+ },
106
+ params: {
107
+ email: intermediateState.value.email,
108
+ },
109
+ })
110
+ resetOtp()
111
+ runTimer()
112
+ isResendLoading.value = false
113
+ }
114
+ catch (error) {
115
+ $toast.error(error.data)
116
+ }
117
+ }
118
+
119
+ const timer = ref(60)
120
+
121
+ function runTimer() {
122
+ timer.value = 60
123
+ const intervalId = setInterval(() => {
124
+ if (!timer.value) clearInterval(intervalId)
125
+ return timer.value--
126
+ }, 1000)
127
+ }
128
+
129
+ function handleEnter(e: KeyboardEvent) {
130
+ if (e.key === 'Enter') {
131
+ onConfirm()
132
+ }
133
+ }
134
+
135
+ onMounted(() => {
136
+ runTimer()
137
+ document.addEventListener('keyup', handleEnter)
138
+ })
139
+
140
+ onBeforeUnmount(() => {
141
+ document.removeEventListener('keyup', handleEnter)
142
+ })
143
+ </script>
144
+
145
+ <template>
146
+ <div class="flex flex-col items-center gap-4 text-center">
147
+ <h2 class="text-2xl font-bold">
148
+ {{ t('modals.id.confirmAccount.title') }}
149
+ </h2>
150
+
151
+ <a-icon-hand-with-phone-light class="size-32 dark:hidden" />
152
+ <a-icon-hand-with-phone-dark class="hidden size-32 dark:block" />
153
+
154
+ <div class="text-sm">
155
+ <p class="mb-1">
156
+ {{ t('modals.id.resetPasswordOtp.content') }}
157
+ </p>
158
+
159
+ <div v-if="timer > 0" class="text-2xl font-bold">
160
+ {{ timer }} {{ t('modals.id.resetPasswordOtp.seconds') }}
161
+ </div>
162
+ <button
163
+ v-else
164
+ class="text-blue-700 dark:text-blue-500"
165
+ :disabled="isResendLoading"
166
+ @click="onResend"
167
+ >
168
+ {{ t('actions.resend') }}
169
+ </button>
170
+ </div>
171
+
172
+ <id-otp-input
173
+ v-model="otp"
174
+ v-model:error="showError"
175
+ @on-completed="onConfirm"
176
+ />
177
+
178
+ <a-button
179
+ block
180
+ view="outline"
181
+ @click="onClose"
182
+ >
183
+ {{ t('actions.close') }}
184
+ </a-button>
185
+ </div>
186
+ </template>
@@ -0,0 +1,41 @@
1
+ <script setup lang="ts">
2
+ import { useUrls } from '#adata-ui/composables/useUrls'
3
+
4
+ const { t } = useI18n()
5
+ const { confirmSuccessfulModal } = useIdModals()
6
+ const regex = /^\/counterparty\/main\/company\/\d+\/basic-info$/;
7
+ const { pk } = useUrls()
8
+
9
+ function onClose() {
10
+ confirmSuccessfulModal.value = false
11
+
12
+ const path = window.location.pathname;
13
+
14
+ if (regex.test(path)) {
15
+ navigateTo(`${pk}/${path.split("/")[4]}`, { external: true })
16
+ } else {
17
+ window.location.reload()
18
+ }
19
+ }
20
+ </script>
21
+
22
+ <template>
23
+ <div class="flex flex-col gap-4 text-center">
24
+ <h2 class="text-2xl font-bold">
25
+ {{ t('modals.id.confirmSuccessful.title') }}
26
+ </h2>
27
+ <span class="mx-auto size-[100px] rounded-full bg-[#BDC7CE26]">
28
+ <a-ill-ok />
29
+ </span>
30
+ <p class="text-sm">
31
+ {{ t('modals.id.confirmSuccessful.content') }}
32
+ </p>
33
+ <a-button view="outline" @click="onClose">
34
+ {{ t('actions.close') }}
35
+ </a-button>
36
+ </div>
37
+ </template>
38
+
39
+ <style scoped>
40
+
41
+ </style>