diff --git a/apps/web/components/Form/Overlay.tsx b/apps/web/components/Form/Overlay.tsx index dc50706..5a32dde 100644 --- a/apps/web/components/Form/Overlay.tsx +++ b/apps/web/components/Form/Overlay.tsx @@ -1,44 +1,61 @@ 'use client'; import { FormContext } from './context/form-context'; import { CheckCircleIcon, XCircleIcon } from '@heroicons/react/24/solid'; -import { Background, LoadingSpinner } from '@repo/ui'; +import { Background, Button, LoadingSpinner } from '@repo/ui'; import type { PropsWithChildren } from 'react'; import { useContext } from 'react'; function OverlayWrapper({ children }: PropsWithChildren) { return ( -
+
{children}
); } + +function StateContentWrapper({ children }: PropsWithChildren) { + return
{children}
; +} + export function Overlay() { - const { formState } = useContext(FormContext); + const { formState, setFormState } = useContext(FormContext); const { status, text } = formState; - if (status === 'pending') - return ( - + let stateContent: JSX.Element | false = false; + + if (status === 'pending') { + stateContent = ( + {LoadingSpinner}

Загрузка...

-
+ ); - if (status === 'success') - return ( - - {' '} + } + if (status === 'success') { + stateContent = ( + +

Данные сохранены

-
- ); - if (status === 'error') { - return ( - - {' '} -

{text}

-
+ ); } - return false; + if (status === 'error') { + stateContent = ( + <> + + +

{text}

+
{' '} + + + ); + } + + if (!stateContent) return false; + + return {stateContent}; } diff --git a/packages/ui/button.tsx b/packages/ui/button.tsx index 701af2e..030504f 100644 --- a/packages/ui/button.tsx +++ b/packages/ui/button.tsx @@ -22,6 +22,7 @@ const variants = cva( 'border border-primary text-primary-500 hover:bg-primary-500 hover:text-white', secondary: 'bg-primary-50 text-primary-500 border border-transparent hover:bg-primary-100 hover:text-primary-600', + text: 'bg-none text-primary-500 hover:bg-primary-50', }, }, }