title overrides and any return types
This commit is contained in:
parent
0682e64bd3
commit
11ce28085b
|
|
@ -11,7 +11,7 @@ type FormProps<T> = {
|
||||||
};
|
};
|
||||||
export type WithFormProps<T, P> = P & FormProps<T>;
|
export type WithFormProps<T, P> = P & FormProps<T>;
|
||||||
type CleanedFormProps<P> = Omit<P, "refresh" | "afterSubmit" | "initialData">;
|
type CleanedFormProps<P> = Omit<P, "refresh" | "afterSubmit" | "initialData">;
|
||||||
export function withForm<T extends object, P extends FormProps<T>>(WrappedForm: React.ComponentType<CleanedFormProps<P>>, method: (client: ApiClient, project: OwnerResponse, props: P) => (body: T) => CancelablePromise<any>, submitText: string, trMethod?: (initialData: T, props: CleanedFormProps<P>) => T) {
|
export function withForm<T extends object, P extends FormProps<T>>(WrappedForm: React.ComponentType<CleanedFormProps<P>>, method: (client: ApiClient, project: OwnerResponse, props: P) => (body: T) => CancelablePromise<any> | any, submitText: string, trMethod?: (initialData: T, props: CleanedFormProps<P>) => T) {
|
||||||
return function GameFormWrapper({ refresh, afterSubmit, initialData, ...props }: P) {
|
return function GameFormWrapper({ refresh, afterSubmit, initialData, ...props }: P) {
|
||||||
const client = useApiClient();
|
const client = useApiClient();
|
||||||
const company = useOwner();
|
const company = useOwner();
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,14 @@ import { useCallback } from "react";
|
||||||
|
|
||||||
export default function useModal<T>(
|
export default function useModal<T>(
|
||||||
Component: React.ComponentType<T>,
|
Component: React.ComponentType<T>,
|
||||||
title: string
|
defaulTitle: string
|
||||||
) {
|
) {
|
||||||
const openModal = useCallback((params: T) => {
|
const openModal = useCallback((params: T, title?: string) => {
|
||||||
modals.open({
|
modals.open({
|
||||||
title,
|
title: title ?? defaulTitle,
|
||||||
children: <Component afterSubmit={() => modals.closeAll()} {...params} />,
|
children: <Component afterSubmit={() => modals.closeAll()} {...params} />,
|
||||||
});
|
});
|
||||||
}, [Component, title]);
|
}, [Component, defaulTitle ]);
|
||||||
|
|
||||||
return openModal;
|
return openModal;
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user