Skip to content

Commit

Permalink
changed to use StatusCodes enum
Browse files Browse the repository at this point in the history
  • Loading branch information
JazzarKarim committed Dec 2, 2024
1 parent db476ea commit 65ff8bb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions business-registry-dashboard/app/pages/index.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<script setup lang="ts">
import { StatusCodes } from 'http-status-codes'
const { t } = useI18n()
const affStore = useAffiliationsStore()
const brdModal = useBrdModals()
Expand Down Expand Up @@ -53,18 +55,18 @@ const parseUrlAndAddAffiliation = async (token: any, base64Token: string) => {
} catch (error: any) {
console.error(error)
// 3. Unauthorized
if (error.response?.status === 401) {
if (error.response?.status === StatusCodes.UNAUTHORIZED) {
brdModal.openMagicLinkModal(t('error.magicLinkUnauthorized.title'), t('error.magicLinkUnauthorized.description'))
return
}
// 4. Expired
if (error.response?.status === 400 &&
if (error.response?.status === StatusCodes.BAD_REQUEST &&
error.response?._data.code === MagicLinkInvitationStatus.EXPIRED_AFFILIATION_INVITATION) {
brdModal.openMagicLinkModal(t('error.magicLinkExpired.title'), t('error.magicLinkExpired.description', { identifier }))
return
}
// 5. Already Added
if (error.response?.status === 400 &&
if (error.response?.status === StatusCodes.BAD_REQUEST &&
error.response?._data.code === MagicLinkInvitationStatus.ACTIONED_AFFILIATION_INVITATION) {
brdModal.openMagicLinkModal(t('error.magicLinkAlreadyAdded.title'), t('error.magicLinkAlreadyAdded.description', { identifier }))
return
Expand Down

0 comments on commit 65ff8bb

Please sign in to comment.