move move frontend to progress-test

This commit is contained in:
João Geonizeli
2022-07-21 21:16:59 -03:00
parent f8d5d08447
commit 386050d4ad
129 changed files with 159374 additions and 39 deletions

View File

@@ -0,0 +1,39 @@
import React, { FC, useContext } from 'react'
import { Control, FieldValues } from 'react-hook-form';
import { Question } from '../../../__generated__/graphql-schema';
type FormContextHooks = {
register: any
setValue: Function
control: Control<FieldValues>
}
type FormContextProps = {
hooks: FormContextHooks
question?: Question
}
const FormContext = React.createContext<FormContextProps | null>(null);
export const useFormProvider = () => {
const context = useContext(FormContext)
if (context === null) {
throw new Error('You probably forgot to put <FormProvider>.')
}
return context
}
type Props = {
children?: any
props: FormContextProps
}
export const FormProvider: FC<Props> = ({ children, props }) => {
return (
<FormContext.Provider value={props}>
{children}
</FormContext.Provider>
)
}