Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix user ui error handling #122

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 25 additions & 17 deletions src/components/cards/AppInfoCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -573,27 +573,35 @@ const AppInfoCard: React.FC<ComponentProps> = ({
return
}

if (application.Lifecycle.State === 'ReadyToSign') {
const requestId = application['Allocation Requests'].find(
(alloc) => alloc.Active,
)?.ID
if (!requestId) return

try {
if (application.Lifecycle.State === 'ReadyToSign') {
const requestId = application['Allocation Requests'].find(
(alloc) => alloc.Active,
)?.ID
if (!requestId) return

setAllocationAmountConfig((prev) => ({
...prev,
isDialogOpen: false,
}))

await mutationProposal.mutateAsync({
requestId,
userName,
allocationAmount: validatedAllocationAmount,
})
} else {
await mutationTrigger.mutateAsync({
userName,
allocationAmount: validatedAllocationAmount,
})
}
} catch (error) {
setAllocationAmountConfig((prev) => ({
...prev,
isDialogOpen: false,
}))

await mutationProposal.mutateAsync({
requestId,
userName,
allocationAmount: validatedAllocationAmount,
})
} else {
await mutationTrigger.mutateAsync({
userName,
allocationAmount: validatedAllocationAmount,
})
handleSSAError(error)
}

setApiCalling(false)
Expand Down
9 changes: 9 additions & 0 deletions src/lib/apiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ export const postApplicationDecline = async (
return data
} catch (error) {
console.error(error)
throw error
}
}

Expand Down Expand Up @@ -211,6 +212,7 @@ export const postAdditionalInfoRequest = async (
return data
} catch (error) {
console.error(error)
throw error
}
}

Expand Down Expand Up @@ -262,6 +264,7 @@ export const postRequestKyc = async (
return data
} catch (error) {
console.error(error)
throw error
}
}

Expand All @@ -287,6 +290,7 @@ export const postRemoveAlloc = async (
return data
} catch (error) {
console.error(error)
throw error
}
}

Expand Down Expand Up @@ -322,6 +326,7 @@ export const postApplicationTrigger = async (
return data
} catch (error) {
console.error(error)
throw error
}
}

Expand Down Expand Up @@ -354,6 +359,7 @@ export const postApproveChanges = async (
return data
} catch (error) {
console.error(error)
throw error
}
}

Expand Down Expand Up @@ -401,6 +407,7 @@ export const postApplicationProposal = async (
return data
} catch (error) {
console.error(error)
throw error
}
}

Expand Down Expand Up @@ -445,6 +452,7 @@ export const postApplicationApproval = async (
return data
} catch (error) {
console.error(error)
throw error
}
}

Expand All @@ -462,6 +470,7 @@ export const fetchLDNActors = async (): Promise<
return data
} catch (e) {
console.error(e)
throw e
}
}
/**
Expand Down