title overrides and any return types

This commit is contained in:
honzapatCZ 2025-04-24 15:18:09 +02:00
parent 0682e64bd3
commit 11ce28085b
2 changed files with 5 additions and 5 deletions

View File

@ -11,7 +11,7 @@ type FormProps<T> = {
};
export type WithFormProps<T, P> = P & FormProps<T>;
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) {
const client = useApiClient();
const company = useOwner();

View File

@ -3,14 +3,14 @@ import { useCallback } from "react";
export default function useModal<T>(
Component: React.ComponentType<T>,
title: string
defaulTitle: string
) {
const openModal = useCallback((params: T) => {
const openModal = useCallback((params: T, title?: string) => {
modals.open({
title,
title: title ?? defaulTitle,
children: <Component afterSubmit={() => modals.closeAll()} {...params} />,
});
}, [Component, title]);
}, [Component, defaulTitle ]);
return openModal;
}