mirror of
https://github.com/hazemKrimi/crimson-quirks-ui.git
synced 2026-05-01 18:20:28 +00:00
Update template page
This commit is contained in:
@@ -22,8 +22,11 @@ import {
|
|||||||
GetAllTemplatesQueryVariables,
|
GetAllTemplatesQueryVariables,
|
||||||
GetCategoryByIdQuery,
|
GetCategoryByIdQuery,
|
||||||
GetCategoryByIdQueryVariables,
|
GetCategoryByIdQueryVariables,
|
||||||
|
GetPrototypeByIdQuery,
|
||||||
|
GetPrototypeByIdQueryVariables,
|
||||||
GetTemplateByIdQuery,
|
GetTemplateByIdQuery,
|
||||||
GetTemplateByIdQueryVariables,
|
GetTemplateByIdQueryVariables,
|
||||||
|
ProtoTypeOutput,
|
||||||
TemplateOutput,
|
TemplateOutput,
|
||||||
} from '../../graphql/types';
|
} from '../../graphql/types';
|
||||||
import {
|
import {
|
||||||
@@ -31,6 +34,7 @@ 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);
|
||||||
@@ -39,6 +43,7 @@ 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 }] = useLazyQuery<
|
||||||
GetCategoryByIdQuery,
|
GetCategoryByIdQuery,
|
||||||
@@ -72,6 +77,15 @@ const Template = () => {
|
|||||||
fetchPolicy: 'network-only',
|
fetchPolicy: 'network-only',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const [getPrototype, { loading: prototypeLoading }] = useLazyQuery<
|
||||||
|
GetPrototypeByIdQuery,
|
||||||
|
GetPrototypeByIdQueryVariables
|
||||||
|
>(GET_PROTOTYPE_BY_ID, {
|
||||||
|
onCompleted({ getPrototypeById }) {
|
||||||
|
setPrototype(getPrototypeById.prototype);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const handlePrint = useReactToPrint({
|
const handlePrint = useReactToPrint({
|
||||||
content: () => printRef.current,
|
content: () => printRef.current,
|
||||||
});
|
});
|
||||||
@@ -79,6 +93,7 @@ const Template = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (id) {
|
if (id) {
|
||||||
getTemplate({ variables: { id } });
|
getTemplate({ variables: { id } });
|
||||||
|
getPrototype({ variables: { id } });
|
||||||
} else {
|
} else {
|
||||||
getTemplates();
|
getTemplates();
|
||||||
}
|
}
|
||||||
@@ -88,7 +103,10 @@ const Template = () => {
|
|||||||
|
|
||||||
return role === 'productOwner' || role === 'developer' ? (
|
return role === 'productOwner' || role === 'developer' ? (
|
||||||
<>
|
<>
|
||||||
{!templatesLoading && !templateLoading && !categoryLoading ? (
|
{!templatesLoading &&
|
||||||
|
!templateLoading &&
|
||||||
|
!categoryLoading &&
|
||||||
|
!prototypeLoading ? (
|
||||||
<>
|
<>
|
||||||
{template ? (
|
{template ? (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
@@ -122,7 +140,7 @@ const Template = () => {
|
|||||||
variant='primary-action'
|
variant='primary-action'
|
||||||
text='Prototype'
|
text='Prototype'
|
||||||
iconLeft={<Design />}
|
iconLeft={<Design />}
|
||||||
disabled={role === 'productOwner'}
|
disabled={!prototype && role === 'productOwner'}
|
||||||
onClick={() => history.push(`/prototype/${id}`)}
|
onClick={() => history.push(`/prototype/${id}`)}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
Reference in New Issue
Block a user