diff --git a/apps/web/components/Form/base-form.tsx b/apps/web/components/Form/base-form.tsx index 27ab531..15d3878 100644 --- a/apps/web/components/Form/base-form.tsx +++ b/apps/web/components/Form/base-form.tsx @@ -11,7 +11,7 @@ const { TELEGRAM_BOT_URL } = publicRuntimeConfig; export function BaseForm({ children, onSubmit }: FormProps & PropsWithChildren) { const { handleSubmit, register } = useForm(); const { - state: { error, step }, + state: { error, step, tfa }, } = useContext(FormStateContext); return ( @@ -32,7 +32,7 @@ export function BaseForm({ children, onSubmit }: FormProps & PropsWithChildren) autoComplete="on" {...register('password', { required: true })} /> - {step === 'telegram-login' ? ( + {tfa ? ( Открыть чат с ботом diff --git a/apps/web/context/form-state.tsx b/apps/web/context/form-state.tsx index db884ee..55e025d 100644 --- a/apps/web/context/form-state.tsx +++ b/apps/web/context/form-state.tsx @@ -6,6 +6,7 @@ import { createContext, useMemo, useReducer } from 'react'; type State = { error: string | undefined; step: 'login' | 'telegram' | 'telegram-login'; + tfa: boolean; user: LdapUser | undefined; }; @@ -59,13 +60,15 @@ type Context = { export const FormStateContext = createContext({} as Context); type FormStateProviderProps = { + readonly tfa: boolean; readonly user?: LdapUser; } & PropsWithChildren; -export function FormStateProvider({ children, user = undefined }: FormStateProviderProps) { +export function FormStateProvider({ children, tfa, user = undefined }: FormStateProviderProps) { const [state, dispatch] = useReducer(reducer, { error: undefined, step: 'login', + tfa, user, });