feat: marketplaces editor in clients page
This commit is contained in:
37
src/app/clients/hooks/utils/useClientsActions.tsx
Normal file
37
src/app/clients/hooks/utils/useClientsActions.tsx
Normal file
@ -0,0 +1,37 @@
|
||||
import { modals } from "@mantine/modals";
|
||||
import { useClientsContext } from "@/app/clients/contexts/ClientsContext";
|
||||
import { ClientSchema } from "@/lib/client";
|
||||
|
||||
const useClientsActions = () => {
|
||||
const { clientsCrud } = useClientsContext();
|
||||
|
||||
const onCreateClick = () => {
|
||||
modals.openContextModal({
|
||||
modal: "clientEditorModal",
|
||||
title: "Создание клиента",
|
||||
innerProps: {
|
||||
onCreate: clientsCrud.onCreate,
|
||||
isEditing: false,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const onUpdateClick = (client: ClientSchema) => {
|
||||
modals.openContextModal({
|
||||
modal: "clientEditorModal",
|
||||
title: "Редактирование клиента",
|
||||
innerProps: {
|
||||
onChange: updates => clientsCrud.onUpdate(client.id, updates),
|
||||
entity: client,
|
||||
isEditing: true,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
onCreateClick,
|
||||
onUpdateClick,
|
||||
};
|
||||
};
|
||||
|
||||
export default useClientsActions;
|
||||
Reference in New Issue
Block a user