From 3792581758ed211481010cc67e105cf6a9226b3d Mon Sep 17 00:00:00 2001 From: Hazem Krimi Date: Wed, 24 May 2023 13:44:17 +0100 Subject: [PATCH] Remove payments button for client in project page --- src/pages/Project/index.tsx | 175 ++++++++++++++---------------------- 1 file changed, 68 insertions(+), 107 deletions(-) diff --git a/src/pages/Project/index.tsx b/src/pages/Project/index.tsx index f2a61f4..c936c0c 100644 --- a/src/pages/Project/index.tsx +++ b/src/pages/Project/index.tsx @@ -11,7 +11,6 @@ import { Empty, FullBuild, MVP, - Payment, Settings, Specification, } from '../../assets'; @@ -86,38 +85,41 @@ const Project = () => { const [fullBuildModal, setFullBuildModal] = useState(false); const [transactionsData, setTransactionsData] = useState(); - const [getProjectsByClientId, { loading: clientProjectsLoading, error: clientProjectsError }] = - useLazyQuery< - GetAllProjectsByClientIdQuery, - GetAllProjectsByClientIdQueryVariables - >(GET_ALL_PROJECTS_BY_CLIENT_ID, { - variables: { - id: currentUser?.id!, - }, - onCompleted({ getAllProjectsByClientId }) { - if (getAllProjectsByClientId.length > 0) + const [ + getProjectsByClientId, + { loading: clientProjectsLoading, error: clientProjectsError }, + ] = useLazyQuery< + GetAllProjectsByClientIdQuery, + GetAllProjectsByClientIdQueryVariables + >(GET_ALL_PROJECTS_BY_CLIENT_ID, { + variables: { + id: currentUser?.id!, + }, + onCompleted({ getAllProjectsByClientId }) { + if (getAllProjectsByClientId.length > 0) setProject(getAllProjectsByClientId[0]); - }, - }); - - const [getProjects, { loading: projectsLoading, error: projectsError }] = useLazyQuery< - GetAllProjectsQuery, - GetAllUsersQueryVariables - >(GET_ALL_PROJECTS, { - onCompleted({ getAllProjects }) { - if (getAllProjects.length > 0) - setProject(getAllProjects[0]); - } + }, }); - const [getProject, { loading: projectLoading, error: projectError }] = useLazyQuery< - GetProjectByIdQuery, - GetProjectByIdQueryVariables - >(GET_PROJECT_BY_ID, { - onCompleted({ getProjectById }) { - setProject(getProjectById); - } - }); + const [getProjects, { loading: projectsLoading, error: projectsError }] = + useLazyQuery( + GET_ALL_PROJECTS, + { + onCompleted({ getAllProjects }) { + if (getAllProjects.length > 0) setProject(getAllProjects[0]); + }, + } + ); + + const [getProject, { loading: projectLoading, error: projectError }] = + useLazyQuery( + GET_PROJECT_BY_ID, + { + onCompleted({ getProjectById }) { + setProject(getProjectById); + }, + } + ); const [changeProjectState] = useMutation< ChangeProjectStateMutation, @@ -277,29 +279,27 @@ const Project = () => { }, }); - if (role === 'admin') return ( - - ); + if (role === 'admin') return ; - if (clientProjectsLoading || projectsLoading || projectLoading) return ( - - ); + if (clientProjectsLoading || projectsLoading || projectLoading) + return ; - if (clientProjectsError || projectsError || projectError || !project) return ( - - - - + if (clientProjectsError || projectsError || projectError || !project) + return ( + + + + + - - - ); + + ); return ( <> @@ -316,9 +316,7 @@ const Project = () => { label='File' file color={role || 'client'} - onChange={async ( - event: React.ChangeEvent - ) => { + onChange={async (event: React.ChangeEvent) => { const formData = new FormData(); if (event.target.files && event.target.files[0]) { @@ -364,9 +362,7 @@ const Project = () => { label='File' file color={role || 'client'} - onChange={async ( - event: React.ChangeEvent - ) => { + onChange={async (event: React.ChangeEvent) => { const formData = new FormData(); if (event.target.files && event.target.files[0]) { @@ -392,8 +388,7 @@ const Project = () => { }} error={ addMvpForm.touched.fileName && - (!!addMvpForm.errors.fileName || - !!addMvpForm.errors.fileSource) + (!!addMvpForm.errors.fileName || !!addMvpForm.errors.fileSource) } errorMessage={addMvpForm.errors.fileName} /> @@ -458,18 +453,6 @@ const Project = () => { } /> - {role === 'client' && ( - -