Skip to content

Commit

Permalink
fix: user management bugs (#1343)
Browse files Browse the repository at this point in the history
  • Loading branch information
Riddhiagrawal001 authored Sep 10, 2024
1 parent 6f25b23 commit 36d234d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 16 deletions.
2 changes: 2 additions & 0 deletions src/entryPoints/AuthModule/Common/CommonAuthTypes.res
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ type authFlow =
| ActivateFromEmail
type data = {code: string, message: string, type_: string}
type subCode =
| HE_02
| UR_00
| UR_01
| UR_03
| UR_05
| UR_16
| UR_29
| UR_33
| UR_38
| UR_40
| UR_41
Expand Down
2 changes: 2 additions & 0 deletions src/entryPoints/AuthModule/Common/CommonAuthUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,13 @@ let parseErrorMessage = errorMessage => {

let errorSubCodeMapper = (subCode: string) => {
switch subCode {
| "HE_02" => HE_02
| "UR_01" => UR_01
| "UR_03" => UR_03
| "UR_05" => UR_05
| "UR_16" => UR_16
| "UR_29" => UR_29
| "UR_33" => UR_33
| "UR_38" => UR_38
| "UR_40" => UR_40
| "UR_41" => UR_41
Expand Down
45 changes: 29 additions & 16 deletions src/screens/APIUtils/APIUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ let useGetURL = () => {
switch (userEntity, userManagementRevamp) {
| (#Organization, true)
| (#Merchant, true)
| (#Profile, true) =>
| (#Profile, true)
| (#Internal, true) =>
`account/${merchantId}/profile/connectors`
| _ => connectorBaseURL
}
Expand Down Expand Up @@ -116,15 +117,12 @@ let useGetURL = () => {
| Some(queryParams) => `payments/${key_id}?${queryParams}`
| None => `payments/${key_id}`
}

| None =>
switch queryParamerters {
| Some(queryParams) =>
switch (transactionEntity, userManagementRevamp) {
| (#Merchant, true) => `payments/list?${queryParams}`
| (#Profile, true) => `payments/profile/list?${queryParams}`
| _ => `payments/list?limit=100`
}
| None => `payments/list?limit=100`
switch (transactionEntity, userManagementRevamp) {
| (#Merchant, true) => `payments/list?limit=100`
| (#Profile, true) => `payments/profile/list?limit=100`
| _ => `payments/list?limit=100`
}
}
| Post =>
Expand Down Expand Up @@ -226,7 +224,8 @@ let useGetURL = () => {
switch (userEntity, userManagementRevamp) {
| (#Organization, true)
| (#Merchant, true)
| (#Profile, true) => `routing/list/profile`
| (#Profile, true)
| (#Internal, true) => `routing/list/profile`
| _ => `routing`
}
}
Expand Down Expand Up @@ -345,7 +344,8 @@ let useGetURL = () => {
switch (userEntity, userManagementRevamp) {
| (#Organization, true)
| (#Merchant, true)
| (#Profile, true) => `routing/payouts/list/profile`
| (#Profile, true)
| (#Internal, true) => `routing/payouts/list/profile`
| _ => `routing/payouts`
}
}
Expand Down Expand Up @@ -465,7 +465,8 @@ let useGetURL = () => {
switch (userEntity, userManagementRevamp) {
| (#Organization, true)
| (#Merchant, true)
| (#Profile, true) =>
| (#Profile, true)
| (#Internal, true) =>
`account/${merchantId}/profile`
| _ => `account/${merchantId}/business_profile`
}
Expand Down Expand Up @@ -761,14 +762,18 @@ let responseHandler = async (
let errorDict = json->getDictFromJsonObject->getObj("error", Dict.make())
let errorStringifiedJson = errorDict->JSON.Encode.object->JSON.stringify

//TODO:-
// errorCodes to be handled
// let errorCode = errorDict->getString("code", "")

if isPlayground && responseStatus === 403 {
popUpCallBack()
} else if showErrorToast {
switch responseStatus {
| 400 => {
let errorCode = errorDict->getString("code", "")
switch errorCode->CommonAuthUtils.errorSubCodeMapper {
| HE_02 | UR_33 =>
RescriptReactRouter.replace(GlobalVars.appendDashboardPath(~url="/home"))
| _ => ()
}
}
| 401 =>
if !sessionExpired.contents {
showToast(~toastType=ToastWarning, ~message="Session Expired", ~autoClose=false)
Expand All @@ -792,6 +797,13 @@ let responseHandler = async (
},
})

| 404 => {
let errorCode = errorDict->getString("code", "")
switch errorCode->CommonAuthUtils.errorSubCodeMapper {
| HE_02 => RescriptReactRouter.replace(GlobalVars.appendDashboardPath(~url="/home"))
| _ => ()
}
}
| _ =>
showToast(
~toastType=ToastError,
Expand All @@ -814,6 +826,7 @@ let catchHandler = (
) => {
switch Exn.message(err) {
| Some(msg) => Exn.raiseError(msg)

| None => {
if isPlayground {
popUpCallBack()
Expand Down

0 comments on commit 36d234d

Please sign in to comment.