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

View File

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