import React, { type ReactNode } from 'react' import { Stack, Group, Paper, Button, Title, Box } from '@mantine/core' import { useFormLayoutStore } from '../store/FormLayout.store' interface FormSectionProps { type: 'header' | 'body' | 'footer' | 'error' title?: string rightSection?: ReactNode children?: ReactNode buttonTitles?: { submit?: string; cancel?: string } className?: string [key: string]: any } export const FormSection: React.FC = ({ type, title, rightSection, children, buttonTitles, className, ...others }) => { const { onCancel, onSubmit, request, loading } = useFormLayoutStore((state) => ({ onCancel: state.onCancel, onSubmit: state.onSubmit, request: state.request, loading: state.loading, })) if (type === 'header') { return ( {title} {rightSection && {rightSection}} ) } if (type === 'body') { return ( {children} ) } if (type === 'footer') { return ( {children} {request !== 'view' && ( <> )} ) } if (type === 'error') { return ( {children} ) } return null }