diff --git a/Form/withForm.tsx b/Form/withForm.tsx index f24d043..e9daf1b 100644 --- a/Form/withForm.tsx +++ b/Form/withForm.tsx @@ -10,11 +10,15 @@ type FormProps = { initialData?: T; }; export type WithFormProps = P & FormProps; -export function withForm>(WrappedForm: React.ComponentType, method: (client: ApiClient, project: OwnerResponse, props: P) => (body: T) => CancelablePromise, submitText: string) { +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) { return function GameFormWrapper({ refresh, afterSubmit, initialData, ...props }: P) { const client = useApiClient(); const company = useOwner(); + if (trMethod) + initialData = trMethod(initialData, props); + const fnc = method(client, company, { ...props, initialData } as P); console.log(fnc); @@ -26,10 +30,10 @@ export function withForm>(WrappedForm: return ( {submit(values); afterSubmit && afterSubmit(values)}} + onSubmit={(values) => { submit(values); afterSubmit && afterSubmit(values) }} submitText={submitText} > - + ); }; diff --git a/macros/useMethod.macro.d.ts b/macros/useMethod.macro.d.ts index 07793d8..c81c529 100644 --- a/macros/useMethod.macro.d.ts +++ b/macros/useMethod.macro.d.ts @@ -1,4 +1,4 @@ -import { CancelablePromise, Error } from "src/services/api"; +import { CancelablePromise, Error } from "@services/api"; export default function useMethod(method: (...args: Arg) => CancelablePromise, onDone?: (data: T, ...args: Arg) => void, diff --git a/macros/useQuery.macro.d.ts b/macros/useQuery.macro.d.ts index ce15b4e..51845fa 100644 --- a/macros/useQuery.macro.d.ts +++ b/macros/useQuery.macro.d.ts @@ -1,4 +1,4 @@ -import { CancelablePromise, Error } from "src/services/api"; +import { CancelablePromise, Error } from "@services/api"; //default export is a function /*