Skip to content

Commit

Permalink
fix: totp error toast
Browse files Browse the repository at this point in the history
  • Loading branch information
kanikabansal-juspay authored and JeevaRamu0104 committed Nov 18, 2024
1 parent 7899e26 commit 0662f06
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/SelectBox.res
Original file line number Diff line number Diff line change
Expand Up @@ -1623,7 +1623,7 @@ module BaseDropdown = {

let showBorder = isFilterSection && !isMobileView ? Some(false) : showBorder

let dropdownOuterClass = "border border-jp-gray-lightmode_steelgray border-opacity-75 dark:border-jp-gray-960 rounded shadow-generic_shadow dark:shadow-generic_shadow_dark"
let dropdownOuterClass = "border border-jp-gray-lightmode_steelgray border-opacity-75 dark:border-jp-gray-960 rounded shadow-generic_shadow dark:shadow-generic_shadow_dark z-40"

let newInputSelect = input->ffInputToSelectInput
let newInputRadio = input->ffInputToRadioInput
Expand Down
2 changes: 2 additions & 0 deletions src/entryPoints/AuthModule/Common/CommonAuthTypes.res
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,7 @@ type subCode =
| UR_48
| UR_49
| UR_06
| UR_37
| UR_39

type modeType = TestButtonMode | LiveButtonMode
2 changes: 2 additions & 0 deletions src/entryPoints/AuthModule/Common/CommonAuthUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ let errorSubCodeMapper = (subCode: string) => {
| "UR_48" => UR_48
| "UR_49" => UR_49
| "UR_06" => UR_06
| "UR_37" => UR_37
| "UR_39" => UR_39
| _ => UR_00
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/entryPoints/AuthModule/TwoFaAuth/TotpSetup.res
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,11 @@ module ConfigureTotpScreen = {
| Exn.Error(e) => {
let err = Exn.message(e)->Option.getOr("Something went wrong")
let errorCode = err->safeParse->getDictFromJsonObject->getString("code", "")
let errorMessage = err->safeParse->getDictFromJsonObject->getString("message", "")
if errorCode->CommonAuthUtils.errorSubCodeMapper == UR_48 {
errorHandling()
} else if errorCode->CommonAuthUtils.errorSubCodeMapper == UR_37 {
showToast(~message=errorMessage, ~toastType=ToastError)
}
setOtp(_ => "")
setButtonState(_ => Button.Normal)
Expand Down
7 changes: 7 additions & 0 deletions src/screens/Hooks/TotpHooks.res
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ let useVerifyTotp = () => {

let useVerifyRecoveryCode = () => {
open APIUtils
open LogicUtils
let getURL = useGetURL()
let updateDetails = useUpdateMethod()
let showToast = ToastState.useShowToast()
async body => {
try {
let url = getURL(~entityName=USERS, ~userType=#VERIFY_RECOVERY_CODE, ~methodType=Post)
Expand All @@ -28,6 +30,11 @@ let useVerifyRecoveryCode = () => {
} catch {
| Exn.Error(e) => {
let err = Exn.message(e)->Option.getOr("Failed to Fetch!")
let errorCode = err->safeParse->getDictFromJsonObject->getString("code", "")
let errorMessage = err->safeParse->getDictFromJsonObject->getString("message", "")
if errorCode->CommonAuthUtils.errorSubCodeMapper == UR_39 {
showToast(~message=errorMessage, ~toastType=ToastError)
}
Exn.raiseError(err)
}
}
Expand Down

0 comments on commit 0662f06

Please sign in to comment.