Skip to content

Commit

Permalink
Merge pull request #254 from GenomicDataInfrastructure/251-gdi-fronte…
Browse files Browse the repository at this point in the history
…nd-empty-400-when-submitting-empty-form

fix: fetch application request fails silently and makes renedering is…
  • Loading branch information
brunopacheco1 authored May 24, 2024
2 parents 6977f80 + d8e2faa commit 5c883c9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
18 changes: 17 additions & 1 deletion src/app/applications/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,23 @@ export default function ApplicationDetailsPage() {
}
}, [error]);

if (!application) return;
if (!application) {
return (
<PageContainer>
{alert && (
<Alert
type={alert.type}
message={alert.message}
onClose={() => {
onCloseAlert();
clearError();
}}
className="mb-8"
/>
)}
</PageContainer>
);
}

const events = application.events;
const lastEvent = events[0];
Expand Down
7 changes: 4 additions & 3 deletions src/providers/application/ApplicationProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,15 @@ function ApplicationProvider({ children }: ApplicationProviderProps) {

const fetchApplication = useCallback(async () => {
dispatch({ type: ApplicationActionType.LOADING });
try {
const response = await fetch(`/api/applications/${id}`);
const response = await fetch(`/api/applications/${id}`);

if (response.ok) {
const retrievedApplication = await response.json();
dispatch({
type: ApplicationActionType.APPLICATION_LOADED,
payload: retrievedApplication,
});
} catch {
} else {
dispatch({
type: ApplicationActionType.REJECTED,
payload: "Failed to fetch application",
Expand Down

0 comments on commit 5c883c9

Please sign in to comment.