From 5721ebc86993ece256a98dddba9ff3f468e80236 Mon Sep 17 00:00:00 2001 From: Kichiyaki Date: Sat, 13 Mar 2021 16:57:18 +0100 Subject: [PATCH] [WIP] --- codegen.yml | 1 + .../AppLayout/components/Sidebar/Sidebar.tsx | 7 + .../components/FormDialog/FormDialog.tsx | 75 ++++- .../components/FormDialog/constants.ts | 1 - src/features/QuestionsPage/constants.ts | 7 +- src/libs/graphql/types.ts | 276 +++++++++--------- 6 files changed, 218 insertions(+), 149 deletions(-) delete mode 100644 src/features/QuestionsPage/components/FormDialog/constants.ts diff --git a/codegen.yml b/codegen.yml index 9e3af2d..bee28c3 100644 --- a/codegen.yml +++ b/codegen.yml @@ -9,3 +9,4 @@ generates: skipTypename: true scalars: ID: number + Time: Date | string diff --git a/src/common/AppLayout/components/Sidebar/Sidebar.tsx b/src/common/AppLayout/components/Sidebar/Sidebar.tsx index 4b8e7e3..2a76837 100644 --- a/src/common/AppLayout/components/Sidebar/Sidebar.tsx +++ b/src/common/AppLayout/components/Sidebar/Sidebar.tsx @@ -16,6 +16,7 @@ import { Group as GroupIcon, Work as WorkIcon, Description as DescriptionIcon, + QuestionAnswer as QuestionAnswerIcon, } from '@material-ui/icons'; import Nav from './components/Nav/Nav'; import CurrentUser from './components/CurrentUser/CurrentUser'; @@ -51,6 +52,12 @@ const Sidebar = ({ className, open, variant, onClose, onOpen }: Props) => { exact: true, Icon: , }, + { + name: 'Pytania', + to: Route.QuestionsPage, + exact: true, + Icon: , + }, ]; useEffect(() => { diff --git a/src/features/QuestionsPage/components/FormDialog/FormDialog.tsx b/src/features/QuestionsPage/components/FormDialog/FormDialog.tsx index db3ba03..28a57f0 100644 --- a/src/features/QuestionsPage/components/FormDialog/FormDialog.tsx +++ b/src/features/QuestionsPage/components/FormDialog/FormDialog.tsx @@ -1,7 +1,6 @@ -import { useForm } from 'react-hook-form'; +import { useForm, Controller } from 'react-hook-form'; import { pick } from 'lodash'; -import { MAX_NAME_LENGTH } from './constants'; -import { QuestionInput, Question } from 'libs/graphql/types'; +import { QuestionInput, Question, Maybe, Answer } from 'libs/graphql/types'; import { makeStyles } from '@material-ui/core/styles'; import { @@ -11,9 +10,11 @@ import { DialogContent, DialogProps, DialogTitle, + MenuItem, TextField, } from '@material-ui/core'; -import { Maybe } from 'graphql/jsutils/Maybe'; + +const ANSWERS = Object.keys(Answer); export interface FormDialogProps extends Pick { question?: Maybe; @@ -27,6 +28,7 @@ const FormDialog = ({ open, onClose, question, onSubmit }: FormDialogProps) => { register, handleSubmit, errors, + control, formState: { isSubmitting }, } = useForm({}); const classes = useStyles(); @@ -59,18 +61,73 @@ const FormDialog = ({ open, onClose, question, onSubmit }: FormDialogProps) => { + + + + {ANSWERS.map(answer => ( + + {answer} + + ))} + + } + /> + {ANSWERS.map(answer => { + const upper = answer.toUpperCase(); + return ( + //(question as any)[`answer${upper}`] + + ); + })}