Don't build redirect until data available

This commit is contained in:
Jake McDermott 2020-12-17 09:16:54 -05:00
parent d35732c4b7
commit 19f855717d
No known key found for this signature in database
GPG Key ID: 0E56ED990CDFCB4F

View File

@ -18,8 +18,11 @@ function JobTypeRedirect({ id, path, view, i18n }) {
request: loadJob,
} = useRequest(
useCallback(async () => {
const { data } = await UnifiedJobsAPI.read({ id });
return { job: data };
const {
data: { results },
} = await UnifiedJobsAPI.read({ id });
const [item] = results;
return { job: item };
}, [id]),
{ job: {} }
);
@ -42,7 +45,7 @@ function JobTypeRedirect({ id, path, view, i18n }) {
</PageSection>
);
}
if (isLoading) {
if (isLoading || !job?.id) {
// TODO show loading state
return <div>Loading...</div>;
}