diff --git a/apps/web/components/Form/index.tsx b/apps/web/components/Form/index.tsx index 95c520f..30b680c 100644 --- a/apps/web/components/Form/index.tsx +++ b/apps/web/components/Form/index.tsx @@ -1,27 +1,40 @@ /* eslint-disable react/forbid-component-props */ 'use client'; import { Buttons } from './Buttons'; -import { FormContextProvider } from './context/form-context'; +import { FormContext, FormContextProvider } from './context/form-context'; import { Elements } from './Elements'; import { Header } from './Header'; import type { Props } from './types'; import { makeCreateUrl } from '@/utils/url'; +import type { FC } from 'react'; +import { useContext } from 'react'; import { Background, Divider } from 'ui'; -export function Form(props: Props) { - const { pageUrlParams, title } = props; - const createUrl = makeCreateUrl(pageUrlParams); +function Content(props: Props) { + const { title } = props; + const { createUrl } = useContext(FormContext); return ( - -
- - - - +
+ + + ); } -export * from './Header'; +function withContext(Component: FC) { + return (props: T) => { + const { pageUrlParams } = props; + const createUrl = makeCreateUrl(pageUrlParams); + + return ( + + + + ); + }; +} + +export const Form = withContext(Content);