mirror of
https://github.com/hazemKrimi/crimson-quirks-ui.git
synced 2026-05-01 18:20:28 +00:00
Improve networking, loading and redirection
This commit is contained in:
+5
-5
@@ -28,7 +28,7 @@ import {
|
|||||||
AddProject,
|
AddProject,
|
||||||
UpdateProject,
|
UpdateProject,
|
||||||
Payments,
|
Payments,
|
||||||
SupportMessaging,
|
Support,
|
||||||
} from './pages';
|
} from './pages';
|
||||||
import { GetUserByIdQuery, GetUserByIdQueryVariables } from './graphql/types';
|
import { GetUserByIdQuery, GetUserByIdQueryVariables } from './graphql/types';
|
||||||
import { GET_USER_BY_ID } from './graphql/auth.api';
|
import { GET_USER_BY_ID } from './graphql/auth.api';
|
||||||
@@ -136,18 +136,18 @@ const App = () => {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path='/support-messaging/:project'
|
path='/support/:project'
|
||||||
element={
|
element={
|
||||||
<Protected>
|
<Protected>
|
||||||
<SupportMessaging />
|
<Support />
|
||||||
</Protected>
|
</Protected>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path='/support-messaging/:project/:id'
|
path='/support/:project/:id'
|
||||||
element={
|
element={
|
||||||
<Protected>
|
<Protected>
|
||||||
<SupportMessaging />
|
<Support />
|
||||||
</Protected>
|
</Protected>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -56,8 +56,7 @@ const Sidebar = () => {
|
|||||||
},
|
},
|
||||||
onCompleted({ getAllProjectsByClientId }) {
|
onCompleted({ getAllProjectsByClientId }) {
|
||||||
setProjects(getAllProjectsByClientId);
|
setProjects(getAllProjectsByClientId);
|
||||||
},
|
}
|
||||||
fetchPolicy: 'network-only',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const [getProjects] = useLazyQuery<
|
const [getProjects] = useLazyQuery<
|
||||||
@@ -66,8 +65,7 @@ const Sidebar = () => {
|
|||||||
>(GET_ALL_PROJECTS, {
|
>(GET_ALL_PROJECTS, {
|
||||||
onCompleted({ getAllProjects }) {
|
onCompleted({ getAllProjects }) {
|
||||||
setProjects(getAllProjects);
|
setProjects(getAllProjects);
|
||||||
},
|
}
|
||||||
fetchPolicy: 'network-only',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const [getTemplates] = useLazyQuery<
|
const [getTemplates] = useLazyQuery<
|
||||||
@@ -77,7 +75,6 @@ const Sidebar = () => {
|
|||||||
onCompleted({ getAllTemplates }) {
|
onCompleted({ getAllTemplates }) {
|
||||||
setTemplates(getAllTemplates);
|
setTemplates(getAllTemplates);
|
||||||
},
|
},
|
||||||
fetchPolicy: 'network-only',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const [getFeatures] = useLazyQuery<
|
const [getFeatures] = useLazyQuery<
|
||||||
@@ -87,7 +84,6 @@ const Sidebar = () => {
|
|||||||
onCompleted({ getAllFeatures }) {
|
onCompleted({ getAllFeatures }) {
|
||||||
setFeatures(getAllFeatures);
|
setFeatures(getAllFeatures);
|
||||||
},
|
},
|
||||||
fetchPolicy: 'network-only',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const [getCategories] = useLazyQuery<
|
const [getCategories] = useLazyQuery<
|
||||||
@@ -97,7 +93,6 @@ const Sidebar = () => {
|
|||||||
onCompleted({ getAllCategories }) {
|
onCompleted({ getAllCategories }) {
|
||||||
setCategories(getAllCategories);
|
setCategories(getAllCategories);
|
||||||
},
|
},
|
||||||
fetchPolicy: 'network-only',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -123,8 +118,6 @@ const Sidebar = () => {
|
|||||||
setFeatures([]);
|
setFeatures([]);
|
||||||
setCategories([]);
|
setCategories([]);
|
||||||
};
|
};
|
||||||
|
|
||||||
// eslint-disable-next-line
|
|
||||||
}, [location.pathname]);
|
}, [location.pathname]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -133,14 +126,15 @@ const Sidebar = () => {
|
|||||||
<>
|
<>
|
||||||
<Box display='flex' flexDirection='column'>
|
<Box display='flex' flexDirection='column'>
|
||||||
{projects &&
|
{projects &&
|
||||||
projects.map((project) => (
|
new RegExp(/project/, 'i').test(location.pathname) &&
|
||||||
|
projects.map((project, index) => (
|
||||||
<Box marginBottom='20px' key={project.id}>
|
<Box marginBottom='20px' key={project.id}>
|
||||||
<div id={`project-${project.id}`}>
|
<div id={`project-${project.id}`}>
|
||||||
<SidebarItem
|
<SidebarItem
|
||||||
color={role}
|
color={role}
|
||||||
selected={new RegExp(project.id, 'i').test(
|
selected={
|
||||||
location.pathname
|
new RegExp(project.id, 'i').test(location.pathname) ||
|
||||||
)}
|
(index === 0 && location.pathname === '/project')}
|
||||||
text={project.name[0]}
|
text={project.name[0]}
|
||||||
onClick={() => navigate(`/project/${project.id}`)}
|
onClick={() => navigate(`/project/${project.id}`)}
|
||||||
/>
|
/>
|
||||||
@@ -152,6 +146,7 @@ const Sidebar = () => {
|
|||||||
</Box>
|
</Box>
|
||||||
))}
|
))}
|
||||||
{templates &&
|
{templates &&
|
||||||
|
new RegExp(/template/, 'i').test(location.pathname) &&
|
||||||
templates.map((template, index) => (
|
templates.map((template, index) => (
|
||||||
<Box marginBottom='20px' key={template.id}>
|
<Box marginBottom='20px' key={template.id}>
|
||||||
<div id={`template-${template.id}`}>
|
<div id={`template-${template.id}`}>
|
||||||
@@ -172,6 +167,7 @@ const Sidebar = () => {
|
|||||||
</Box>
|
</Box>
|
||||||
))}
|
))}
|
||||||
{features &&
|
{features &&
|
||||||
|
new RegExp(/feature/, 'i').test(location.pathname) &&
|
||||||
features.map((feature, index) => (
|
features.map((feature, index) => (
|
||||||
<Box marginBottom='20px' key={feature.id}>
|
<Box marginBottom='20px' key={feature.id}>
|
||||||
<div id={`feature-${feature.id}`}>
|
<div id={`feature-${feature.id}`}>
|
||||||
@@ -192,6 +188,7 @@ const Sidebar = () => {
|
|||||||
</Box>
|
</Box>
|
||||||
))}
|
))}
|
||||||
{categories &&
|
{categories &&
|
||||||
|
new RegExp(/category/, 'i').test(location.pathname) &&
|
||||||
categories.map((category, index) => (
|
categories.map((category, index) => (
|
||||||
<Box marginBottom='20px' key={category.id}>
|
<Box marginBottom='20px' key={category.id}>
|
||||||
<div id={`category-${category.id}`}>
|
<div id={`category-${category.id}`}>
|
||||||
|
|||||||
@@ -66,7 +66,14 @@ const AddCategory = () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return role === 'developer' ? (
|
if (role !== 'developer') return (
|
||||||
|
<>
|
||||||
|
{role === 'admin' && <Navigate to='/clients' />}
|
||||||
|
{['client', 'productOwer'].includes(role as string) && <Navigate to='/project' />}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
|
||||||
|
return (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
<Box>
|
<Box>
|
||||||
<Button
|
<Button
|
||||||
@@ -188,12 +195,6 @@ const AddCategory = () => {
|
|||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
{role === 'admin' && <Navigate to='/clients' />}
|
|
||||||
{role === 'client' ||
|
|
||||||
(role === 'productOwner' && <Navigate to='/project' />)}
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,6 @@ const AddFeature = () => {
|
|||||||
imageName: Yup.string().required('Image is required'),
|
imageName: Yup.string().required('Image is required'),
|
||||||
imageSource: Yup.string().required('Image is required'),
|
imageSource: Yup.string().required('Image is required'),
|
||||||
featureType: Yup.string().required('Feature Type is required'),
|
featureType: Yup.string().required('Feature Type is required'),
|
||||||
// prettier-ignore
|
|
||||||
price: Yup.number().typeError('Price must be a number').required('Price is required'),
|
price: Yup.number().typeError('Price must be a number').required('Price is required'),
|
||||||
repo: Yup.string().required('Repo is required'),
|
repo: Yup.string().required('Repo is required'),
|
||||||
}),
|
}),
|
||||||
@@ -122,7 +121,14 @@ const AddFeature = () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return role === 'developer' ? (
|
if (role !== 'developer') return (
|
||||||
|
<>
|
||||||
|
{role === 'admin' && <Navigate to='/clients' />}
|
||||||
|
{['client', 'productOwer'].includes(role as string) && <Navigate to='/project' />}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
|
||||||
|
return (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
<Box>
|
<Box>
|
||||||
<Button
|
<Button
|
||||||
@@ -477,12 +483,6 @@ const AddFeature = () => {
|
|||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
{role === 'admin' && <Navigate to='/clients' />}
|
|
||||||
{role === 'client' ||
|
|
||||||
(role === 'productOwner' && <Navigate to='/project' />)}
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -153,8 +153,7 @@ const AddProject = () => {
|
|||||||
>(GET_ALL_CATEGORIES, {
|
>(GET_ALL_CATEGORIES, {
|
||||||
onCompleted({ getAllCategories }) {
|
onCompleted({ getAllCategories }) {
|
||||||
setCategories(getAllCategories);
|
setCategories(getAllCategories);
|
||||||
},
|
}
|
||||||
fetchPolicy: 'network-only',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const [getTemplates, { loading: templatesLoading }] = useLazyQuery<
|
const [getTemplates, { loading: templatesLoading }] = useLazyQuery<
|
||||||
@@ -163,8 +162,7 @@ const AddProject = () => {
|
|||||||
>(GET_ALL_TEMPLATES_BY_CATEGORIES_ID, {
|
>(GET_ALL_TEMPLATES_BY_CATEGORIES_ID, {
|
||||||
onCompleted({ getAllTemplatesByCategoriesId }) {
|
onCompleted({ getAllTemplatesByCategoriesId }) {
|
||||||
setTemplates(getAllTemplatesByCategoriesId);
|
setTemplates(getAllTemplatesByCategoriesId);
|
||||||
},
|
}
|
||||||
fetchPolicy: 'network-only',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const [getFeatures, { loading: featuresLoading }] = useLazyQuery<
|
const [getFeatures, { loading: featuresLoading }] = useLazyQuery<
|
||||||
@@ -173,8 +171,7 @@ const AddProject = () => {
|
|||||||
>(GET_ALL_FEATURES, {
|
>(GET_ALL_FEATURES, {
|
||||||
onCompleted({ getAllFeatures }) {
|
onCompleted({ getAllFeatures }) {
|
||||||
setFeatures(getAllFeatures);
|
setFeatures(getAllFeatures);
|
||||||
},
|
}
|
||||||
fetchPolicy: 'network-only',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const [getDevelopers, { loading: developersLoading }] = useLazyQuery<
|
const [getDevelopers, { loading: developersLoading }] = useLazyQuery<
|
||||||
@@ -183,8 +180,7 @@ const AddProject = () => {
|
|||||||
>(GET_ALL_USERS, {
|
>(GET_ALL_USERS, {
|
||||||
onCompleted({ getAllUsers }) {
|
onCompleted({ getAllUsers }) {
|
||||||
setDevelopers(getAllUsers.filter((user) => user.role === 'Developer'));
|
setDevelopers(getAllUsers.filter((user) => user.role === 'Developer'));
|
||||||
},
|
}
|
||||||
fetchPolicy: 'network-only',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const [createUser, { loading: createUserLoading }] = useMutation<
|
const [createUser, { loading: createUserLoading }] = useMutation<
|
||||||
@@ -248,8 +244,6 @@ const AddProject = () => {
|
|||||||
if (step === 'features') getFeatures();
|
if (step === 'features') getFeatures();
|
||||||
if (step === 'client-creation') getCountryCodes();
|
if (step === 'client-creation') getCountryCodes();
|
||||||
if (step === 'project-metadata') getDevelopers();
|
if (step === 'project-metadata') getDevelopers();
|
||||||
|
|
||||||
// eslint-disable-next-line
|
|
||||||
}, [step]);
|
}, [step]);
|
||||||
|
|
||||||
const basicInfoForm = useFormik({
|
const basicInfoForm = useFormik({
|
||||||
@@ -512,7 +506,6 @@ const AddProject = () => {
|
|||||||
validationSchema: Yup.object().shape({
|
validationSchema: Yup.object().shape({
|
||||||
summary: Yup.string().required('Summary is required'),
|
summary: Yup.string().required('Summary is required'),
|
||||||
purpose: Yup.string().required('Purpose is required'),
|
purpose: Yup.string().required('Purpose is required'),
|
||||||
// prettier-ignore
|
|
||||||
months: Yup.number().typeError('Months must be a number').required('Months is required'),
|
months: Yup.number().typeError('Months must be a number').required('Months is required'),
|
||||||
}),
|
}),
|
||||||
onSubmit: ({
|
onSubmit: ({
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import {
|
|||||||
FeatureCard,
|
FeatureCard,
|
||||||
} from '../../components';
|
} from '../../components';
|
||||||
import { Wrapper } from './styles';
|
import { Wrapper } from './styles';
|
||||||
import { ArrowLeft, General, Specification, Features } from '../../assets';
|
import { ArrowLeft, General, Specification, Features, Empty } from '../../assets';
|
||||||
import {
|
import {
|
||||||
AddTemplateMutation,
|
AddTemplateMutation,
|
||||||
AddTemplateMutationVariables,
|
AddTemplateMutationVariables,
|
||||||
@@ -85,14 +85,14 @@ const AddTemplate = () => {
|
|||||||
>('general');
|
>('general');
|
||||||
const [error, setError] = useState<string>('');
|
const [error, setError] = useState<string>('');
|
||||||
|
|
||||||
const { data: categories, loading: categoriesLoading } = useQuery<
|
const { data: categories, loading: categoriesLoading, error: categoriesError } = useQuery<
|
||||||
GetAllCategoriesQuery,
|
GetAllCategoriesQuery,
|
||||||
GetAllCategoriesQueryVariables
|
GetAllCategoriesQueryVariables
|
||||||
>(GET_ALL_CATEGORIES, {
|
>(GET_ALL_CATEGORIES, {
|
||||||
fetchPolicy: 'network-only',
|
fetchPolicy: 'network-only',
|
||||||
});
|
});
|
||||||
|
|
||||||
const [getFeatures, { loading: featuresLoading }] = useLazyQuery<
|
const [getFeatures, { loading: featuresLoading, error: featuresError }] = useLazyQuery<
|
||||||
GetAllFeaturesQuery,
|
GetAllFeaturesQuery,
|
||||||
GetAllFeaturesQueryVariables
|
GetAllFeaturesQueryVariables
|
||||||
>(GET_ALL_FEATURES, {
|
>(GET_ALL_FEATURES, {
|
||||||
@@ -267,7 +267,34 @@ const AddTemplate = () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return role === 'productOwner' ? (
|
if (role !== 'productOwner') return (
|
||||||
|
<>
|
||||||
|
{role === 'admin' && <Navigate to='/clients' />}
|
||||||
|
{['client', 'developer'].includes(role as string) && <Navigate to='/project' />}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
|
||||||
|
if (categoriesLoading || featuresLoading) return (
|
||||||
|
<Spinner fullScreen color={role || 'client'} />
|
||||||
|
);
|
||||||
|
|
||||||
|
if (categoriesError || featuresError || !availableFeatures || !categories) return (
|
||||||
|
<Wrapper color={role}>
|
||||||
|
<Box
|
||||||
|
width='100%'
|
||||||
|
height='100vh'
|
||||||
|
display='grid'
|
||||||
|
alignItems='center'
|
||||||
|
justifyContent='center'
|
||||||
|
>
|
||||||
|
<Box>
|
||||||
|
<Empty />
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</Wrapper>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
<Box>
|
<Box>
|
||||||
<Button
|
<Button
|
||||||
@@ -733,8 +760,6 @@ const AddTemplate = () => {
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{selectedSection === 'features' && (
|
{selectedSection === 'features' && (
|
||||||
<>
|
|
||||||
{!featuresLoading ? (
|
|
||||||
<>
|
<>
|
||||||
<Box
|
<Box
|
||||||
display='grid'
|
display='grid'
|
||||||
@@ -801,22 +826,10 @@ const AddTemplate = () => {
|
|||||||
</Box>
|
</Box>
|
||||||
</form>
|
</form>
|
||||||
</>
|
</>
|
||||||
) : (
|
|
||||||
<Box display='grid' alignItems='center' justifyContent='center'>
|
|
||||||
<Spinner color={role || 'client'} />
|
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
{role === 'admin' && <Navigate to='/clients' />}
|
|
||||||
{role === 'client' ||
|
|
||||||
(role === 'developer' && <Navigate to='/project' />)}
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -23,24 +23,22 @@ const Category = () => {
|
|||||||
const { id } = useParams<{ id: string }>();
|
const { id } = useParams<{ id: string }>();
|
||||||
const [category, setCategory] = useState<CategoryOutput>();
|
const [category, setCategory] = useState<CategoryOutput>();
|
||||||
|
|
||||||
const [getCategories, { loading: categoriesLoading }] = useLazyQuery<
|
const [getCategories, { loading: categoriesLoading, error: categoriesError }] = useLazyQuery<
|
||||||
GetAllCategoriesQuery,
|
GetAllCategoriesQuery,
|
||||||
GetAllCategoriesQueryVariables
|
GetAllCategoriesQueryVariables
|
||||||
>(GET_ALL_CATEGORIES, {
|
>(GET_ALL_CATEGORIES, {
|
||||||
onCompleted({ getAllCategories }) {
|
onCompleted({ getAllCategories }) {
|
||||||
setCategory(getAllCategories[0]);
|
setCategory(getAllCategories[0]);
|
||||||
},
|
}
|
||||||
fetchPolicy: 'network-only',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const [getCategory, { loading: categoryLoading }] = useLazyQuery<
|
const [getCategory, { loading: categoryLoading, error: categoryError }] = useLazyQuery<
|
||||||
GetCategoryByIdQuery,
|
GetCategoryByIdQuery,
|
||||||
GetCategoryByIdQueryVariables
|
GetCategoryByIdQueryVariables
|
||||||
>(GET_CATEGORY_BY_ID, {
|
>(GET_CATEGORY_BY_ID, {
|
||||||
onCompleted({ getCategoryById }) {
|
onCompleted({ getCategoryById }) {
|
||||||
setCategory(getCategoryById);
|
setCategory(getCategoryById);
|
||||||
},
|
}
|
||||||
fetchPolicy: 'network-only',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -49,15 +47,36 @@ const Category = () => {
|
|||||||
} else {
|
} else {
|
||||||
getCategories();
|
getCategories();
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line
|
|
||||||
}, [id]);
|
}, [id]);
|
||||||
|
|
||||||
return role === 'developer' ? (
|
if (role !== 'developer') return (
|
||||||
<>
|
<>
|
||||||
{!categoriesLoading && !categoryLoading ? (
|
{role === 'admin' && <Navigate to='/clients' />}
|
||||||
<>
|
{['client', 'productOwer'].includes(role as string) && <Navigate to='/project' />}
|
||||||
{category ? (
|
</>
|
||||||
|
)
|
||||||
|
|
||||||
|
if (categoriesLoading || categoryLoading) return (
|
||||||
|
<Spinner fullScreen color={role || 'client'} />
|
||||||
|
);
|
||||||
|
|
||||||
|
if (categoriesError || categoryError || !category) return (
|
||||||
|
<Wrapper color={role}>
|
||||||
|
<Box
|
||||||
|
width='100%'
|
||||||
|
height='100vh'
|
||||||
|
display='grid'
|
||||||
|
alignItems='center'
|
||||||
|
justifyContent='center'
|
||||||
|
>
|
||||||
|
<Box>
|
||||||
|
<Empty />
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</Wrapper>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
<Box padding='35px 45px 0px 120px'>
|
<Box padding='35px 45px 0px 120px'>
|
||||||
<Box
|
<Box
|
||||||
@@ -87,32 +106,6 @@ const Category = () => {
|
|||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
) : (
|
|
||||||
<Wrapper color={role}>
|
|
||||||
<Box
|
|
||||||
width='100%'
|
|
||||||
height='100vh'
|
|
||||||
display='grid'
|
|
||||||
alignItems='center'
|
|
||||||
justifyContent='center'
|
|
||||||
>
|
|
||||||
<Box>
|
|
||||||
<Empty />
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
</Wrapper>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<Spinner fullScreen color={role || 'client'} />
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
{role === 'admin' && <Navigate to='/clients' />}
|
|
||||||
{role === 'client' ||
|
|
||||||
(role === 'productOwner' && <Navigate to='/project' />)}
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import {
|
|||||||
Modal,
|
Modal,
|
||||||
} from '../../components';
|
} from '../../components';
|
||||||
import { Wrapper } from './styles';
|
import { Wrapper } from './styles';
|
||||||
import { ArrowLeft, General } from '../../assets';
|
import { ArrowLeft, Empty, General } from '../../assets';
|
||||||
import {
|
import {
|
||||||
CategoryOutput,
|
CategoryOutput,
|
||||||
DeleteCategoryMutation,
|
DeleteCategoryMutation,
|
||||||
@@ -44,14 +44,13 @@ const CategorySettings = () => {
|
|||||||
const [deleteCategoryModal, setDeleteCategoryModal] =
|
const [deleteCategoryModal, setDeleteCategoryModal] =
|
||||||
useState<boolean>(false);
|
useState<boolean>(false);
|
||||||
|
|
||||||
const [getCategory, { loading: categoryLoading }] = useLazyQuery<
|
const [getCategory, { loading: categoryLoading, error: categoryError }] = useLazyQuery<
|
||||||
GetCategoryByIdQuery,
|
GetCategoryByIdQuery,
|
||||||
GetCategoryByIdQueryVariables
|
GetCategoryByIdQueryVariables
|
||||||
>(GET_CATEGORY_BY_ID, {
|
>(GET_CATEGORY_BY_ID, {
|
||||||
onCompleted({ getCategoryById }) {
|
onCompleted({ getCategoryById }) {
|
||||||
setCategory(getCategoryById);
|
setCategory(getCategoryById);
|
||||||
},
|
}
|
||||||
fetchPolicy: 'network-only',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const [updateCategory, { loading }] = useMutation<
|
const [updateCategory, { loading }] = useMutation<
|
||||||
@@ -84,8 +83,6 @@ const CategorySettings = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getCategory({ variables: { id: id as string } });
|
getCategory({ variables: { id: id as string } });
|
||||||
|
|
||||||
// eslint-disable-next-line
|
|
||||||
}, [id]);
|
}, [id]);
|
||||||
|
|
||||||
const form = useFormik({
|
const form = useFormik({
|
||||||
@@ -116,7 +113,34 @@ const CategorySettings = () => {
|
|||||||
enableReinitialize: true,
|
enableReinitialize: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
return role === 'developer' ? (
|
if (role !== 'developer') return (
|
||||||
|
<>
|
||||||
|
{role === 'admin' && <Navigate to='/clients' />}
|
||||||
|
{['client', 'productOwer'].includes(role as string) && <Navigate to='/project' />}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
|
||||||
|
if (categoryLoading) return (
|
||||||
|
<Spinner fullScreen color={role || 'client'} />
|
||||||
|
);
|
||||||
|
|
||||||
|
if (categoryError || !category) return (
|
||||||
|
<Wrapper color={role}>
|
||||||
|
<Box
|
||||||
|
width='100%'
|
||||||
|
height='100vh'
|
||||||
|
display='grid'
|
||||||
|
alignItems='center'
|
||||||
|
justifyContent='center'
|
||||||
|
>
|
||||||
|
<Box>
|
||||||
|
<Empty />
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</Wrapper>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
{deleteCategoryModal && (
|
{deleteCategoryModal && (
|
||||||
<Modal
|
<Modal
|
||||||
@@ -176,7 +200,6 @@ const CategorySettings = () => {
|
|||||||
<Alert color='success' text='Category updated successfully' />
|
<Alert color='success' text='Category updated successfully' />
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
{!categoryLoading ? (
|
|
||||||
<form onSubmit={form.handleSubmit}>
|
<form onSubmit={form.handleSubmit}>
|
||||||
<Box
|
<Box
|
||||||
display='grid'
|
display='grid'
|
||||||
@@ -262,20 +285,9 @@ const CategorySettings = () => {
|
|||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
</form>
|
</form>
|
||||||
) : (
|
|
||||||
<Box display='grid' alignItems='center' justifyContent='center'>
|
|
||||||
<Spinner color={role || 'client'} />
|
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
{role === 'admin' && <Navigate to='/clients' />}
|
|
||||||
{role === 'client' ||
|
|
||||||
(role === 'productOwner' && <Navigate to='/project' />)}
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -172,7 +172,11 @@ const CreateUser = () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return role === 'admin' ? (
|
if (role !== 'admin') return (
|
||||||
|
<Navigate to='/' />
|
||||||
|
)
|
||||||
|
|
||||||
|
return (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
<Box>
|
<Box>
|
||||||
<Button
|
<Button
|
||||||
@@ -470,8 +474,6 @@ const CreateUser = () => {
|
|||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
) : (
|
|
||||||
<Navigate to='/' />
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+31
-38
@@ -28,24 +28,22 @@ const Feature = () => {
|
|||||||
const { id } = useParams<{ id: string }>();
|
const { id } = useParams<{ id: string }>();
|
||||||
const [feature, setFeature] = useState<FeatureOutput>();
|
const [feature, setFeature] = useState<FeatureOutput>();
|
||||||
|
|
||||||
const [getFeatures, { loading: featuresLoading }] = useLazyQuery<
|
const [getFeatures, { loading: featuresLoading, error: featuresError }] = useLazyQuery<
|
||||||
GetAllFeaturesQuery,
|
GetAllFeaturesQuery,
|
||||||
GetAllFeaturesQueryVariables
|
GetAllFeaturesQueryVariables
|
||||||
>(GET_ALL_FEATURES, {
|
>(GET_ALL_FEATURES, {
|
||||||
onCompleted({ getAllFeatures }) {
|
onCompleted({ getAllFeatures }) {
|
||||||
setFeature(getAllFeatures[0]);
|
setFeature(getAllFeatures[0]);
|
||||||
},
|
}
|
||||||
fetchPolicy: 'network-only',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const [getFeature, { loading: featureLoading }] = useLazyQuery<
|
const [getFeature, { loading: featureLoading, error: featureError }] = useLazyQuery<
|
||||||
GetFeatureByIdQuery,
|
GetFeatureByIdQuery,
|
||||||
GetFeatureByIdQueryVariables
|
GetFeatureByIdQueryVariables
|
||||||
>(GET_FEATURE_BY_ID, {
|
>(GET_FEATURE_BY_ID, {
|
||||||
onCompleted({ getFeatureById }) {
|
onCompleted({ getFeatureById }) {
|
||||||
setFeature(getFeatureById);
|
setFeature(getFeatureById);
|
||||||
},
|
}
|
||||||
fetchPolicy: 'network-only',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -54,15 +52,36 @@ const Feature = () => {
|
|||||||
} else {
|
} else {
|
||||||
getFeatures();
|
getFeatures();
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line
|
|
||||||
}, [id]);
|
}, [id]);
|
||||||
|
|
||||||
return role === 'developer' ? (
|
if (role !== 'developer') return (
|
||||||
<>
|
<>
|
||||||
{!featuresLoading && !featureLoading ? (
|
{role === 'admin' && <Navigate to='/clients' />}
|
||||||
<>
|
{['client', 'productOwer'].includes(role as string) && <Navigate to='/project' />}
|
||||||
{feature ? (
|
</>
|
||||||
|
);
|
||||||
|
|
||||||
|
if (featureLoading || featureLoading) return (
|
||||||
|
<Spinner fullScreen color={role || 'client'} />
|
||||||
|
);
|
||||||
|
|
||||||
|
if (featuresError || featureError || !feature) return (
|
||||||
|
<Wrapper color={role}>
|
||||||
|
<Box
|
||||||
|
width='100%'
|
||||||
|
height='100vh'
|
||||||
|
display='grid'
|
||||||
|
alignItems='center'
|
||||||
|
justifyContent='center'
|
||||||
|
>
|
||||||
|
<Box>
|
||||||
|
<Empty />
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</Wrapper>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
<Box padding='35px 45px 0px 120px'>
|
<Box padding='35px 45px 0px 120px'>
|
||||||
<Box
|
<Box
|
||||||
@@ -154,32 +173,6 @@ const Feature = () => {
|
|||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
) : (
|
|
||||||
<Wrapper color={role}>
|
|
||||||
<Box
|
|
||||||
width='100%'
|
|
||||||
height='100vh'
|
|
||||||
display='grid'
|
|
||||||
alignItems='center'
|
|
||||||
justifyContent='center'
|
|
||||||
>
|
|
||||||
<Box>
|
|
||||||
<Empty />
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
</Wrapper>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<Spinner fullScreen color={role || 'client'} />
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
{role === 'admin' && <Navigate to='/clients' />}
|
|
||||||
{role === 'client' ||
|
|
||||||
(role === 'productOwner' && <Navigate to='/project' />)}
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import {
|
|||||||
ImagePreview,
|
ImagePreview,
|
||||||
} from '../../components';
|
} from '../../components';
|
||||||
import { Wrapper } from './styles';
|
import { Wrapper } from './styles';
|
||||||
import { ArrowLeft, Design, General } from '../../assets';
|
import { ArrowLeft, Design, Empty, General } from '../../assets';
|
||||||
import {
|
import {
|
||||||
DeleteFeatureMutation,
|
DeleteFeatureMutation,
|
||||||
DeleteFeatureMutationVariables,
|
DeleteFeatureMutationVariables,
|
||||||
@@ -59,14 +59,13 @@ const FeatureSettings = () => {
|
|||||||
|
|
||||||
const [deleteFeatureModal, setDeleteFeatureModal] = useState<boolean>(false);
|
const [deleteFeatureModal, setDeleteFeatureModal] = useState<boolean>(false);
|
||||||
|
|
||||||
const [getFeature, { loading: featureLoading }] = useLazyQuery<
|
const [getFeature, { loading: featureLoading, error: featureError }] = useLazyQuery<
|
||||||
GetFeatureByIdQuery,
|
GetFeatureByIdQuery,
|
||||||
GetFeatureByIdQueryVariables
|
GetFeatureByIdQueryVariables
|
||||||
>(GET_FEATURE_BY_ID, {
|
>(GET_FEATURE_BY_ID, {
|
||||||
onCompleted({ getFeatureById }) {
|
onCompleted({ getFeatureById }) {
|
||||||
setFeature(getFeatureById);
|
setFeature(getFeatureById);
|
||||||
},
|
}
|
||||||
fetchPolicy: 'network-only',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const [updateFeature, { loading }] = useMutation<
|
const [updateFeature, { loading }] = useMutation<
|
||||||
@@ -99,8 +98,6 @@ const FeatureSettings = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getFeature({ variables: { id: id as string } });
|
getFeature({ variables: { id: id as string } });
|
||||||
|
|
||||||
// eslint-disable-next-line
|
|
||||||
}, [id]);
|
}, [id]);
|
||||||
|
|
||||||
const generalForm = useFormik({
|
const generalForm = useFormik({
|
||||||
@@ -178,7 +175,34 @@ const FeatureSettings = () => {
|
|||||||
enableReinitialize: true,
|
enableReinitialize: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
return role === 'developer' ? (
|
if (role !== 'developer') return (
|
||||||
|
<>
|
||||||
|
{role === 'admin' && <Navigate to='/clients' />}
|
||||||
|
{['client', 'productOwer'].includes(role as string) && <Navigate to='/project' />}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
|
||||||
|
if (featureLoading || featureLoading) return (
|
||||||
|
<Spinner fullScreen color={role || 'client'} />
|
||||||
|
);
|
||||||
|
|
||||||
|
if (featureError || !feature) return (
|
||||||
|
<Wrapper color={role}>
|
||||||
|
<Box
|
||||||
|
width='100%'
|
||||||
|
height='100vh'
|
||||||
|
display='grid'
|
||||||
|
alignItems='center'
|
||||||
|
justifyContent='center'
|
||||||
|
>
|
||||||
|
<Box>
|
||||||
|
<Empty />
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</Wrapper>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
<Box>
|
<Box>
|
||||||
<Button
|
<Button
|
||||||
@@ -237,8 +261,6 @@ const FeatureSettings = () => {
|
|||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
{selectedSection === 'general' && (
|
{selectedSection === 'general' && (
|
||||||
<>
|
|
||||||
{!featureLoading ? (
|
|
||||||
<>
|
<>
|
||||||
{deleteFeatureModal && (
|
{deleteFeatureModal && (
|
||||||
<Modal
|
<Modal
|
||||||
@@ -489,12 +511,6 @@ const FeatureSettings = () => {
|
|||||||
</Box>
|
</Box>
|
||||||
</form>
|
</form>
|
||||||
</>
|
</>
|
||||||
) : (
|
|
||||||
<Box display='grid' alignItems='center' justifyContent='center'>
|
|
||||||
<Spinner color={role || 'client'} />
|
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
)}
|
)}
|
||||||
{selectedSection === 'wireframes' && (
|
{selectedSection === 'wireframes' && (
|
||||||
<form onSubmit={wireframesForm.handleSubmit}>
|
<form onSubmit={wireframesForm.handleSubmit}>
|
||||||
@@ -564,12 +580,6 @@ const FeatureSettings = () => {
|
|||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
{role === 'admin' && <Navigate to='/clients' />}
|
|
||||||
{role === 'client' ||
|
|
||||||
(role === 'productOwner' && <Navigate to='/project' />)}
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ export const Wrapper = styled.div`
|
|||||||
|
|
||||||
.feature-type {
|
.feature-type {
|
||||||
background: ${({ theme }) => theme.colors.gray.dark};
|
background: ${({ theme }) => theme.colors.gray.dark};
|
||||||
|
background-clip: text;
|
||||||
-webkit-background-clip: text;
|
-webkit-background-clip: text;
|
||||||
-webkit-text-fill-color: transparent;
|
-webkit-text-fill-color: transparent;
|
||||||
}
|
}
|
||||||
|
|||||||
+37
-64
@@ -44,10 +44,7 @@ import {
|
|||||||
GetAllUsersQueryVariables,
|
GetAllUsersQueryVariables,
|
||||||
GetProjectByIdQuery,
|
GetProjectByIdQuery,
|
||||||
GetProjectByIdQueryVariables,
|
GetProjectByIdQueryVariables,
|
||||||
GetPrototypeByIdQuery,
|
|
||||||
GetPrototypeByIdQueryVariables,
|
|
||||||
ProjectOutput,
|
ProjectOutput,
|
||||||
ProtoTypeOutput,
|
|
||||||
} from '../../graphql/types';
|
} from '../../graphql/types';
|
||||||
import {
|
import {
|
||||||
ADD_PROJECT_DESIGN,
|
ADD_PROJECT_DESIGN,
|
||||||
@@ -58,7 +55,6 @@ import {
|
|||||||
GET_ALL_PROJECTS_BY_CLIENT_ID,
|
GET_ALL_PROJECTS_BY_CLIENT_ID,
|
||||||
GET_PROJECT_BY_ID,
|
GET_PROJECT_BY_ID,
|
||||||
} from '../../graphql/project.api';
|
} from '../../graphql/project.api';
|
||||||
import { GET_PROTOTYPE_BY_ID } from '../../graphql/prototype.api';
|
|
||||||
|
|
||||||
type Transaction = {
|
type Transaction = {
|
||||||
amount: number;
|
amount: number;
|
||||||
@@ -84,14 +80,13 @@ const Project = () => {
|
|||||||
const printRef = useRef<HTMLDivElement>(null);
|
const printRef = useRef<HTMLDivElement>(null);
|
||||||
const { id } = useParams<{ id: string }>();
|
const { id } = useParams<{ id: string }>();
|
||||||
const [project, setProject] = useState<ProjectOutput>();
|
const [project, setProject] = useState<ProjectOutput>();
|
||||||
const [prototype, setPrototype] = useState<Array<ProtoTypeOutput>>();
|
|
||||||
const [error, setError] = useState<string>('');
|
const [error, setError] = useState<string>('');
|
||||||
const [designModal, setDesignModal] = useState<boolean>(false);
|
const [designModal, setDesignModal] = useState<boolean>(false);
|
||||||
const [mvpModal, setMvpModal] = useState<boolean>(false);
|
const [mvpModal, setMvpModal] = useState<boolean>(false);
|
||||||
const [fullBuildModal, setFullBuildModal] = useState<boolean>(false);
|
const [fullBuildModal, setFullBuildModal] = useState<boolean>(false);
|
||||||
const [transactionsData, setTransactionsData] = useState<TransactionData>();
|
const [transactionsData, setTransactionsData] = useState<TransactionData>();
|
||||||
|
|
||||||
const [getProjectsByClientId, { loading: clientProjectsLoading }] =
|
const [getProjectsByClientId, { loading: clientProjectsLoading, error: clientProjectsError }] =
|
||||||
useLazyQuery<
|
useLazyQuery<
|
||||||
GetAllProjectsByClientIdQuery,
|
GetAllProjectsByClientIdQuery,
|
||||||
GetAllProjectsByClientIdQueryVariables
|
GetAllProjectsByClientIdQueryVariables
|
||||||
@@ -101,39 +96,27 @@ const Project = () => {
|
|||||||
},
|
},
|
||||||
onCompleted({ getAllProjectsByClientId }) {
|
onCompleted({ getAllProjectsByClientId }) {
|
||||||
if (getAllProjectsByClientId.length > 0)
|
if (getAllProjectsByClientId.length > 0)
|
||||||
navigate(`/project/${getAllProjectsByClientId[0].id}`);
|
setProject(getAllProjectsByClientId[0]);
|
||||||
},
|
},
|
||||||
fetchPolicy: 'network-only',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const [getProjects, { loading: projectsLoading }] = useLazyQuery<
|
const [getProjects, { loading: projectsLoading, error: projectsError }] = useLazyQuery<
|
||||||
GetAllProjectsQuery,
|
GetAllProjectsQuery,
|
||||||
GetAllUsersQueryVariables
|
GetAllUsersQueryVariables
|
||||||
>(GET_ALL_PROJECTS, {
|
>(GET_ALL_PROJECTS, {
|
||||||
onCompleted({ getAllProjects }) {
|
onCompleted({ getAllProjects }) {
|
||||||
if (getAllProjects.length > 0)
|
if (getAllProjects.length > 0)
|
||||||
navigate(`/project/${getAllProjects[0].id}`);
|
setProject(getAllProjects[0]);
|
||||||
},
|
}
|
||||||
fetchPolicy: 'network-only',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const [getProject, { loading: projectLoading }] = useLazyQuery<
|
const [getProject, { loading: projectLoading, error: projectError }] = useLazyQuery<
|
||||||
GetProjectByIdQuery,
|
GetProjectByIdQuery,
|
||||||
GetProjectByIdQueryVariables
|
GetProjectByIdQueryVariables
|
||||||
>(GET_PROJECT_BY_ID, {
|
>(GET_PROJECT_BY_ID, {
|
||||||
onCompleted({ getProjectById }) {
|
onCompleted({ getProjectById }) {
|
||||||
setProject(getProjectById);
|
setProject(getProjectById);
|
||||||
},
|
}
|
||||||
fetchPolicy: 'network-only',
|
|
||||||
});
|
|
||||||
|
|
||||||
const [getPrototype, { loading: prototypeLoading }] = useLazyQuery<
|
|
||||||
GetPrototypeByIdQuery,
|
|
||||||
GetPrototypeByIdQueryVariables
|
|
||||||
>(GET_PROTOTYPE_BY_ID, {
|
|
||||||
onCompleted({ getPrototypeById }) {
|
|
||||||
setPrototype(getPrototypeById.prototype);
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const [changeProjectState] = useMutation<
|
const [changeProjectState] = useMutation<
|
||||||
@@ -194,10 +177,6 @@ const Project = () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const handlePrint = useReactToPrint({
|
|
||||||
content: () => printRef.current,
|
|
||||||
});
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (id) {
|
if (id) {
|
||||||
getProject({ variables: { id } });
|
getProject({ variables: { id } });
|
||||||
@@ -212,15 +191,11 @@ const Project = () => {
|
|||||||
return () => {
|
return () => {
|
||||||
setProject(undefined);
|
setProject(undefined);
|
||||||
};
|
};
|
||||||
|
|
||||||
// eslint-disable-next-line
|
|
||||||
}, [id, role]);
|
}, [id, role]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
(async () => {
|
(async () => {
|
||||||
if (project) {
|
if (project) {
|
||||||
getPrototype({ variables: { id: project?.template?.id } });
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const transactionsResult = await (
|
const transactionsResult = await (
|
||||||
await fetch(`${import.meta.env.VITE_PAYMENT_API}/transactions`, {
|
await fetch(`${import.meta.env.VITE_PAYMENT_API}/transactions`, {
|
||||||
@@ -239,13 +214,14 @@ const Project = () => {
|
|||||||
})();
|
})();
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
setPrototype(undefined);
|
|
||||||
setTransactionsData(undefined);
|
setTransactionsData(undefined);
|
||||||
};
|
};
|
||||||
|
|
||||||
// eslint-disable-next-line
|
|
||||||
}, [project]);
|
}, [project]);
|
||||||
|
|
||||||
|
const handlePrint = useReactToPrint({
|
||||||
|
content: () => printRef.current,
|
||||||
|
});
|
||||||
|
|
||||||
const addDesignForm = useFormik({
|
const addDesignForm = useFormik({
|
||||||
initialValues: {
|
initialValues: {
|
||||||
fileName: '',
|
fileName: '',
|
||||||
@@ -301,12 +277,31 @@ const Project = () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return role !== 'admin' ? (
|
if (role === 'admin') return (
|
||||||
<>
|
<Navigate to='/clients' />
|
||||||
{!projectsLoading &&
|
);
|
||||||
!clientProjectsLoading &&
|
|
||||||
!projectLoading &&
|
if (clientProjectsLoading || projectsLoading || projectLoading) return (
|
||||||
!prototypeLoading ? (
|
<Spinner fullScreen color={role || 'client'} />
|
||||||
|
);
|
||||||
|
|
||||||
|
if (clientProjectsError || projectsError || projectError || !project) return (
|
||||||
|
<Wrapper color={role}>
|
||||||
|
<Box
|
||||||
|
width='100%'
|
||||||
|
height='100vh'
|
||||||
|
display='grid'
|
||||||
|
alignItems='center'
|
||||||
|
justifyContent='center'
|
||||||
|
>
|
||||||
|
<Box>
|
||||||
|
<Empty />
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</Wrapper>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
<>
|
<>
|
||||||
{designModal && (
|
{designModal && (
|
||||||
<Modal
|
<Modal
|
||||||
@@ -426,7 +421,6 @@ const Project = () => {
|
|||||||
/>
|
/>
|
||||||
</Modal>
|
</Modal>
|
||||||
)}
|
)}
|
||||||
{project ? (
|
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
<Box padding='35px 45px 0px 120px'>
|
<Box padding='35px 45px 0px 120px'>
|
||||||
<Box
|
<Box
|
||||||
@@ -458,7 +452,7 @@ const Project = () => {
|
|||||||
variant='primary-action'
|
variant='primary-action'
|
||||||
text='Prototype'
|
text='Prototype'
|
||||||
iconLeft={<Design />}
|
iconLeft={<Design />}
|
||||||
disabled={!prototype}
|
disabled={!project.template.id}
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
navigate(`/prototype/${project.template.id}`)
|
navigate(`/prototype/${project.template.id}`)
|
||||||
}
|
}
|
||||||
@@ -879,28 +873,7 @@ const Project = () => {
|
|||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
) : (
|
|
||||||
<Wrapper color={role}>
|
|
||||||
<Box
|
|
||||||
width='100%'
|
|
||||||
height='100vh'
|
|
||||||
display='grid'
|
|
||||||
alignItems='center'
|
|
||||||
justifyContent='center'
|
|
||||||
>
|
|
||||||
<Box>
|
|
||||||
<Empty />
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
</Wrapper>
|
|
||||||
)}
|
|
||||||
</>
|
</>
|
||||||
) : (
|
|
||||||
<Spinner fullScreen color={role || 'client'} />
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<Navigate to='/clients' />
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -6,12 +6,7 @@ import ReactFlow, {
|
|||||||
ControlButton,
|
ControlButton,
|
||||||
Connection,
|
Connection,
|
||||||
Edge,
|
Edge,
|
||||||
Node,
|
|
||||||
MarkerType,
|
MarkerType,
|
||||||
applyNodeChanges,
|
|
||||||
applyEdgeChanges,
|
|
||||||
NodeChange,
|
|
||||||
EdgeChange,
|
|
||||||
useEdgesState,
|
useEdgesState,
|
||||||
useNodesState
|
useNodesState
|
||||||
} from 'reactflow';
|
} from 'reactflow';
|
||||||
@@ -65,17 +60,16 @@ const Prototype = () => {
|
|||||||
const [success, setSuccess] = useState<boolean>(false);
|
const [success, setSuccess] = useState<boolean>(false);
|
||||||
const diagramParentRef = useRef<HTMLDivElement>(null);
|
const diagramParentRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
const [getTemplate, { loading: templateLoading }] = useLazyQuery<
|
const [getTemplate, { loading: templateLoading, error: templateError }] = useLazyQuery<
|
||||||
GetTemplateByIdQuery,
|
GetTemplateByIdQuery,
|
||||||
GetTemplateByIdQueryVariables
|
GetTemplateByIdQueryVariables
|
||||||
>(GET_TEMPLATE_BY_ID, {
|
>(GET_TEMPLATE_BY_ID, {
|
||||||
onCompleted({ getTemplateById }) {
|
onCompleted({ getTemplateById }) {
|
||||||
setTemplate(getTemplateById);
|
setTemplate(getTemplateById);
|
||||||
},
|
},
|
||||||
fetchPolicy: 'network-only',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const [getPrototype, { loading: prototypeLoading }] = useLazyQuery<
|
const [getPrototype, { loading: prototypeLoading, error: prototypeError }] = useLazyQuery<
|
||||||
GetPrototypeByIdQuery,
|
GetPrototypeByIdQuery,
|
||||||
GetPrototypeByIdQueryVariables
|
GetPrototypeByIdQueryVariables
|
||||||
>(GET_PROTOTYPE_BY_ID, {
|
>(GET_PROTOTYPE_BY_ID, {
|
||||||
@@ -197,13 +191,31 @@ const Prototype = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return role === 'productOwner' ||
|
if (role === 'admin') return (
|
||||||
role === 'developer' ||
|
<Navigate to='/clients' />
|
||||||
role === 'client' ? (
|
)
|
||||||
<>
|
|
||||||
{!templateLoading && !prototypeLoading ? (
|
if (templateLoading || prototypeLoading) return (
|
||||||
<>
|
<Spinner fullScreen color={role || 'client'} />
|
||||||
{template ? (
|
);
|
||||||
|
|
||||||
|
if (templateError || prototypeError || !template || !prototype) return (
|
||||||
|
<Wrapper color={role}>
|
||||||
|
<Box
|
||||||
|
width='100%'
|
||||||
|
height='100vh'
|
||||||
|
display='grid'
|
||||||
|
alignItems='center'
|
||||||
|
justifyContent='center'
|
||||||
|
>
|
||||||
|
<Box>
|
||||||
|
<Empty />
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</Wrapper>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
<Wrapper color={role}>
|
<Wrapper color={role}>
|
||||||
<Box padding='35px 45px 0px 120px'>
|
<Box padding='35px 45px 0px 120px'>
|
||||||
<Box
|
<Box
|
||||||
@@ -327,28 +339,6 @@ const Prototype = () => {
|
|||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
) : (
|
|
||||||
<Wrapper color={role}>
|
|
||||||
<Box
|
|
||||||
width='100%'
|
|
||||||
height='100vh'
|
|
||||||
display='grid'
|
|
||||||
alignItems='center'
|
|
||||||
justifyContent='center'
|
|
||||||
>
|
|
||||||
<Box>
|
|
||||||
<Empty />
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
</Wrapper>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<Spinner fullScreen color={role || 'client'} />
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<>{role === 'admin' && <Navigate to='/clients' />}</>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import {
|
|||||||
import { theme } from '../../themes';
|
import { theme } from '../../themes';
|
||||||
import { clientSupport } from '../..';
|
import { clientSupport } from '../..';
|
||||||
|
|
||||||
const SupportMessaging = () => {
|
const Support = () => {
|
||||||
const { project, id } = useParams<{ id: string; project: string }>();
|
const { project, id } = useParams<{ id: string; project: string }>();
|
||||||
const role = useReactiveVar(roleVar);
|
const role = useReactiveVar(roleVar);
|
||||||
const currentUser = useReactiveVar(userVar);
|
const currentUser = useReactiveVar(userVar);
|
||||||
@@ -97,8 +97,6 @@ const SupportMessaging = () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
// eslint-disable-next-line
|
|
||||||
}, [id]);
|
}, [id]);
|
||||||
|
|
||||||
const createThreadForm = useFormik({
|
const createThreadForm = useFormik({
|
||||||
@@ -123,7 +121,7 @@ const SupportMessaging = () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
navigate(
|
navigate(
|
||||||
`/support-messaging/${project}/${createdThread.data?.createThread}`
|
`/support/${project}/${createdThread.data?.createThread}`
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -338,4 +336,4 @@ const SupportMessaging = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default SupportMessaging;
|
export default Support;
|
||||||
@@ -22,11 +22,8 @@ import {
|
|||||||
GetAllTemplatesQueryVariables,
|
GetAllTemplatesQueryVariables,
|
||||||
GetCategoryByIdQuery,
|
GetCategoryByIdQuery,
|
||||||
GetCategoryByIdQueryVariables,
|
GetCategoryByIdQueryVariables,
|
||||||
GetPrototypeByIdQuery,
|
|
||||||
GetPrototypeByIdQueryVariables,
|
|
||||||
GetTemplateByIdQuery,
|
GetTemplateByIdQuery,
|
||||||
GetTemplateByIdQueryVariables,
|
GetTemplateByIdQueryVariables,
|
||||||
ProtoTypeOutput,
|
|
||||||
TemplateOutput,
|
TemplateOutput,
|
||||||
} from '../../graphql/types';
|
} from '../../graphql/types';
|
||||||
import {
|
import {
|
||||||
@@ -34,7 +31,6 @@ import {
|
|||||||
GET_TEMPLATE_BY_ID,
|
GET_TEMPLATE_BY_ID,
|
||||||
} from '../../graphql/template.api';
|
} from '../../graphql/template.api';
|
||||||
import { GET_CATEGORY_BY_ID } from '../../graphql/category.api';
|
import { GET_CATEGORY_BY_ID } from '../../graphql/category.api';
|
||||||
import { GET_PROTOTYPE_BY_ID } from '../../graphql/prototype.api';
|
|
||||||
|
|
||||||
const Template = () => {
|
const Template = () => {
|
||||||
const role = useReactiveVar(roleVar);
|
const role = useReactiveVar(roleVar);
|
||||||
@@ -43,78 +39,83 @@ const Template = () => {
|
|||||||
const { id } = useParams<{ id: string }>();
|
const { id } = useParams<{ id: string }>();
|
||||||
const [template, setTemplate] = useState<TemplateOutput>();
|
const [template, setTemplate] = useState<TemplateOutput>();
|
||||||
const [category, setCategory] = useState<CategoryOutput>();
|
const [category, setCategory] = useState<CategoryOutput>();
|
||||||
const [prototype, setPrototype] = useState<Array<ProtoTypeOutput>>();
|
|
||||||
|
|
||||||
const [getCategory, { loading: categoryLoading }] = useLazyQuery<
|
const [getCategory, { loading: categoryLoading, error: categoryError }] = useLazyQuery<
|
||||||
GetCategoryByIdQuery,
|
GetCategoryByIdQuery,
|
||||||
GetCategoryByIdQueryVariables
|
GetCategoryByIdQueryVariables
|
||||||
>(GET_CATEGORY_BY_ID, {
|
>(GET_CATEGORY_BY_ID, {
|
||||||
onCompleted({ getCategoryById }) {
|
onCompleted({ getCategoryById }) {
|
||||||
setCategory(getCategoryById);
|
setCategory(getCategoryById);
|
||||||
},
|
}
|
||||||
fetchPolicy: 'network-only',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const [getTemplates, { loading: templatesLoading }] = useLazyQuery<
|
const [getTemplates, { loading: templatesLoading, error: templatesError }] = useLazyQuery<
|
||||||
GetAllTemplatesQuery,
|
GetAllTemplatesQuery,
|
||||||
GetAllTemplatesQueryVariables
|
GetAllTemplatesQueryVariables
|
||||||
>(GET_ALL_TEMPLATES, {
|
>(GET_ALL_TEMPLATES, {
|
||||||
onCompleted({ getAllTemplates }) {
|
onCompleted({ getAllTemplates }) {
|
||||||
if (getAllTemplates.length > 0)
|
if (getAllTemplates.length > 0) {
|
||||||
navigate(`/template/${getAllTemplates[0].id}`);
|
setTemplate(getAllTemplates[0]);
|
||||||
},
|
getCategory({ variables: { id: getAllTemplates[0]?.category! } });
|
||||||
fetchPolicy: 'network-only',
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const [getTemplate, { loading: templateLoading }] = useLazyQuery<
|
const [getTemplate, { loading: templateLoading, error: templateError }] = useLazyQuery<
|
||||||
GetTemplateByIdQuery,
|
GetTemplateByIdQuery,
|
||||||
GetTemplateByIdQueryVariables
|
GetTemplateByIdQueryVariables
|
||||||
>(GET_TEMPLATE_BY_ID, {
|
>(GET_TEMPLATE_BY_ID, {
|
||||||
onCompleted({ getTemplateById }) {
|
onCompleted({ getTemplateById }) {
|
||||||
setTemplate(getTemplateById);
|
setTemplate(getTemplateById);
|
||||||
getCategory({ variables: { id: template?.category! } });
|
getCategory({ variables: { id: getTemplateById?.category! } });
|
||||||
},
|
}
|
||||||
fetchPolicy: 'network-only',
|
|
||||||
});
|
|
||||||
|
|
||||||
const [getPrototype, { loading: prototypeLoading }] = useLazyQuery<
|
|
||||||
GetPrototypeByIdQuery,
|
|
||||||
GetPrototypeByIdQueryVariables
|
|
||||||
>(GET_PROTOTYPE_BY_ID, {
|
|
||||||
onCompleted({ getPrototypeById }) {
|
|
||||||
if (getPrototypeById) setPrototype(getPrototypeById.prototype);
|
|
||||||
},
|
|
||||||
fetchPolicy: 'network-only',
|
|
||||||
});
|
|
||||||
|
|
||||||
const handlePrint = useReactToPrint({
|
|
||||||
content: () => printRef.current,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (id) {
|
if (id) {
|
||||||
getTemplate({ variables: { id } });
|
getTemplate({ variables: { id } });
|
||||||
getPrototype({ variables: { id } });
|
|
||||||
} else {
|
} else {
|
||||||
getTemplates();
|
getTemplates();
|
||||||
}
|
}
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
setTemplate(undefined);
|
setTemplate(undefined);
|
||||||
setPrototype(undefined);
|
setCategory(undefined);
|
||||||
};
|
};
|
||||||
|
|
||||||
// eslint-disable-next-line
|
|
||||||
}, [id]);
|
}, [id]);
|
||||||
|
|
||||||
return role === 'productOwner' || role === 'developer' ? (
|
const handlePrint = useReactToPrint({
|
||||||
|
content: () => printRef.current,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (role !== 'productOwner' && role !== 'developer') return (
|
||||||
<>
|
<>
|
||||||
{!templatesLoading &&
|
{role === 'admin' && <Navigate to='/clients' />}
|
||||||
!templateLoading &&
|
{role === 'client' && <Navigate to='/project' />}
|
||||||
!categoryLoading &&
|
</>
|
||||||
!prototypeLoading ? (
|
);
|
||||||
<>
|
|
||||||
{template ? (
|
if (templatesLoading || templateLoading || categoryLoading) return (
|
||||||
|
<Spinner fullScreen color={role || 'client'} />
|
||||||
|
);
|
||||||
|
|
||||||
|
if (templatesError || templateError || categoryError || !template) return (
|
||||||
|
<Wrapper color={role}>
|
||||||
|
<Box
|
||||||
|
width='100%'
|
||||||
|
height='100vh'
|
||||||
|
display='grid'
|
||||||
|
alignItems='center'
|
||||||
|
justifyContent='center'
|
||||||
|
>
|
||||||
|
<Box>
|
||||||
|
<Empty />
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</Wrapper>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
<Box padding='35px 45px 0px 120px'>
|
<Box padding='35px 45px 0px 120px'>
|
||||||
<Box
|
<Box
|
||||||
@@ -147,7 +148,7 @@ const Template = () => {
|
|||||||
text='Prototype'
|
text='Prototype'
|
||||||
iconLeft={<Design />}
|
iconLeft={<Design />}
|
||||||
disabled={
|
disabled={
|
||||||
prototype === undefined && role === 'productOwner'
|
role === 'productOwner'
|
||||||
}
|
}
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
navigate(`/prototype/${id || template.id}`)
|
navigate(`/prototype/${id || template.id}`)
|
||||||
@@ -245,31 +246,6 @@ const Template = () => {
|
|||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
) : (
|
|
||||||
<Wrapper color={role}>
|
|
||||||
<Box
|
|
||||||
width='100%'
|
|
||||||
height='100vh'
|
|
||||||
display='grid'
|
|
||||||
alignItems='center'
|
|
||||||
justifyContent='center'
|
|
||||||
>
|
|
||||||
<Box>
|
|
||||||
<Empty />
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
</Wrapper>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<Spinner fullScreen color={role || 'client'} />
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
{role === 'admin' && <Navigate to='/clients' />}
|
|
||||||
{role === 'client' && <Navigate to='/project' />}
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import {
|
|||||||
UpdateProjectMutationVariables,
|
UpdateProjectMutationVariables,
|
||||||
} from '../../graphql/types';
|
} from '../../graphql/types';
|
||||||
import { GET_PROJECT_BY_ID, UPDATE_PROJECT } from '../../graphql/project.api';
|
import { GET_PROJECT_BY_ID, UPDATE_PROJECT } from '../../graphql/project.api';
|
||||||
import { ArrowLeft } from '../../assets';
|
import { ArrowLeft, Empty } from '../../assets';
|
||||||
import { theme } from '../../themes';
|
import { theme } from '../../themes';
|
||||||
|
|
||||||
const UpdateProject = () => {
|
const UpdateProject = () => {
|
||||||
@@ -24,14 +24,13 @@ const UpdateProject = () => {
|
|||||||
const [project, setProject] = useState<ProjectOutput>();
|
const [project, setProject] = useState<ProjectOutput>();
|
||||||
const { id } = useParams<{ id: string }>();
|
const { id } = useParams<{ id: string }>();
|
||||||
|
|
||||||
const [getProject, { loading: projectLoading }] = useLazyQuery<
|
const [getProject, { loading: projectLoading, error: projectError }] = useLazyQuery<
|
||||||
GetProjectByIdQuery,
|
GetProjectByIdQuery,
|
||||||
GetProjectByIdQueryVariables
|
GetProjectByIdQueryVariables
|
||||||
>(GET_PROJECT_BY_ID, {
|
>(GET_PROJECT_BY_ID, {
|
||||||
onCompleted({ getProjectById }) {
|
onCompleted({ getProjectById }) {
|
||||||
setProject(getProjectById);
|
setProject(getProjectById);
|
||||||
},
|
}
|
||||||
fetchPolicy: 'network-only',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const [updateProject, { loading: updateProjectLoading }] = useMutation<
|
const [updateProject, { loading: updateProjectLoading }] = useMutation<
|
||||||
@@ -51,8 +50,6 @@ const UpdateProject = () => {
|
|||||||
if (id) {
|
if (id) {
|
||||||
getProject({ variables: { id } });
|
getProject({ variables: { id } });
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line
|
|
||||||
}, [id]);
|
}, [id]);
|
||||||
|
|
||||||
const basicInfoForm = useFormik({
|
const basicInfoForm = useFormik({
|
||||||
@@ -78,7 +75,27 @@ const UpdateProject = () => {
|
|||||||
enableReinitialize: true,
|
enableReinitialize: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
return !projectLoading ? (
|
if (projectLoading) return (
|
||||||
|
<Spinner fullScreen color={role || 'client'} />
|
||||||
|
);
|
||||||
|
|
||||||
|
if (projectError || !project) return (
|
||||||
|
<Wrapper color={role}>
|
||||||
|
<Box
|
||||||
|
width='100%'
|
||||||
|
height='100vh'
|
||||||
|
display='grid'
|
||||||
|
alignItems='center'
|
||||||
|
justifyContent='center'
|
||||||
|
>
|
||||||
|
<Box>
|
||||||
|
<Empty />
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</Wrapper>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
<Box padding='35px 45px 30px 120px'>
|
<Box padding='35px 45px 30px 120px'>
|
||||||
<Box
|
<Box
|
||||||
@@ -210,8 +227,6 @@ const UpdateProject = () => {
|
|||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
) : (
|
|
||||||
<Spinner fullScreen color={role || 'client'} />
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import {
|
|||||||
Spinner,
|
Spinner,
|
||||||
} from '../../components';
|
} from '../../components';
|
||||||
import { Wrapper } from './styles';
|
import { Wrapper } from './styles';
|
||||||
import { ArrowLeft, Profile, Security } from '../../assets';
|
import { ArrowLeft, Empty, Profile, Security } from '../../assets';
|
||||||
import {
|
import {
|
||||||
UpdateUserInfoMutation,
|
UpdateUserInfoMutation,
|
||||||
UpdateUserPasswordMutation,
|
UpdateUserPasswordMutation,
|
||||||
@@ -39,11 +39,17 @@ const UserSettings = () => {
|
|||||||
const role = useReactiveVar(roleVar);
|
const role = useReactiveVar(roleVar);
|
||||||
const [userToEdit, setUserToEdit] = useState<UserOutput>();
|
const [userToEdit, setUserToEdit] = useState<UserOutput>();
|
||||||
const { id } = useParams<{ id: string }>();
|
const { id } = useParams<{ id: string }>();
|
||||||
|
const [selectedSection, setSelectedSection] = useState<
|
||||||
|
'general' | 'security'
|
||||||
|
>('general');
|
||||||
|
const [error, setError] = useState<string>('');
|
||||||
|
const [success, setSuccess] = useState<boolean>(false);
|
||||||
|
|
||||||
const { data: countryCodes, loading: countryCodesLoading } = useQuery<
|
const { data: countryCodes, loading: countryCodesLoading } = useQuery<
|
||||||
GetCountryCodesQuery,
|
GetCountryCodesQuery,
|
||||||
GetCountryCodesQueryVariables
|
GetCountryCodesQueryVariables
|
||||||
>(GET_COUNTRY_CODES);
|
>(GET_COUNTRY_CODES);
|
||||||
const { loading: userInfoLoading } = useQuery<
|
const { loading: userInfoLoading, error: userInforError } = useQuery<
|
||||||
GetUserByIdQuery,
|
GetUserByIdQuery,
|
||||||
GetUserByIdQueryVariables
|
GetUserByIdQueryVariables
|
||||||
>(GET_USER_BY_ID, {
|
>(GET_USER_BY_ID, {
|
||||||
@@ -55,12 +61,6 @@ const UserSettings = () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const [selectedSection, setSelectedSection] = useState<
|
|
||||||
'general' | 'security'
|
|
||||||
>('general');
|
|
||||||
const [error, setError] = useState<string>('');
|
|
||||||
const [success, setSuccess] = useState<boolean>(false);
|
|
||||||
|
|
||||||
const [updateUserInfo, { loading: generalLoading }] = useMutation<
|
const [updateUserInfo, { loading: generalLoading }] = useMutation<
|
||||||
UpdateUserInfoMutation,
|
UpdateUserInfoMutation,
|
||||||
UpdateUserInfoMutationVariables
|
UpdateUserInfoMutationVariables
|
||||||
@@ -182,7 +182,27 @@ const UserSettings = () => {
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
return role === 'admin' ? (
|
if (role !== 'admin') return (
|
||||||
|
<Navigate to='/' />
|
||||||
|
)
|
||||||
|
|
||||||
|
if (userInforError || !userToEdit) return (
|
||||||
|
<Wrapper color={role}>
|
||||||
|
<Box
|
||||||
|
width='100%'
|
||||||
|
height='100vh'
|
||||||
|
display='grid'
|
||||||
|
alignItems='center'
|
||||||
|
justifyContent='center'
|
||||||
|
>
|
||||||
|
<Box>
|
||||||
|
<Empty />
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</Wrapper>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
<Box>
|
<Box>
|
||||||
<Button
|
<Button
|
||||||
@@ -480,8 +500,6 @@ const UserSettings = () => {
|
|||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
) : (
|
|
||||||
<Navigate to='/' />
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+27
-13
@@ -12,7 +12,7 @@ import {
|
|||||||
Text,
|
Text,
|
||||||
Modal,
|
Modal,
|
||||||
Input,
|
Input,
|
||||||
Alert,
|
Alert
|
||||||
} from '../../components';
|
} from '../../components';
|
||||||
import { Wrapper } from './styles';
|
import { Wrapper } from './styles';
|
||||||
import {
|
import {
|
||||||
@@ -34,7 +34,7 @@ const Users = () => {
|
|||||||
const [error, setError] = useState<string>('');
|
const [error, setError] = useState<string>('');
|
||||||
const [deleteAccountModal, setDeleteAccountModal] = useState<boolean>(false);
|
const [deleteAccountModal, setDeleteAccountModal] = useState<boolean>(false);
|
||||||
|
|
||||||
const [getUsers, { loading }] = useLazyQuery<
|
const [getUsers, { loading, error: usersError }] = useLazyQuery<
|
||||||
GetAllUsersQuery,
|
GetAllUsersQuery,
|
||||||
GetAllUsersQueryVariables
|
GetAllUsersQueryVariables
|
||||||
>(GET_ALL_USERS, {
|
>(GET_ALL_USERS, {
|
||||||
@@ -52,8 +52,6 @@ const Users = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getUsers();
|
getUsers();
|
||||||
|
|
||||||
// eslint-disable-next-line
|
|
||||||
}, [location.pathname]);
|
}, [location.pathname]);
|
||||||
|
|
||||||
const [deleteUser] = useMutation<
|
const [deleteUser] = useMutation<
|
||||||
@@ -90,9 +88,31 @@ const Users = () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return role === 'admin' ? (
|
if (role !== 'admin') return (
|
||||||
<>
|
<Navigate to='/' />
|
||||||
{!loading ? (
|
)
|
||||||
|
|
||||||
|
if (loading) return (
|
||||||
|
<Spinner fullScreen color={role || 'client'} />
|
||||||
|
);
|
||||||
|
|
||||||
|
if (usersError || !users) return (
|
||||||
|
<Wrapper color={role}>
|
||||||
|
<Box
|
||||||
|
width='100%'
|
||||||
|
height='100vh'
|
||||||
|
display='grid'
|
||||||
|
alignItems='center'
|
||||||
|
justifyContent='center'
|
||||||
|
>
|
||||||
|
<Box>
|
||||||
|
<Empty />
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</Wrapper>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
<>
|
<>
|
||||||
{deleteAccountModal && (
|
{deleteAccountModal && (
|
||||||
<Modal
|
<Modal
|
||||||
@@ -297,12 +317,6 @@ const Users = () => {
|
|||||||
</Wrapper>
|
</Wrapper>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
) : (
|
|
||||||
<Spinner fullScreen color={role || 'client'} />
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<Navigate to='/clients' />
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import styled from 'styled-components';
|
|||||||
|
|
||||||
type WrapperProps = {
|
type WrapperProps = {
|
||||||
color?: 'client' | 'productOwner' | 'developer' | 'admin';
|
color?: 'client' | 'productOwner' | 'developer' | 'admin';
|
||||||
empty: boolean;
|
empty?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Wrapper = styled.div<WrapperProps>`
|
export const Wrapper = styled.div<WrapperProps>`
|
||||||
@@ -11,6 +11,7 @@ export const Wrapper = styled.div<WrapperProps>`
|
|||||||
.table-head {
|
.table-head {
|
||||||
p {
|
p {
|
||||||
background: ${({ theme }) => theme.colors.gray.dark};
|
background: ${({ theme }) => theme.colors.gray.dark};
|
||||||
|
background-clip: text;
|
||||||
-webkit-background-clip: text;
|
-webkit-background-clip: text;
|
||||||
-webkit-text-fill-color: transparent;
|
-webkit-text-fill-color: transparent;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -21,7 +21,7 @@ import TemplateSettings from './TemplateSettings';
|
|||||||
import AddProject from './AddProject';
|
import AddProject from './AddProject';
|
||||||
import UpdateProject from './UpdateProject';
|
import UpdateProject from './UpdateProject';
|
||||||
import Payments from './Payments';
|
import Payments from './Payments';
|
||||||
import SupportMessaging from './SupportMessaging';
|
import Support from './Support';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
Login,
|
Login,
|
||||||
@@ -47,5 +47,5 @@ export {
|
|||||||
AddProject,
|
AddProject,
|
||||||
UpdateProject,
|
UpdateProject,
|
||||||
Payments,
|
Payments,
|
||||||
SupportMessaging,
|
Support,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user