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();
return () => {
setProject(undefined);
};
// eslint-disable-next-line
}, [id, role]);
@@ -236,6 +240,11 @@ const Project = () => {
}
})();
return () => {
setPrototype(undefined);
setTransactionsData(undefined);
};
// eslint-disable-next-line
}, [project]);
+12 -4
View File
@@ -60,8 +60,8 @@ const Template = () => {
GetAllTemplatesQueryVariables
>(GET_ALL_TEMPLATES, {
onCompleted({ getAllTemplates }) {
setTemplate(getAllTemplates[0]);
getCategory({ variables: { id: template?.category! } });
if (getAllTemplates.length > 0)
history.push(`/template/${getAllTemplates[0].id}`);
},
fetchPolicy: 'network-only',
});
@@ -82,8 +82,9 @@ const Template = () => {
GetPrototypeByIdQueryVariables
>(GET_PROTOTYPE_BY_ID, {
onCompleted({ getPrototypeById }) {
setPrototype(getPrototypeById.prototype);
if (getPrototypeById) setPrototype(getPrototypeById.prototype);
},
fetchPolicy: 'network-only',
});
const handlePrint = useReactToPrint({
@@ -98,6 +99,11 @@ const Template = () => {
getTemplates();
}
return () => {
setTemplate(undefined);
setPrototype(undefined);
};
// eslint-disable-next-line
}, [id]);
@@ -140,7 +146,9 @@ const Template = () => {
variant='primary-action'
text='Prototype'
iconLeft={<Design />}
disabled={!prototype && role === 'productOwner'}
disabled={
prototype === undefined && role === 'productOwner'
}
onClick={() =>
history.push(`/prototype/${id || template.id}`)
}