diff --git a/Form/Core/FileField.tsx b/Form/Core/FileField.tsx index e61bf5e..e9f4f04 100644 --- a/Form/Core/FileField.tsx +++ b/Form/Core/FileField.tsx @@ -10,7 +10,7 @@ import { Accept } from "react-dropzone"; * @param props.accept - Array of supported file extensions. * @returns {JSX.Element} The rendered file input field. */ -export function FileField({ single, accept, ...props }: FieldHookConfig & { single?: boolean, accept?: Accept }) { +export function FileField({ single, accept, ...props }: FieldHookConfig & { single?: boolean, accept?: Accept | string }) { const [field, meta, helpers] = useField(props); /** diff --git a/Form/Core/NejDropzone.tsx b/Form/Core/NejDropzone.tsx index 3283427..3891f81 100644 --- a/Form/Core/NejDropzone.tsx +++ b/Form/Core/NejDropzone.tsx @@ -13,12 +13,12 @@ import { HTMLAttributes, useMemo } from "react"; * @param {string} props.text - The text to be displayed in the dropzone. * @returns {JSX.Element} - NejDropzone component. */ -export default function NejDropzone({ value, accept, onDrop, validator, single, text, css, children, ...props }: HTMLAttributes & { value: File | File[], accept?: Accept, onDrop: (files: File[]) => void, validator?: (file: File) => FileError | FileError[] | null, single?: boolean, text?: string, css?: any, children?: any }) { +export default function NejDropzone({ value, accept, onDrop, validator, single, text, css, children, ...props }: HTMLAttributes & { value: File | File[], accept?: Accept | string, onDrop: (files: File[]) => void, validator?: (file: File) => FileError | FileError[] | null, single?: boolean, text?: string, css?: any, children?: any }) { const { getRootProps, getInputProps, isFocused, isDragAccept, isDragReject } = useDropzone({ //validator: validator, onDropAccepted: onDrop, - accept: accept, + accept: typeof (accept) === "string" ? { [accept]: ["*.*"] } : accept, validator: validator, maxFiles: single ? 1 : undefined, }); diff --git a/Form/withForm.tsx b/Form/withForm.tsx index e9daf1b..5a23c2e 100644 --- a/Form/withForm.tsx +++ b/Form/withForm.tsx @@ -11,7 +11,7 @@ type FormProps = { }; export type WithFormProps = P & FormProps; type CleanedFormProps

= Omit; -export function withForm>(WrappedForm: React.ComponentType>, method: (client: ApiClient, project: OwnerResponse, props: P) => (body: T) => CancelablePromise, submitText: string, trMethod?: (initialData: T, props: CleanedFormProps

) => T) { +export function withForm>(WrappedForm: React.ComponentType>, method: (client: ApiClient, project: OwnerResponse, props: P) => (body: T) => CancelablePromise | any, submitText: string, trMethod?: (initialData: T, props: CleanedFormProps

) => T) { return function GameFormWrapper({ refresh, afterSubmit, initialData, ...props }: P) { const client = useApiClient(); const company = useOwner(); diff --git a/useModal.tsx b/useModal.tsx index 31d193c..5815e1c 100644 --- a/useModal.tsx +++ b/useModal.tsx @@ -3,14 +3,14 @@ import { useCallback } from "react"; export default function useModal( Component: React.ComponentType, - title: string + defaulTitle: string ) { - const openModal = useCallback((params: T) => { + const openModal = useCallback((params: T, title?: string) => { modals.open({ - title, + title: title ?? defaulTitle, children: modals.closeAll()} {...params} />, }); - }, [Component, title]); + }, [Component, defaulTitle ]); return openModal; } \ No newline at end of file