diff --git a/src/pages/Prototype/index.tsx b/src/pages/Prototype/index.tsx index 5864e21..ca2f344 100644 --- a/src/pages/Prototype/index.tsx +++ b/src/pages/Prototype/index.tsx @@ -1,29 +1,166 @@ -import { useReactiveVar } from '@apollo/client'; +import { useEffect, useState } from 'react'; +import { useHistory, useParams } from 'react-router-dom'; +import { useLazyQuery, useReactiveVar } from '@apollo/client'; import { Redirect } from 'react-router'; import { roleVar } from '../../graphql/state'; -import { Empty } from '../../assets'; -import { Box } from '../../components'; +import { Empty, ArrowLeft } from '../../assets'; +import { + Box, + Text, + Button, + Spinner, + FrontendFeatureCard, + BackendFeatureCard, +} from '../../components'; import { Wrapper } from './styles'; +import { + GetTemplateByIdQuery, + GetTemplateByIdQueryVariables, + TemplateOutput, +} from '../../graphql/types'; +import { GET_TEMPLATE_BY_ID } from '../../graphql/template.api'; const Prototype = () => { const role = useReactiveVar(roleVar); + const history = useHistory(); + const { id } = useParams<{ id: string }>(); + const [template, setTemplate] = useState(); - return role !== 'admin' ? ( - - - - - - - + const [getTemplate, { loading: templateLoading }] = useLazyQuery< + GetTemplateByIdQuery, + GetTemplateByIdQueryVariables + >(GET_TEMPLATE_BY_ID, { + onCompleted({ getTemplateById }) { + setTemplate(getTemplateById); + }, + fetchPolicy: 'network-only', + }); + + useEffect(() => { + if (id) { + getTemplate({ variables: { id } }); + } + + // eslint-disable-next-line + }, [id]); + + return role === 'productOwner' || role === 'developer' ? ( + <> + {!templateLoading ? ( + <> + {template ? ( + + + + +