Fix template and prototype bugs

This commit is contained in:
Hazem Krimi
2021-06-21 23:17:37 +01:00
parent d0a335add5
commit 613af2e1e9
2 changed files with 21 additions and 4 deletions
+9
View File
@@ -211,6 +211,10 @@ const Project = () => {
}); });
} else getProjects(); } else getProjects();
return () => {
setProject(undefined);
};
// eslint-disable-next-line // eslint-disable-next-line
}, [id, role]); }, [id, role]);
@@ -236,6 +240,11 @@ const Project = () => {
} }
})(); })();
return () => {
setPrototype(undefined);
setTransactionsData(undefined);
};
// eslint-disable-next-line // eslint-disable-next-line
}, [project]); }, [project]);
+12 -4
View File
@@ -60,8 +60,8 @@ const Template = () => {
GetAllTemplatesQueryVariables GetAllTemplatesQueryVariables
>(GET_ALL_TEMPLATES, { >(GET_ALL_TEMPLATES, {
onCompleted({ getAllTemplates }) { onCompleted({ getAllTemplates }) {
setTemplate(getAllTemplates[0]); if (getAllTemplates.length > 0)
getCategory({ variables: { id: template?.category! } }); history.push(`/template/${getAllTemplates[0].id}`);
}, },
fetchPolicy: 'network-only', fetchPolicy: 'network-only',
}); });
@@ -82,8 +82,9 @@ const Template = () => {
GetPrototypeByIdQueryVariables GetPrototypeByIdQueryVariables
>(GET_PROTOTYPE_BY_ID, { >(GET_PROTOTYPE_BY_ID, {
onCompleted({ getPrototypeById }) { onCompleted({ getPrototypeById }) {
setPrototype(getPrototypeById.prototype); if (getPrototypeById) setPrototype(getPrototypeById.prototype);
}, },
fetchPolicy: 'network-only',
}); });
const handlePrint = useReactToPrint({ const handlePrint = useReactToPrint({
@@ -98,6 +99,11 @@ const Template = () => {
getTemplates(); getTemplates();
} }
return () => {
setTemplate(undefined);
setPrototype(undefined);
};
// eslint-disable-next-line // eslint-disable-next-line
}, [id]); }, [id]);
@@ -140,7 +146,9 @@ const Template = () => {
variant='primary-action' variant='primary-action'
text='Prototype' text='Prototype'
iconLeft={<Design />} iconLeft={<Design />}
disabled={!prototype && role === 'productOwner'} disabled={
prototype === undefined && role === 'productOwner'
}
onClick={() => onClick={() =>
history.push(`/prototype/${id || template.id}`) history.push(`/prototype/${id || template.id}`)
} }