Fix bug in project page

This commit is contained in:
Hazem Krimi
2021-06-21 17:20:38 +01:00
parent 45a80fd377
commit c03325b4b7
+4 -2
View File
@@ -102,7 +102,8 @@ const Project = () => {
id: currentUser?.id!, id: currentUser?.id!,
}, },
onCompleted({ getAllProjectsByClientId }) { onCompleted({ getAllProjectsByClientId }) {
history.push(`/project/${getAllProjectsByClientId[0].id}`); if (getAllProjectsByClientId.length > 0)
history.push(`/project/${getAllProjectsByClientId[0].id}`);
}, },
fetchPolicy: 'network-only', fetchPolicy: 'network-only',
}); });
@@ -112,7 +113,8 @@ const Project = () => {
GetAllUsersQueryVariables GetAllUsersQueryVariables
>(GET_ALL_PROJECTS, { >(GET_ALL_PROJECTS, {
onCompleted({ getAllProjects }) { onCompleted({ getAllProjects }) {
history.push(`/project/${getAllProjects[0].id}`); if (getAllProjects.length > 0)
history.push(`/project/${getAllProjects[0].id}`);
}, },
fetchPolicy: 'network-only', fetchPolicy: 'network-only',
}); });