@mesob/auth-react 0.4.0 → 0.4.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.
- package/dist/chunk-35TCGAW3.js +98 -0
- package/dist/chunk-35TCGAW3.js.map +1 -0
- package/dist/chunk-3BZC4VVD.js +36 -0
- package/dist/chunk-3BZC4VVD.js.map +1 -0
- package/dist/chunk-45UCLKH2.js +188 -0
- package/dist/chunk-45UCLKH2.js.map +1 -0
- package/dist/chunk-55BMNC4S.js +115 -0
- package/dist/chunk-55BMNC4S.js.map +1 -0
- package/dist/chunk-5F5FZMHE.js +94 -0
- package/dist/chunk-5F5FZMHE.js.map +1 -0
- package/dist/chunk-5M7I7WNH.js +31 -0
- package/dist/chunk-5M7I7WNH.js.map +1 -0
- package/dist/chunk-72YRO3A7.js +288 -0
- package/dist/chunk-72YRO3A7.js.map +1 -0
- package/dist/chunk-7KXTL6NT.js +48 -0
- package/dist/chunk-7KXTL6NT.js.map +1 -0
- package/dist/chunk-AIMD6R6U.js +466 -0
- package/dist/chunk-AIMD6R6U.js.map +1 -0
- package/dist/chunk-BGSHXIHI.js +953 -0
- package/dist/chunk-BGSHXIHI.js.map +1 -0
- package/dist/chunk-BZ42QPXE.js +271 -0
- package/dist/chunk-BZ42QPXE.js.map +1 -0
- package/dist/chunk-C26NPUPI.js +272 -0
- package/dist/chunk-C26NPUPI.js.map +1 -0
- package/dist/chunk-C2KFZ57H.js +194 -0
- package/dist/chunk-C2KFZ57H.js.map +1 -0
- package/dist/chunk-C5ZW7FD2.js +46 -0
- package/dist/chunk-C5ZW7FD2.js.map +1 -0
- package/dist/chunk-DPH2PHK3.js +32 -0
- package/dist/chunk-DPH2PHK3.js.map +1 -0
- package/dist/chunk-EQ4346FE.js +139 -0
- package/dist/chunk-EQ4346FE.js.map +1 -0
- package/dist/chunk-FAHN63DA.js +535 -0
- package/dist/chunk-FAHN63DA.js.map +1 -0
- package/dist/chunk-FFR5UHTS.js +99 -0
- package/dist/chunk-FFR5UHTS.js.map +1 -0
- package/dist/chunk-FHOLUOOZ.js +164 -0
- package/dist/chunk-FHOLUOOZ.js.map +1 -0
- package/dist/chunk-G2AW2H36.js +11 -0
- package/dist/chunk-G2AW2H36.js.map +1 -0
- package/dist/chunk-G7SCXCCM.js +89 -0
- package/dist/chunk-G7SCXCCM.js.map +1 -0
- package/dist/chunk-GP7GIUI3.js +64 -0
- package/dist/chunk-GP7GIUI3.js.map +1 -0
- package/dist/chunk-GRT6EBR6.js +93 -0
- package/dist/chunk-GRT6EBR6.js.map +1 -0
- package/dist/chunk-GXKBVCVS.js +102 -0
- package/dist/chunk-GXKBVCVS.js.map +1 -0
- package/dist/chunk-HB2RZTHS.js +338 -0
- package/dist/chunk-HB2RZTHS.js.map +1 -0
- package/dist/chunk-HOO2VLNM.js +305 -0
- package/dist/chunk-HOO2VLNM.js.map +1 -0
- package/dist/chunk-II5MLBSB.js +183 -0
- package/dist/chunk-II5MLBSB.js.map +1 -0
- package/dist/chunk-ISNNPMF7.js +95 -0
- package/dist/chunk-ISNNPMF7.js.map +1 -0
- package/dist/chunk-JB6XVST4.js +141 -0
- package/dist/chunk-JB6XVST4.js.map +1 -0
- package/dist/chunk-JUHBVG5Q.js +303 -0
- package/dist/chunk-JUHBVG5Q.js.map +1 -0
- package/dist/chunk-JZZJCBAE.js +118 -0
- package/dist/chunk-JZZJCBAE.js.map +1 -0
- package/dist/chunk-KWG4DSB5.js +55 -0
- package/dist/chunk-KWG4DSB5.js.map +1 -0
- package/dist/chunk-L4CGIO2I.js +265 -0
- package/dist/chunk-L4CGIO2I.js.map +1 -0
- package/dist/chunk-LNG736CV.js +19 -0
- package/dist/chunk-LNG736CV.js.map +1 -0
- package/dist/chunk-LSYKVFJA.js +98 -0
- package/dist/chunk-LSYKVFJA.js.map +1 -0
- package/dist/chunk-LZR4YUDV.js +107 -0
- package/dist/chunk-LZR4YUDV.js.map +1 -0
- package/dist/chunk-MELNS4QH.js +255 -0
- package/dist/chunk-MELNS4QH.js.map +1 -0
- package/dist/chunk-MS2JUZ3N.js +94 -0
- package/dist/chunk-MS2JUZ3N.js.map +1 -0
- package/dist/chunk-NEO72TMH.js +32 -0
- package/dist/chunk-NEO72TMH.js.map +1 -0
- package/dist/chunk-NJPNTAAT.js +68 -0
- package/dist/chunk-NJPNTAAT.js.map +1 -0
- package/dist/chunk-NPW7D2HZ.js +16 -0
- package/dist/chunk-NPW7D2HZ.js.map +1 -0
- package/dist/chunk-OAN4EXU4.js +310 -0
- package/dist/chunk-OAN4EXU4.js.map +1 -0
- package/dist/chunk-OFLSINVU.js +138 -0
- package/dist/chunk-OFLSINVU.js.map +1 -0
- package/dist/chunk-OHIIMUQC.js +286 -0
- package/dist/chunk-OHIIMUQC.js.map +1 -0
- package/dist/chunk-OQGJX37L.js +239 -0
- package/dist/chunk-OQGJX37L.js.map +1 -0
- package/dist/chunk-OYHH7HQG.js +65 -0
- package/dist/chunk-OYHH7HQG.js.map +1 -0
- package/dist/chunk-PSRIZMWJ.js +486 -0
- package/dist/chunk-PSRIZMWJ.js.map +1 -0
- package/dist/chunk-QNCE2B5O.js +23 -0
- package/dist/chunk-QNCE2B5O.js.map +1 -0
- package/dist/chunk-RLPZFLAS.js +23 -0
- package/dist/chunk-RLPZFLAS.js.map +1 -0
- package/dist/chunk-RT5C7IAE.js +38 -0
- package/dist/chunk-RT5C7IAE.js.map +1 -0
- package/dist/chunk-S3CXCCKL.js +272 -0
- package/dist/chunk-S3CXCCKL.js.map +1 -0
- package/dist/chunk-SOCZK4CV.js +69 -0
- package/dist/chunk-SOCZK4CV.js.map +1 -0
- package/dist/chunk-T6P7UHVP.js +34 -0
- package/dist/chunk-T6P7UHVP.js.map +1 -0
- package/dist/chunk-TFVBER3Y.js +52 -0
- package/dist/chunk-TFVBER3Y.js.map +1 -0
- package/dist/chunk-UXOZ2TME.js +104 -0
- package/dist/chunk-UXOZ2TME.js.map +1 -0
- package/dist/chunk-V2W3WPCZ.js +22 -0
- package/dist/chunk-V2W3WPCZ.js.map +1 -0
- package/dist/chunk-YZ264S2L.js +286 -0
- package/dist/chunk-YZ264S2L.js.map +1 -0
- package/dist/chunk-ZESFGO3K.js +28 -0
- package/dist/chunk-ZESFGO3K.js.map +1 -0
- package/dist/chunk-ZG6WFZHX.js +143 -0
- package/dist/chunk-ZG6WFZHX.js.map +1 -0
- package/dist/components/auth/auth-card.d.ts +3 -6
- package/dist/components/auth/auth-card.js +3 -7
- package/dist/components/auth/auth-card.js.map +1 -1
- package/dist/components/auth/auth-layout.d.ts +3 -6
- package/dist/components/auth/auth-layout.js +3 -28
- package/dist/components/auth/auth-layout.js.map +1 -1
- package/dist/components/auth/countdown.d.ts +2 -5
- package/dist/components/auth/countdown.js +5 -130
- package/dist/components/auth/countdown.js.map +1 -1
- package/dist/components/auth/forgot-password.d.ts +1 -5
- package/dist/components/auth/forgot-password.js +6 -365
- package/dist/components/auth/forgot-password.js.map +1 -1
- package/dist/components/auth/reset-password-form.d.ts +2 -5
- package/dist/components/auth/reset-password-form.js +6 -487
- package/dist/components/auth/reset-password-form.js.map +1 -1
- package/dist/components/auth/set-password.d.ts +2 -5
- package/dist/components/auth/set-password.js +7 -521
- package/dist/components/auth/set-password.js.map +1 -1
- package/dist/components/auth/sign-in.d.ts +2 -5
- package/dist/components/auth/sign-in.js +7 -561
- package/dist/components/auth/sign-in.js.map +1 -1
- package/dist/components/auth/sign-up.d.ts +2 -5
- package/dist/components/auth/sign-up.js +6 -511
- package/dist/components/auth/sign-up.js.map +1 -1
- package/dist/components/auth/verification-form.d.ts +13 -2
- package/dist/components/auth/verification-form.js +5 -217
- package/dist/components/auth/verification-form.js.map +1 -1
- package/dist/components/auth/verify-email.d.ts +2 -5
- package/dist/components/auth/verify-email.js +8 -527
- package/dist/components/auth/verify-email.js.map +1 -1
- package/dist/components/auth/verify-phone.d.ts +2 -5
- package/dist/components/auth/verify-phone.js +8 -532
- package/dist/components/auth/verify-phone.js.map +1 -1
- package/dist/components/authorization/deny.d.ts +3 -6
- package/dist/components/authorization/deny.js +4 -47
- package/dist/components/authorization/deny.js.map +1 -1
- package/dist/components/authorization/grant.d.ts +3 -6
- package/dist/components/authorization/grant.js +4 -52
- package/dist/components/authorization/grant.js.map +1 -1
- package/dist/components/error-boundary.d.ts +6 -10
- package/dist/components/error-boundary.js +4 -43
- package/dist/components/error-boundary.js.map +1 -1
- package/dist/components/iam/permission-selector.d.ts +3 -6
- package/dist/components/iam/permission-selector.js +3 -116
- package/dist/components/iam/permission-selector.js.map +1 -1
- package/dist/components/iam/permissions-page.d.ts +1 -0
- package/dist/components/iam/permissions-page.js +10 -0
- package/dist/components/iam/permissions-page.js.map +1 -0
- package/dist/components/iam/permissions.d.ts +1 -5
- package/dist/components/iam/permissions.js +5 -198
- package/dist/components/iam/permissions.js.map +1 -1
- package/dist/components/iam/role-detail-layout.d.ts +3 -6
- package/dist/components/iam/role-detail-layout.js +3 -131
- package/dist/components/iam/role-detail-layout.js.map +1 -1
- package/dist/components/iam/role-detail-page.d.ts +2 -5
- package/dist/components/iam/role-detail-page.js +3 -223
- package/dist/components/iam/role-detail-page.js.map +1 -1
- package/dist/components/iam/role-permissions-page.d.ts +2 -5
- package/dist/components/iam/role-permissions-page.js +4 -391
- package/dist/components/iam/role-permissions-page.js.map +1 -1
- package/dist/components/iam/roles-page.d.ts +1 -0
- package/dist/components/iam/roles-page.js +13 -0
- package/dist/components/iam/roles-page.js.map +1 -0
- package/dist/components/iam/roles.d.ts +1 -5
- package/dist/components/iam/roles.js +5 -218
- package/dist/components/iam/roles.js.map +1 -1
- package/dist/components/iam/sessions-page.d.ts +1 -0
- package/dist/components/iam/sessions-page.js +12 -0
- package/dist/components/iam/sessions-page.js.map +1 -0
- package/dist/components/iam/sessions.d.ts +1 -5
- package/dist/components/iam/sessions.js +5 -198
- package/dist/components/iam/sessions.js.map +1 -1
- package/dist/components/iam/tenants-page.d.ts +1 -0
- package/dist/components/iam/tenants-page.js +13 -0
- package/dist/components/iam/tenants-page.js.map +1 -0
- package/dist/components/iam/tenants.d.ts +1 -5
- package/dist/components/iam/tenants.js +5 -204
- package/dist/components/iam/tenants.js.map +1 -1
- package/dist/components/iam/users-page.d.ts +1 -0
- package/dist/components/iam/users-page.js +13 -0
- package/dist/components/iam/users-page.js.map +1 -0
- package/dist/components/iam/users.d.ts +1 -5
- package/dist/components/iam/users.js +5 -207
- package/dist/components/iam/users.js.map +1 -1
- package/dist/components/profile/account.d.ts +1 -5
- package/dist/components/profile/account.js +4 -151
- package/dist/components/profile/account.js.map +1 -1
- package/dist/components/profile/change-email-form.d.ts +1 -5
- package/dist/components/profile/change-email-form.js +9 -735
- package/dist/components/profile/change-email-form.js.map +1 -1
- package/dist/components/profile/change-password-form.d.ts +1 -5
- package/dist/components/profile/change-password-form.js +3 -262
- package/dist/components/profile/change-password-form.js.map +1 -1
- package/dist/components/profile/change-phone-form.d.ts +1 -5
- package/dist/components/profile/change-phone-form.js +10 -772
- package/dist/components/profile/change-phone-form.js.map +1 -1
- package/dist/components/profile/change-profile.d.ts +3 -7
- package/dist/components/profile/change-profile.js +2 -40
- package/dist/components/profile/change-profile.js.map +1 -1
- package/dist/components/profile/otp-verification-modal.d.ts +2 -5
- package/dist/components/profile/otp-verification-modal.js +6 -266
- package/dist/components/profile/otp-verification-modal.js.map +1 -1
- package/dist/components/profile/profile-layout.d.ts +4 -0
- package/dist/components/profile/profile-layout.js +10 -0
- package/dist/components/profile/profile-layout.js.map +1 -0
- package/dist/components/profile/request-change-email-form.d.ts +2 -5
- package/dist/components/profile/request-change-email-form.js +4 -285
- package/dist/components/profile/request-change-email-form.js.map +1 -1
- package/dist/components/profile/request-change-phone-form.d.ts +2 -5
- package/dist/components/profile/request-change-phone-form.js +5 -323
- package/dist/components/profile/request-change-phone-form.js.map +1 -1
- package/dist/components/profile/security.d.ts +1 -5
- package/dist/components/profile/security.js +15 -1508
- package/dist/components/profile/security.js.map +1 -1
- package/dist/components/profile/verify-change-email-form.d.ts +2 -5
- package/dist/components/profile/verify-change-email-form.js +7 -407
- package/dist/components/profile/verify-change-email-form.js.map +1 -1
- package/dist/components/profile/verify-change-phone-form.d.ts +2 -5
- package/dist/components/profile/verify-change-phone-form.js +7 -411
- package/dist/components/profile/verify-change-phone-form.js.map +1 -1
- package/dist/components/shared/data-table.d.ts +5 -8
- package/dist/components/shared/data-table.js +3 -79
- package/dist/components/shared/data-table.js.map +1 -1
- package/dist/components/skeletons/auth-form-skeleton.d.ts +1 -5
- package/dist/components/skeletons/auth-form-skeleton.js +3 -27
- package/dist/components/skeletons/auth-form-skeleton.js.map +1 -1
- package/dist/components/skeletons/profile-skeleton.d.ts +1 -5
- package/dist/components/skeletons/profile-skeleton.js +3 -28
- package/dist/components/skeletons/profile-skeleton.js.map +1 -1
- package/dist/components/skeletons/table-skeleton.d.ts +2 -5
- package/dist/components/skeletons/table-skeleton.js +3 -34
- package/dist/components/skeletons/table-skeleton.js.map +1 -1
- package/dist/constants/auth.error.codes.d.ts +5 -0
- package/dist/hooks/use-session-cookie-name.d.ts +1 -0
- package/dist/hooks/use-translator.d.ts +1 -0
- package/dist/index.d.ts +50 -92
- package/dist/index.js +147 -4936
- package/dist/index.js.map +1 -1
- package/dist/lib/query-options.d.ts +10 -0
- package/dist/lib/translations.d.ts +3 -0
- package/dist/pages/auth/forgot-password.d.ts +3 -7
- package/dist/pages/auth/forgot-password.js +8 -770
- package/dist/pages/auth/forgot-password.js.map +1 -1
- package/dist/pages/auth/layout.d.ts +3 -7
- package/dist/pages/auth/layout.js +13 -536
- package/dist/pages/auth/layout.js.map +1 -1
- package/dist/pages/auth/reset-password.d.ts +4 -7
- package/dist/pages/auth/reset-password.js +8 -888
- package/dist/pages/auth/reset-password.js.map +1 -1
- package/dist/pages/auth/set-password.d.ts +4 -7
- package/dist/pages/auth/set-password.js +9 -927
- package/dist/pages/auth/set-password.js.map +1 -1
- package/dist/pages/auth/sign-in.d.ts +4 -7
- package/dist/pages/auth/sign-in.js +9 -967
- package/dist/pages/auth/sign-in.js.map +1 -1
- package/dist/pages/auth/sign-up.d.ts +4 -7
- package/dist/pages/auth/sign-up.js +8 -915
- package/dist/pages/auth/sign-up.js.map +1 -1
- package/dist/pages/auth/verify-email.d.ts +4 -7
- package/dist/pages/auth/verify-email.js +10 -922
- package/dist/pages/auth/verify-email.js.map +1 -1
- package/dist/pages/auth/verify-phone.d.ts +4 -7
- package/dist/pages/auth/verify-phone.js +10 -927
- package/dist/pages/auth/verify-phone.js.map +1 -1
- package/dist/pages/iam/permissions/_components/permission-card.d.ts +6 -0
- package/dist/pages/iam/permissions/_components/permissions-data.d.ts +7 -0
- package/dist/pages/iam/permissions/_components/permissions-list.d.ts +14 -0
- package/dist/pages/iam/permissions.d.ts +1 -5
- package/dist/pages/iam/permissions.js +4 -302
- package/dist/pages/iam/permissions.js.map +1 -1
- package/dist/pages/iam/role-detail-layout.d.ts +3 -6
- package/dist/pages/iam/role-detail-layout.js +5 -132
- package/dist/pages/iam/role-detail-layout.js.map +1 -1
- package/dist/pages/iam/role-detail.d.ts +4 -7
- package/dist/pages/iam/role-detail.js +5 -224
- package/dist/pages/iam/role-detail.js.map +1 -1
- package/dist/pages/iam/role-permissions.d.ts +4 -7
- package/dist/pages/iam/role-permissions.js +6 -392
- package/dist/pages/iam/role-permissions.js.map +1 -1
- package/dist/pages/iam/role-users.d.ts +4 -7
- package/dist/pages/iam/role-users.js +9 -808
- package/dist/pages/iam/role-users.js.map +1 -1
- package/dist/pages/iam/roles/_components/role-card.d.ts +7 -0
- package/dist/pages/iam/roles/_components/role-form.d.ts +9 -0
- package/dist/pages/iam/roles/_components/role-selector.d.ts +11 -0
- package/dist/pages/iam/roles/_components/roles-data.d.ts +16 -0
- package/dist/pages/iam/roles/_components/roles-list.d.ts +15 -0
- package/dist/pages/iam/roles/users/_components/role-users-page.d.ts +5 -0
- package/dist/pages/iam/roles.d.ts +1 -5
- package/dist/pages/iam/roles.js +7 -678
- package/dist/pages/iam/roles.js.map +1 -1
- package/dist/pages/iam/sessions/_components/session-card.d.ts +6 -0
- package/dist/pages/iam/sessions/_components/sessions-data.d.ts +7 -0
- package/dist/pages/iam/sessions/_components/sessions-list.d.ts +14 -0
- package/dist/pages/iam/sessions.d.ts +1 -5
- package/dist/pages/iam/sessions.js +6 -309
- package/dist/pages/iam/sessions.js.map +1 -1
- package/dist/pages/iam/shared/navigation.d.ts +8 -0
- package/dist/pages/iam/shared/page-helpers.d.ts +12 -0
- package/dist/pages/iam/tenant-detail.d.ts +2 -5
- package/dist/pages/iam/tenant-detail.js +6 -174
- package/dist/pages/iam/tenant-detail.js.map +1 -1
- package/dist/pages/iam/tenants/_components/tenant-card.d.ts +6 -0
- package/dist/pages/iam/tenants/_components/tenant-form.d.ts +9 -0
- package/dist/pages/iam/tenants/_components/tenant-selector.d.ts +13 -0
- package/dist/pages/iam/tenants/_components/tenants-data.d.ts +12 -0
- package/dist/pages/iam/tenants/_components/tenants-list.d.ts +15 -0
- package/dist/pages/iam/tenants/tenant-detail-page-content.d.ts +5 -0
- package/dist/pages/iam/tenants.d.ts +1 -5
- package/dist/pages/iam/tenants.js +7 -604
- package/dist/pages/iam/tenants.js.map +1 -1
- package/dist/pages/iam/user-activity.d.ts +2 -5
- package/dist/pages/iam/user-activity.js +9 -838
- package/dist/pages/iam/user-activity.js.map +1 -1
- package/dist/pages/iam/user-detail-layout.d.ts +3 -6
- package/dist/pages/iam/user-detail-layout.js +5 -93
- package/dist/pages/iam/user-detail-layout.js.map +1 -1
- package/dist/pages/iam/user-detail.d.ts +2 -5
- package/dist/pages/iam/user-detail.js +5 -92
- package/dist/pages/iam/user-detail.js.map +1 -1
- package/dist/pages/iam/users/_components/bulk-invite-user-form.d.ts +6 -0
- package/dist/pages/iam/users/_components/invite-user-form.d.ts +6 -0
- package/dist/pages/iam/users/_components/invite-user-shared.d.ts +25 -0
- package/dist/pages/iam/users/_components/user-card.d.ts +6 -0
- package/dist/pages/iam/users/_components/user-detail-layout-content.d.ts +6 -0
- package/dist/pages/iam/users/_components/user-detail-page-content.d.ts +5 -0
- package/dist/pages/iam/users/_components/user-form.d.ts +9 -0
- package/dist/pages/iam/users/_components/user-selector.d.ts +12 -0
- package/dist/pages/iam/users/_components/users-data.d.ts +22 -0
- package/dist/pages/iam/users/_components/users-list.d.ts +15 -0
- package/dist/pages/iam/users/activity/_components/role-section.d.ts +3 -0
- package/dist/pages/iam/users/activity/user-activity-page-content.d.ts +5 -0
- package/dist/pages/iam/users.d.ts +1 -5
- package/dist/pages/iam/users.js +7 -1269
- package/dist/pages/iam/users.js.map +1 -1
- package/dist/pages/profile/_components/profile-sidebar.d.ts +1 -0
- package/dist/pages/profile/account.d.ts +1 -5
- package/dist/pages/profile/account.js +9 -158
- package/dist/pages/profile/account.js.map +1 -1
- package/dist/pages/profile/layout.d.ts +1 -8
- package/dist/pages/profile/layout.js +5 -128
- package/dist/pages/profile/layout.js.map +1 -1
- package/dist/pages/profile/security.d.ts +1 -5
- package/dist/pages/profile/security.js +20 -1515
- package/dist/pages/profile/security.js.map +1 -1
- package/dist/provider.d.ts +53 -0
- package/dist/{types-g9QcNRxT.d.ts → types.d.ts} +33 -12
- package/dist/utils/cookie.d.ts +2 -0
- package/dist/utils/custom-fetch.d.ts +2 -0
- package/dist/utils/handle-error.d.ts +7 -0
- package/dist/utils/normalize-phone.d.ts +1 -0
- package/package.json +4 -4
- package/dist/verification-form-ipSRTtQB.d.ts +0 -22
|
@@ -1,777 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
// src/components/profile/change-phone-form.tsx
|
|
4
2
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import
|
|
15
|
-
import { deepmerge } from "deepmerge-ts";
|
|
16
|
-
import createFetchClient from "openapi-fetch";
|
|
17
|
-
import createClient from "openapi-react-query";
|
|
18
|
-
import { createContext, useContext, useMemo, useState } from "react";
|
|
19
|
-
|
|
20
|
-
// src/lib/translations.ts
|
|
21
|
-
function createTranslator(messages, namespace) {
|
|
22
|
-
return (key, params) => {
|
|
23
|
-
const fullKey = namespace ? `${namespace}.${key}` : key;
|
|
24
|
-
const keys = fullKey.split(".");
|
|
25
|
-
let value = messages;
|
|
26
|
-
for (const k of keys) {
|
|
27
|
-
if (value && typeof value === "object" && value !== null) {
|
|
28
|
-
value = value[k];
|
|
29
|
-
} else {
|
|
30
|
-
return fullKey;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
if (typeof value !== "string") {
|
|
34
|
-
return fullKey;
|
|
35
|
-
}
|
|
36
|
-
if (params) {
|
|
37
|
-
return value.replace(
|
|
38
|
-
/\{(\w+)\}/g,
|
|
39
|
-
(_, param) => String(params[param] ?? `{${param}}`)
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
return value;
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// src/utils/cookie.ts
|
|
47
|
-
var isProduction = typeof process !== "undefined" && process.env.NODE_ENV === "production";
|
|
48
|
-
|
|
49
|
-
// src/provider.tsx
|
|
50
|
-
import { jsx } from "react/jsx-runtime";
|
|
51
|
-
var SessionContext = createContext(null);
|
|
52
|
-
var ApiContext = createContext(null);
|
|
53
|
-
var ConfigContext = createContext(null);
|
|
54
|
-
var queryClient = new QueryClient({
|
|
55
|
-
defaultOptions: {
|
|
56
|
-
queries: {
|
|
57
|
-
refetchOnWindowFocus: false
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
function useSession() {
|
|
62
|
-
const context = useContext(SessionContext);
|
|
63
|
-
if (!context) {
|
|
64
|
-
throw new Error("useSession must be used within MesobAuthProvider");
|
|
65
|
-
}
|
|
66
|
-
return context;
|
|
67
|
-
}
|
|
68
|
-
function useApi() {
|
|
69
|
-
const context = useContext(ApiContext);
|
|
70
|
-
if (!context) {
|
|
71
|
-
throw new Error("useApi must be used within MesobAuthProvider");
|
|
72
|
-
}
|
|
73
|
-
return context;
|
|
74
|
-
}
|
|
75
|
-
function useConfig() {
|
|
76
|
-
const context = useContext(ConfigContext);
|
|
77
|
-
if (!context) {
|
|
78
|
-
throw new Error("useConfig must be used within MesobAuthProvider");
|
|
79
|
-
}
|
|
80
|
-
return context;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// src/components/profile/request-change-phone-form.tsx
|
|
84
|
-
import { zodResolver } from "@hookform/resolvers/zod";
|
|
85
|
-
import { Button, Input, Label, Spinner } from "@mesob/ui/components";
|
|
86
|
-
import { IconEye, IconEyeOff } from "@tabler/icons-react";
|
|
87
|
-
import { useEffect, useState as useState2 } from "react";
|
|
88
|
-
import { useForm } from "react-hook-form";
|
|
89
|
-
import { toast } from "sonner";
|
|
90
|
-
import { z } from "zod";
|
|
91
|
-
|
|
92
|
-
// src/utils/normalize-phone.ts
|
|
93
|
-
function normalizePhone(phone) {
|
|
94
|
-
const cleaned = phone.trim().replace(/\s/g, "");
|
|
95
|
-
if (cleaned.startsWith("+2519") || cleaned.startsWith("+2517")) {
|
|
96
|
-
return cleaned;
|
|
97
|
-
}
|
|
98
|
-
if (cleaned.startsWith("2519") || cleaned.startsWith("2517")) {
|
|
99
|
-
return `+${cleaned}`;
|
|
100
|
-
}
|
|
101
|
-
if (cleaned.startsWith("09") || cleaned.startsWith("07")) {
|
|
102
|
-
return `+251${cleaned.slice(1)}`;
|
|
103
|
-
}
|
|
104
|
-
if ((cleaned.startsWith("9") || cleaned.startsWith("7")) && cleaned.length === 9) {
|
|
105
|
-
return `+251${cleaned}`;
|
|
106
|
-
}
|
|
107
|
-
return cleaned;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// src/components/profile/request-change-phone-form.tsx
|
|
111
|
-
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
112
|
-
var phonePasswordSchema = (phoneRegex) => z.object({
|
|
113
|
-
phone: z.string().trim().min(1, { message: "Phone number is required" }).refine(
|
|
114
|
-
(val) => {
|
|
115
|
-
const isPhone = phoneRegex.test(val);
|
|
116
|
-
return isPhone;
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
message: "Invalid phone number"
|
|
120
|
-
}
|
|
121
|
-
),
|
|
122
|
-
password: z.string().min(8, "Password must be at least 8 characters").max(128, "Password too long")
|
|
123
|
-
});
|
|
124
|
-
function isAuthError(error) {
|
|
125
|
-
return typeof error === "object" && error !== null && ("code" in error || "message" in error || "name" in error);
|
|
126
|
-
}
|
|
127
|
-
function getErrorCode(error) {
|
|
128
|
-
if (error.code) {
|
|
129
|
-
return error.code;
|
|
130
|
-
}
|
|
131
|
-
if (error.message) {
|
|
132
|
-
const upperMessage = error.message.toUpperCase().trim();
|
|
133
|
-
const validCodes = [
|
|
134
|
-
"USER_NOT_FOUND",
|
|
135
|
-
"USER_EXISTS",
|
|
136
|
-
"INVALID_PASSWORD",
|
|
137
|
-
"VERIFICATION_EXPIRED",
|
|
138
|
-
"VERIFICATION_MISMATCH",
|
|
139
|
-
"VERIFICATION_NOT_FOUND",
|
|
140
|
-
"TOO_MANY_ATTEMPTS",
|
|
141
|
-
"UNAUTHORIZED"
|
|
142
|
-
];
|
|
143
|
-
if (validCodes.includes(upperMessage)) {
|
|
144
|
-
return upperMessage;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
return void 0;
|
|
148
|
-
}
|
|
149
|
-
function getErrorMessage(error) {
|
|
150
|
-
if (isAuthError(error)) {
|
|
151
|
-
const errorCode = getErrorCode(error);
|
|
152
|
-
switch (errorCode) {
|
|
153
|
-
case "USER_EXISTS":
|
|
154
|
-
return "This phone number is already taken. Please use a different number.";
|
|
155
|
-
case "VERIFICATION_EXPIRED":
|
|
156
|
-
return "Verification code has expired. Please request a new one.";
|
|
157
|
-
case "VERIFICATION_MISMATCH":
|
|
158
|
-
return "Invalid verification code. Please try again.";
|
|
159
|
-
case "VERIFICATION_NOT_FOUND":
|
|
160
|
-
return "Verification not found. Please request a new code.";
|
|
161
|
-
default:
|
|
162
|
-
return error.message || "An error occurred. Please try again.";
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
if (error instanceof Error) {
|
|
166
|
-
return error.message;
|
|
167
|
-
}
|
|
168
|
-
return "An error occurred. Please try again.";
|
|
169
|
-
}
|
|
170
|
-
function RequestChangePhoneForm({
|
|
171
|
-
onSuccess,
|
|
172
|
-
onCancel,
|
|
173
|
-
buttonText
|
|
174
|
-
}) {
|
|
175
|
-
const { user } = useSession();
|
|
176
|
-
const { hooks } = useApi();
|
|
177
|
-
const { config } = useConfig();
|
|
178
|
-
const [isSubmitting, setIsSubmitting] = useState2(false);
|
|
179
|
-
const [isChecking, setIsChecking] = useState2(true);
|
|
180
|
-
const [showPassword, setShowPassword] = useState2(false);
|
|
181
|
-
const phoneRegex = typeof config.phoneRegex === "string" ? new RegExp(config.phoneRegex) : config.phoneRegex || /^(\+2519|\+2517|2519|2517|09|07)\d{8}$/;
|
|
182
|
-
const getPendingAccountChangeQuery = hooks.useQuery(
|
|
183
|
-
"get",
|
|
184
|
-
"/account-change/pending",
|
|
185
|
-
{},
|
|
186
|
-
{ enabled: false }
|
|
187
|
-
);
|
|
188
|
-
const verifyPasswordMutation = hooks.useMutation("post", "/password/verify");
|
|
189
|
-
const checkUserMutation = hooks.useMutation("post", "/check-account");
|
|
190
|
-
const requestPhoneOtpMutation = hooks.useMutation(
|
|
191
|
-
"post",
|
|
192
|
-
"/phone/verification/request"
|
|
193
|
-
);
|
|
194
|
-
const phonePasswordForm = useForm({
|
|
195
|
-
resolver: zodResolver(phonePasswordSchema(phoneRegex)),
|
|
196
|
-
defaultValues: {
|
|
197
|
-
phone: "",
|
|
198
|
-
password: ""
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
const {
|
|
202
|
-
register,
|
|
203
|
-
handleSubmit,
|
|
204
|
-
getValues,
|
|
205
|
-
setValue,
|
|
206
|
-
formState: { errors }
|
|
207
|
-
} = phonePasswordForm;
|
|
208
|
-
useEffect(() => {
|
|
209
|
-
let active = true;
|
|
210
|
-
const run = async () => {
|
|
211
|
-
try {
|
|
212
|
-
const data = await getPendingAccountChangeQuery.refetch();
|
|
213
|
-
if (!active) {
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
const accountChange = data.data?.accountChange;
|
|
217
|
-
const verificationId = data.data?.verificationId;
|
|
218
|
-
if (accountChange?.changeType !== "phone") {
|
|
219
|
-
setIsChecking(false);
|
|
220
|
-
return;
|
|
221
|
-
}
|
|
222
|
-
if (!accountChange.newPhone) {
|
|
223
|
-
setIsChecking(false);
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
|
-
if (getValues("phone")) {
|
|
227
|
-
setIsChecking(false);
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
setValue("phone", accountChange.newPhone, { shouldValidate: true });
|
|
231
|
-
if (verificationId) {
|
|
232
|
-
toast.message("Resuming verification\u2026");
|
|
233
|
-
onSuccess(verificationId, accountChange.newPhone);
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
setIsChecking(false);
|
|
237
|
-
} catch {
|
|
238
|
-
setIsChecking(false);
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
run().catch(() => void 0);
|
|
242
|
-
return () => {
|
|
243
|
-
active = false;
|
|
244
|
-
};
|
|
245
|
-
}, [getPendingAccountChangeQuery.refetch, getValues, onSuccess, setValue]);
|
|
246
|
-
const onPhonePasswordSubmit = async (data) => {
|
|
247
|
-
if (!user) {
|
|
248
|
-
toast.error("User not found");
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
try {
|
|
252
|
-
setIsSubmitting(true);
|
|
253
|
-
const normalizedPhone = normalizePhone(data.phone);
|
|
254
|
-
await verifyPasswordMutation.mutateAsync({
|
|
255
|
-
body: { password: data.password }
|
|
256
|
-
});
|
|
257
|
-
const checkResult = await checkUserMutation.mutateAsync({
|
|
258
|
-
body: { identifier: normalizedPhone }
|
|
259
|
-
});
|
|
260
|
-
if (checkResult.data?.exists) {
|
|
261
|
-
if (user?.phone?.replace(/\s/g, "") === normalizedPhone.replace(/\s/g, "")) {
|
|
262
|
-
toast.error("This is already your current phone number.");
|
|
263
|
-
return;
|
|
264
|
-
}
|
|
265
|
-
toast.error(
|
|
266
|
-
"This phone number is already taken. Please use a different number."
|
|
267
|
-
);
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
const verification = await requestPhoneOtpMutation.mutateAsync({
|
|
271
|
-
body: {
|
|
272
|
-
phone: normalizedPhone,
|
|
273
|
-
context: "change-phone"
|
|
274
|
-
}
|
|
275
|
-
});
|
|
276
|
-
toast.success("Verification code sent to your phone");
|
|
277
|
-
onSuccess(verification.data?.verificationId ?? "", normalizedPhone);
|
|
278
|
-
} catch (error) {
|
|
279
|
-
const errorMessage = getErrorMessage(error);
|
|
280
|
-
if (isAuthError(error)) {
|
|
281
|
-
const errorCode = getErrorCode(error);
|
|
282
|
-
if (errorCode === "INVALID_PASSWORD" || errorCode === "USER_NOT_FOUND") {
|
|
283
|
-
toast.error("Incorrect password. Please try again.");
|
|
284
|
-
return;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
toast.error(errorMessage);
|
|
288
|
-
} finally {
|
|
289
|
-
setIsSubmitting(false);
|
|
290
|
-
}
|
|
291
|
-
};
|
|
292
|
-
const isLoading = isSubmitting || isChecking;
|
|
293
|
-
return /* @__PURE__ */ jsxs(
|
|
294
|
-
"form",
|
|
295
|
-
{
|
|
296
|
-
onSubmit: handleSubmit(onPhonePasswordSubmit),
|
|
297
|
-
className: "p-4 space-y-4 border-t",
|
|
298
|
-
children: [
|
|
299
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-4 w-full md:w-1/2", children: [
|
|
300
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
301
|
-
/* @__PURE__ */ jsx2(Label, { htmlFor: "phone", children: "Phone Number" }),
|
|
302
|
-
/* @__PURE__ */ jsx2(
|
|
303
|
-
Input,
|
|
304
|
-
{
|
|
305
|
-
id: "phone",
|
|
306
|
-
type: "tel",
|
|
307
|
-
placeholder: "Enter your new phone number",
|
|
308
|
-
...register("phone"),
|
|
309
|
-
disabled: isLoading
|
|
310
|
-
}
|
|
311
|
-
),
|
|
312
|
-
errors.phone && /* @__PURE__ */ jsx2("p", { className: "text-sm text-destructive", children: errors.phone.message })
|
|
313
|
-
] }),
|
|
314
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
315
|
-
/* @__PURE__ */ jsx2(Label, { htmlFor: "password", children: "Password" }),
|
|
316
|
-
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
317
|
-
/* @__PURE__ */ jsx2(
|
|
318
|
-
Input,
|
|
319
|
-
{
|
|
320
|
-
id: "password",
|
|
321
|
-
type: showPassword ? "text" : "password",
|
|
322
|
-
autoComplete: "current-password",
|
|
323
|
-
placeholder: "Enter your password",
|
|
324
|
-
...register("password"),
|
|
325
|
-
disabled: isLoading
|
|
326
|
-
}
|
|
327
|
-
),
|
|
328
|
-
/* @__PURE__ */ jsx2(
|
|
329
|
-
"button",
|
|
330
|
-
{
|
|
331
|
-
type: "button",
|
|
332
|
-
onClick: () => setShowPassword(!showPassword),
|
|
333
|
-
className: "absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",
|
|
334
|
-
children: showPassword ? /* @__PURE__ */ jsx2(IconEyeOff, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx2(IconEye, { className: "h-4 w-4" })
|
|
335
|
-
}
|
|
336
|
-
)
|
|
337
|
-
] }),
|
|
338
|
-
errors.password && /* @__PURE__ */ jsx2("p", { className: "text-sm text-destructive", children: errors.password.message })
|
|
339
|
-
] })
|
|
340
|
-
] }),
|
|
341
|
-
/* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
342
|
-
/* @__PURE__ */ jsx2(
|
|
343
|
-
Button,
|
|
344
|
-
{
|
|
345
|
-
type: "button",
|
|
346
|
-
variant: "outline",
|
|
347
|
-
onClick: onCancel,
|
|
348
|
-
disabled: isLoading,
|
|
349
|
-
children: "Cancel"
|
|
350
|
-
}
|
|
351
|
-
),
|
|
352
|
-
/* @__PURE__ */ jsxs(Button, { type: "submit", disabled: isLoading, children: [
|
|
353
|
-
isLoading && /* @__PURE__ */ jsx2(Spinner, { className: "mr-2 h-4 w-4" }),
|
|
354
|
-
isChecking ? "Checking\u2026" : buttonText
|
|
355
|
-
] })
|
|
356
|
-
] })
|
|
357
|
-
]
|
|
358
|
-
}
|
|
359
|
-
);
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
// src/components/profile/verify-change-phone-form.tsx
|
|
363
|
-
import { useState as useState4 } from "react";
|
|
364
|
-
import { toast as toast2 } from "sonner";
|
|
365
|
-
|
|
366
|
-
// src/components/profile/otp-verification-modal.tsx
|
|
367
|
-
import {
|
|
368
|
-
Dialog,
|
|
369
|
-
DialogContent,
|
|
370
|
-
DialogDescription,
|
|
371
|
-
DialogHeader,
|
|
372
|
-
DialogTitle
|
|
373
|
-
} from "@mesob/ui/components";
|
|
374
|
-
|
|
375
|
-
// src/components/auth/verification-form.tsx
|
|
376
|
-
import { zodResolver as zodResolver2 } from "@hookform/resolvers/zod";
|
|
377
|
-
import {
|
|
378
|
-
Button as Button2,
|
|
379
|
-
Form,
|
|
380
|
-
FormControl,
|
|
381
|
-
FormField,
|
|
382
|
-
FormItem,
|
|
383
|
-
FormLabel,
|
|
384
|
-
FormMessage,
|
|
385
|
-
InputOTP,
|
|
386
|
-
InputOTPGroup,
|
|
387
|
-
InputOTPSlot
|
|
388
|
-
} from "@mesob/ui/components";
|
|
389
|
-
import { useForm as useForm2 } from "react-hook-form";
|
|
390
|
-
import { z as z2 } from "zod";
|
|
391
|
-
|
|
392
|
-
// src/hooks/use-translator.ts
|
|
393
|
-
import { useMesob } from "@mesob/ui/providers";
|
|
394
|
-
function useTranslator(namespace) {
|
|
395
|
-
const mesob = useMesob();
|
|
396
|
-
const { config } = useConfig();
|
|
397
|
-
if (mesob?.t) {
|
|
398
|
-
return (key, params) => {
|
|
399
|
-
const fullKey = namespace ? `${namespace}.${key}` : key;
|
|
400
|
-
return mesob.t?.(fullKey, params) ?? fullKey;
|
|
401
|
-
};
|
|
402
|
-
}
|
|
403
|
-
return createTranslator(config.messages || {}, namespace);
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
// src/components/auth/countdown.tsx
|
|
407
|
-
import { Spinner as Spinner2 } from "@mesob/ui/components";
|
|
408
|
-
import { useEffect as useEffect2, useState as useState3 } from "react";
|
|
409
|
-
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
410
|
-
var Countdown = ({
|
|
411
|
-
initialSeconds = 60,
|
|
412
|
-
onResend,
|
|
413
|
-
resending = false
|
|
414
|
-
}) => {
|
|
415
|
-
const t = useTranslator("Common");
|
|
416
|
-
const [seconds, setSeconds] = useState3(initialSeconds);
|
|
417
|
-
const [isResending, setIsResending] = useState3(false);
|
|
418
|
-
useEffect2(() => {
|
|
419
|
-
if (seconds <= 0) {
|
|
420
|
-
return;
|
|
421
|
-
}
|
|
422
|
-
const timer = setInterval(() => {
|
|
423
|
-
setSeconds((prev) => {
|
|
424
|
-
if (prev <= 1) {
|
|
425
|
-
clearInterval(timer);
|
|
426
|
-
return 0;
|
|
427
|
-
}
|
|
428
|
-
return prev - 1;
|
|
429
|
-
});
|
|
430
|
-
}, 1e3);
|
|
431
|
-
return () => clearInterval(timer);
|
|
432
|
-
}, [seconds]);
|
|
433
|
-
const handleResend = async () => {
|
|
434
|
-
setIsResending(true);
|
|
435
|
-
try {
|
|
436
|
-
await onResend();
|
|
437
|
-
setSeconds(initialSeconds);
|
|
438
|
-
} catch (_error) {
|
|
439
|
-
} finally {
|
|
440
|
-
setIsResending(false);
|
|
441
|
-
}
|
|
442
|
-
};
|
|
443
|
-
const busy = isResending || resending;
|
|
444
|
-
if (seconds > 0) {
|
|
445
|
-
return /* @__PURE__ */ jsx3("p", { className: "text-sm text-muted-foreground", children: t("resendIn", { seconds }) });
|
|
446
|
-
}
|
|
447
|
-
return /* @__PURE__ */ jsxs2(
|
|
448
|
-
"button",
|
|
449
|
-
{
|
|
450
|
-
type: "button",
|
|
451
|
-
onClick: handleResend,
|
|
452
|
-
disabled: busy,
|
|
453
|
-
className: "text-sm text-primary hover:underline disabled:opacity-50 flex items-center gap-1",
|
|
454
|
-
children: [
|
|
455
|
-
busy && /* @__PURE__ */ jsx3(Spinner2, { className: "h-3 w-3" }),
|
|
456
|
-
t("resend")
|
|
457
|
-
]
|
|
458
|
-
}
|
|
459
|
-
);
|
|
460
|
-
};
|
|
461
|
-
|
|
462
|
-
// src/components/auth/verification-form.tsx
|
|
463
|
-
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
464
|
-
var verificationSchema = (t) => z2.object({
|
|
465
|
-
code: z2.string().length(6, t("form.codeLength"))
|
|
466
|
-
});
|
|
467
|
-
var VerificationForm = ({
|
|
468
|
-
onSubmit,
|
|
469
|
-
onResend,
|
|
470
|
-
isLoading = false
|
|
471
|
-
}) => {
|
|
472
|
-
const t = useTranslator("Auth.verification");
|
|
473
|
-
const form = useForm2({
|
|
474
|
-
resolver: zodResolver2(verificationSchema(t)),
|
|
475
|
-
defaultValues: { code: "" }
|
|
476
|
-
});
|
|
477
|
-
const handleSubmit = form.handleSubmit(async (values) => {
|
|
478
|
-
await onSubmit(values);
|
|
479
|
-
});
|
|
480
|
-
const codeLength = form.watch("code").length;
|
|
481
|
-
return /* @__PURE__ */ jsx4(Form, { ...form, children: /* @__PURE__ */ jsxs3(
|
|
482
|
-
"form",
|
|
483
|
-
{
|
|
484
|
-
id: "verification-form",
|
|
485
|
-
onSubmit: handleSubmit,
|
|
486
|
-
className: "space-y-4",
|
|
487
|
-
children: [
|
|
488
|
-
/* @__PURE__ */ jsx4(
|
|
489
|
-
FormField,
|
|
490
|
-
{
|
|
491
|
-
control: form.control,
|
|
492
|
-
name: "code",
|
|
493
|
-
render: ({ field }) => /* @__PURE__ */ jsxs3(FormItem, { children: [
|
|
494
|
-
/* @__PURE__ */ jsx4("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx4(FormLabel, { children: t("form.codeLabel") }) }),
|
|
495
|
-
/* @__PURE__ */ jsx4(FormControl, { children: /* @__PURE__ */ jsx4(
|
|
496
|
-
InputOTP,
|
|
497
|
-
{
|
|
498
|
-
maxLength: 6,
|
|
499
|
-
required: true,
|
|
500
|
-
value: field.value ?? "",
|
|
501
|
-
onChange: field.onChange,
|
|
502
|
-
onBlur: field.onBlur,
|
|
503
|
-
containerClassName: "gap-4 justify-center mb-2 flex items-center",
|
|
504
|
-
children: /* @__PURE__ */ jsxs3(InputOTPGroup, { className: "gap-3 *:data-[slot=input-otp-slot]:h-12 *:data-[slot=input-otp-slot]:w-12 *:data-[slot=input-otp-slot]:rounded-md *:data-[slot=input-otp-slot]:border *:data-[slot=input-otp-slot]:text-xl", children: [
|
|
505
|
-
/* @__PURE__ */ jsx4(InputOTPSlot, { className: "h-12", index: 0 }),
|
|
506
|
-
/* @__PURE__ */ jsx4(InputOTPSlot, { className: "h-12", index: 1 }),
|
|
507
|
-
/* @__PURE__ */ jsx4(InputOTPSlot, { className: "h-12", index: 2 }),
|
|
508
|
-
/* @__PURE__ */ jsx4(InputOTPSlot, { className: "h-12", index: 3 }),
|
|
509
|
-
/* @__PURE__ */ jsx4(InputOTPSlot, { className: "h-12", index: 4 }),
|
|
510
|
-
/* @__PURE__ */ jsx4(InputOTPSlot, { className: "h-12", index: 5 })
|
|
511
|
-
] })
|
|
512
|
-
}
|
|
513
|
-
) }),
|
|
514
|
-
/* @__PURE__ */ jsx4(FormMessage, {})
|
|
515
|
-
] })
|
|
516
|
-
}
|
|
517
|
-
),
|
|
518
|
-
/* @__PURE__ */ jsx4(
|
|
519
|
-
Button2,
|
|
520
|
-
{
|
|
521
|
-
type: "submit",
|
|
522
|
-
form: "verification-form",
|
|
523
|
-
className: "w-full",
|
|
524
|
-
disabled: isLoading || codeLength !== 6,
|
|
525
|
-
loading: isLoading,
|
|
526
|
-
children: t("form.confirm")
|
|
527
|
-
}
|
|
528
|
-
),
|
|
529
|
-
/* @__PURE__ */ jsx4("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx4(Countdown, { onResend, resending: isLoading }) })
|
|
530
|
-
]
|
|
531
|
-
}
|
|
532
|
-
) });
|
|
533
|
-
};
|
|
534
|
-
|
|
535
|
-
// src/components/profile/otp-verification-modal.tsx
|
|
536
|
-
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
537
|
-
function OtpVerificationModal({
|
|
538
|
-
open,
|
|
539
|
-
title,
|
|
540
|
-
description,
|
|
541
|
-
verificationId,
|
|
542
|
-
isLoading,
|
|
543
|
-
onSubmit,
|
|
544
|
-
onResend,
|
|
545
|
-
onCancel
|
|
546
|
-
}) {
|
|
547
|
-
return /* @__PURE__ */ jsx5(
|
|
548
|
-
Dialog,
|
|
549
|
-
{
|
|
550
|
-
open,
|
|
551
|
-
onOpenChange: (nextOpen) => {
|
|
552
|
-
if (!nextOpen) {
|
|
553
|
-
onCancel?.();
|
|
554
|
-
}
|
|
555
|
-
},
|
|
556
|
-
children: /* @__PURE__ */ jsxs4(DialogContent, { children: [
|
|
557
|
-
/* @__PURE__ */ jsxs4(DialogHeader, { children: [
|
|
558
|
-
/* @__PURE__ */ jsx5(DialogTitle, { children: title }),
|
|
559
|
-
description && /* @__PURE__ */ jsx5(DialogDescription, { children: description })
|
|
560
|
-
] }),
|
|
561
|
-
/* @__PURE__ */ jsx5(
|
|
562
|
-
VerificationForm,
|
|
563
|
-
{
|
|
564
|
-
verificationId,
|
|
565
|
-
isLoading,
|
|
566
|
-
onSubmit: async ({ code }) => onSubmit(code),
|
|
567
|
-
onResend: onResend ?? (() => void 0)
|
|
568
|
-
}
|
|
569
|
-
)
|
|
570
|
-
] })
|
|
571
|
-
}
|
|
572
|
-
);
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
// src/components/profile/verify-change-phone-form.tsx
|
|
576
|
-
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
577
|
-
function isAuthError2(error) {
|
|
578
|
-
return typeof error === "object" && error !== null && ("code" in error || "message" in error || "name" in error);
|
|
579
|
-
}
|
|
580
|
-
function getErrorCode2(error) {
|
|
581
|
-
if (error.code) {
|
|
582
|
-
return error.code;
|
|
583
|
-
}
|
|
584
|
-
if (error.message) {
|
|
585
|
-
const upperMessage = error.message.toUpperCase().trim();
|
|
586
|
-
const validCodes = [
|
|
587
|
-
"USER_NOT_FOUND",
|
|
588
|
-
"USER_EXISTS",
|
|
589
|
-
"INVALID_PASSWORD",
|
|
590
|
-
"VERIFICATION_EXPIRED",
|
|
591
|
-
"VERIFICATION_MISMATCH",
|
|
592
|
-
"VERIFICATION_NOT_FOUND",
|
|
593
|
-
"TOO_MANY_ATTEMPTS",
|
|
594
|
-
"UNAUTHORIZED"
|
|
595
|
-
];
|
|
596
|
-
if (validCodes.includes(upperMessage)) {
|
|
597
|
-
return upperMessage;
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
return void 0;
|
|
601
|
-
}
|
|
602
|
-
function getErrorMessage2(error) {
|
|
603
|
-
if (isAuthError2(error)) {
|
|
604
|
-
const errorCode = getErrorCode2(error);
|
|
605
|
-
switch (errorCode) {
|
|
606
|
-
case "USER_EXISTS":
|
|
607
|
-
return "This phone number is already taken. Please use a different number.";
|
|
608
|
-
case "VERIFICATION_EXPIRED":
|
|
609
|
-
return "Verification code has expired. Please request a new one.";
|
|
610
|
-
case "VERIFICATION_MISMATCH":
|
|
611
|
-
return "Invalid verification code. Please try again.";
|
|
612
|
-
case "VERIFICATION_NOT_FOUND":
|
|
613
|
-
return "Verification not found. Please request a new code.";
|
|
614
|
-
default:
|
|
615
|
-
return error.message || "An error occurred. Please try again.";
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
if (error instanceof Error) {
|
|
619
|
-
return error.message;
|
|
620
|
-
}
|
|
621
|
-
return "An error occurred. Please try again.";
|
|
622
|
-
}
|
|
623
|
-
function VerifyChangePhoneForm({
|
|
624
|
-
phone,
|
|
625
|
-
verificationId,
|
|
626
|
-
onSuccess,
|
|
627
|
-
onCancel
|
|
628
|
-
}) {
|
|
629
|
-
const { refresh } = useSession();
|
|
630
|
-
const { hooks } = useApi();
|
|
631
|
-
const [isSubmitting, setIsSubmitting] = useState4(false);
|
|
632
|
-
const [currentVerificationId, setCurrentVerificationId] = useState4(verificationId);
|
|
633
|
-
const verifyPhoneOtpMutation = hooks.useMutation(
|
|
634
|
-
"post",
|
|
635
|
-
"/phone/verification/confirm"
|
|
636
|
-
);
|
|
637
|
-
const updatePhoneMutation = hooks.useMutation("put", "/profile/phone");
|
|
638
|
-
const requestPhoneOtpMutation = hooks.useMutation(
|
|
639
|
-
"post",
|
|
640
|
-
"/phone/verification/request"
|
|
641
|
-
);
|
|
642
|
-
const onOtpSubmit = async (code) => {
|
|
643
|
-
if (!currentVerificationId) {
|
|
644
|
-
toast2.error("Verification not found. Please request a new code.");
|
|
645
|
-
return;
|
|
646
|
-
}
|
|
647
|
-
try {
|
|
648
|
-
setIsSubmitting(true);
|
|
649
|
-
await verifyPhoneOtpMutation.mutateAsync({
|
|
650
|
-
body: {
|
|
651
|
-
verificationId: currentVerificationId,
|
|
652
|
-
code,
|
|
653
|
-
context: "change-phone"
|
|
654
|
-
}
|
|
655
|
-
});
|
|
656
|
-
await updatePhoneMutation.mutateAsync({
|
|
657
|
-
body: { phone }
|
|
658
|
-
});
|
|
659
|
-
toast2.success("Phone number updated successfully");
|
|
660
|
-
await refresh();
|
|
661
|
-
onSuccess();
|
|
662
|
-
} catch (error) {
|
|
663
|
-
const errorMessage = getErrorMessage2(error);
|
|
664
|
-
toast2.error(errorMessage);
|
|
665
|
-
} finally {
|
|
666
|
-
setIsSubmitting(false);
|
|
667
|
-
}
|
|
668
|
-
};
|
|
669
|
-
if (!currentVerificationId) {
|
|
670
|
-
toast2.error("Verification not found. Please request a new code.");
|
|
671
|
-
return null;
|
|
672
|
-
}
|
|
673
|
-
return /* @__PURE__ */ jsx6(
|
|
674
|
-
OtpVerificationModal,
|
|
675
|
-
{
|
|
676
|
-
open: true,
|
|
677
|
-
title: "Verify phone",
|
|
678
|
-
description: `Enter the verification code sent to ${phone}`,
|
|
679
|
-
verificationId: currentVerificationId,
|
|
680
|
-
isLoading: isSubmitting,
|
|
681
|
-
onSubmit: onOtpSubmit,
|
|
682
|
-
onResend: async () => {
|
|
683
|
-
try {
|
|
684
|
-
setIsSubmitting(true);
|
|
685
|
-
const next = await requestPhoneOtpMutation.mutateAsync({
|
|
686
|
-
body: {
|
|
687
|
-
phone,
|
|
688
|
-
context: "change-phone"
|
|
689
|
-
}
|
|
690
|
-
});
|
|
691
|
-
setCurrentVerificationId(next.data?.verificationId ?? null);
|
|
692
|
-
toast2.success("Verification code resent");
|
|
693
|
-
} catch (error) {
|
|
694
|
-
toast2.error(getErrorMessage2(error));
|
|
695
|
-
} finally {
|
|
696
|
-
setIsSubmitting(false);
|
|
697
|
-
}
|
|
698
|
-
},
|
|
699
|
-
onCancel
|
|
700
|
-
}
|
|
701
|
-
);
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
// src/components/profile/change-phone-form.tsx
|
|
705
|
-
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
706
|
-
function ChangePhoneForm() {
|
|
707
|
-
const { user } = useSession();
|
|
708
|
-
const [isOpen, setIsOpen] = useState5(false);
|
|
709
|
-
const [showOtp, setShowOtp] = useState5(false);
|
|
710
|
-
const [verificationId, setVerificationId] = useState5(null);
|
|
711
|
-
const [newPhone, setNewPhone] = useState5("");
|
|
712
|
-
const resetForms = () => {
|
|
713
|
-
setShowOtp(false);
|
|
714
|
-
setVerificationId(null);
|
|
715
|
-
setNewPhone("");
|
|
716
|
-
};
|
|
717
|
-
const handleRequestSuccess = (id, phone) => {
|
|
718
|
-
setVerificationId(id);
|
|
719
|
-
setNewPhone(phone);
|
|
720
|
-
setShowOtp(true);
|
|
721
|
-
};
|
|
722
|
-
const handleVerifySuccess = () => {
|
|
723
|
-
resetForms();
|
|
724
|
-
setIsOpen(false);
|
|
725
|
-
};
|
|
726
|
-
const handleCancel = () => {
|
|
727
|
-
resetForms();
|
|
728
|
-
setIsOpen(false);
|
|
729
|
-
};
|
|
730
|
-
const title = user?.phone ? "Change Phone" : "Add Phone";
|
|
731
|
-
const description = user?.phone ? "Update your phone number" : "Add a phone number to your account";
|
|
732
|
-
return /* @__PURE__ */ jsx7(Collapsible, { open: isOpen, onOpenChange: setIsOpen, children: /* @__PURE__ */ jsxs5("div", { className: "border rounded-lg", children: [
|
|
733
|
-
/* @__PURE__ */ jsxs5(
|
|
734
|
-
CollapsibleTrigger,
|
|
735
|
-
{
|
|
736
|
-
render: /* @__PURE__ */ jsx7(
|
|
737
|
-
Button3,
|
|
738
|
-
{
|
|
739
|
-
variant: "ghost",
|
|
740
|
-
className: "w-full justify-between p-4 h-auto"
|
|
741
|
-
}
|
|
742
|
-
),
|
|
743
|
-
children: [
|
|
744
|
-
/* @__PURE__ */ jsxs5("div", { className: "flex flex-col items-start", children: [
|
|
745
|
-
/* @__PURE__ */ jsx7("span", { className: "font-medium", children: title }),
|
|
746
|
-
/* @__PURE__ */ jsx7("span", { className: "text-sm text-muted-foreground", children: description })
|
|
747
|
-
] }),
|
|
748
|
-
/* @__PURE__ */ jsx7(
|
|
749
|
-
IconChevronDown,
|
|
750
|
-
{
|
|
751
|
-
className: `h-4 w-4 transition-transform ${isOpen ? "rotate-180" : ""}`
|
|
752
|
-
}
|
|
753
|
-
)
|
|
754
|
-
]
|
|
755
|
-
}
|
|
756
|
-
),
|
|
757
|
-
/* @__PURE__ */ jsx7(CollapsibleContent, { children: showOtp ? /* @__PURE__ */ jsx7(
|
|
758
|
-
VerifyChangePhoneForm,
|
|
759
|
-
{
|
|
760
|
-
phone: newPhone,
|
|
761
|
-
verificationId,
|
|
762
|
-
onSuccess: handleVerifySuccess,
|
|
763
|
-
onCancel: handleCancel
|
|
764
|
-
}
|
|
765
|
-
) : /* @__PURE__ */ jsx7(
|
|
766
|
-
RequestChangePhoneForm,
|
|
767
|
-
{
|
|
768
|
-
onSuccess: handleRequestSuccess,
|
|
769
|
-
onCancel: handleCancel,
|
|
770
|
-
buttonText: title
|
|
771
|
-
}
|
|
772
|
-
) })
|
|
773
|
-
] }) });
|
|
774
|
-
}
|
|
3
|
+
ChangePhoneForm
|
|
4
|
+
} from "../../chunk-5F5FZMHE.js";
|
|
5
|
+
import "../../chunk-ZG6WFZHX.js";
|
|
6
|
+
import "../../chunk-C26NPUPI.js";
|
|
7
|
+
import "../../chunk-KWG4DSB5.js";
|
|
8
|
+
import "../../chunk-FFR5UHTS.js";
|
|
9
|
+
import "../../chunk-GP7GIUI3.js";
|
|
10
|
+
import "../../chunk-V2W3WPCZ.js";
|
|
11
|
+
import "../../chunk-QNCE2B5O.js";
|
|
12
|
+
import "../../chunk-72YRO3A7.js";
|
|
775
13
|
export {
|
|
776
14
|
ChangePhoneForm
|
|
777
15
|
};
|