From 39c13e94221803c6ea4291fed4ee1c526153d751 Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Thu, 23 Nov 2023 17:06:58 +0300 Subject: [PATCH] apps/web: fix layout --- apps/web/app/layout.tsx | 6 +- apps/web/components/Conditions.tsx | 2 +- apps/web/components/Form/Elements.tsx | 90 +++++++++++++++---------- apps/web/components/Form/Header.tsx | 2 +- apps/web/components/Form/Overlay.tsx | 2 +- apps/web/components/Form/index.tsx | 2 +- apps/web/components/layout/controls.tsx | 2 +- packages/ui/container.tsx | 27 ++------ packages/ui/content.tsx | 6 +- packages/ui/heading.tsx | 3 +- 10 files changed, 71 insertions(+), 71 deletions(-) diff --git a/apps/web/app/layout.tsx b/apps/web/app/layout.tsx index 32e3735..91fe261 100644 --- a/apps/web/app/layout.tsx +++ b/apps/web/app/layout.tsx @@ -52,10 +52,10 @@ export default function RootLayout({ children }: { readonly children: React.Reac -
+ - {children} -
+ {children} + ); diff --git a/apps/web/components/Conditions.tsx b/apps/web/components/Conditions.tsx index 37a0e8b..13f6670 100644 --- a/apps/web/components/Conditions.tsx +++ b/apps/web/components/Conditions.tsx @@ -8,7 +8,7 @@ export function Conditions({ html }: Props) { return ( ); } diff --git a/apps/web/components/Form/Elements.tsx b/apps/web/components/Form/Elements.tsx index caa9931..0e4210f 100644 --- a/apps/web/components/Form/Elements.tsx +++ b/apps/web/components/Form/Elements.tsx @@ -15,49 +15,65 @@ function compatMetadata(metaData: Props['metaData']) { return metaData; } +function RenderElement({ + fieldType, + label, + max, + min = 0, + name, + visible, + ...props +}: Props['metaData'][number] & { readonly name: string }) { + const { setValue, validation, values } = useFormStore(); + + if (!visible) return false; + + const Element = mapFieldTypeElement[fieldType]; + + return ( + + { + setValue({ + name, + value: fieldType === 'CHECKBOX' ? e.target.checked : e.target.value, + }); + }} + {...props} + /> + + ); +} + export function Elements({ data, metaData }: Props) { - const { init, setValue, validation, values } = useFormStore(); + const { init } = useFormStore(); useEffect(() => { init(data); }, [data, init]); + const { comment, ...meta } = compatMetadata(metaData); + return ( -
- {Object.keys(compatMetadata(metaData)).map((name) => { - const { fieldType, label, max, min = 0, visible, ...props } = metaData[name]; - - if (!visible) return false; - - const Element = mapFieldTypeElement[fieldType]; - - return ( - - { - setValue({ - name, - value: fieldType === 'CHECKBOX' ? e.target.checked : e.target.value, - }); - }} - {...props} - /> - - ); - })} -
+ <> +
+ {Object.keys(meta).map((name) => ( + + ))} +
+ + ); } diff --git a/apps/web/components/Form/Header.tsx b/apps/web/components/Form/Header.tsx index 258108c..232859d 100644 --- a/apps/web/components/Form/Header.tsx +++ b/apps/web/components/Form/Header.tsx @@ -3,7 +3,7 @@ import { Heading } from 'ui'; export function Header({ link, title }: { readonly link: string; readonly title: string }) { return ( -
+
{title} Посмотреть условия diff --git a/apps/web/components/Form/Overlay.tsx b/apps/web/components/Form/Overlay.tsx index 7e1752c..8d900da 100644 --- a/apps/web/components/Form/Overlay.tsx +++ b/apps/web/components/Form/Overlay.tsx @@ -7,7 +7,7 @@ import { Background, LoadingSpinner } from 'ui'; function OverlayWrapper({ children }: PropsWithChildren) { return ( - +
{children}
); diff --git a/apps/web/components/Form/index.tsx b/apps/web/components/Form/index.tsx index f415a2a..493ead4 100644 --- a/apps/web/components/Form/index.tsx +++ b/apps/web/components/Form/index.tsx @@ -15,7 +15,7 @@ function Content(props: Props) { const { pageUrlParams } = useContext(FormContext); return ( - +
diff --git a/apps/web/components/layout/controls.tsx b/apps/web/components/layout/controls.tsx index 55fcf2a..43ba81f 100644 --- a/apps/web/components/layout/controls.tsx +++ b/apps/web/components/layout/controls.tsx @@ -6,7 +6,7 @@ export function Controls() { const router = useRouter(); return ( -
+