feat: crappy reordering
This commit is contained in:
@@ -150,6 +150,38 @@ const ServicesTable: FC<Props> = ({
|
||||
);
|
||||
},
|
||||
},
|
||||
"mrt-row-actions": {
|
||||
AggregatedCell: ({ row }) => editMode && (
|
||||
<Tooltip label={"Редактировать категорию"}>
|
||||
<ActionIcon onClick={() => {
|
||||
modals.openContextModal({
|
||||
modal: "createServiceCategory",
|
||||
title: "Создание категории",
|
||||
withCloseButton: false,
|
||||
innerProps: {
|
||||
element: row.original.category,
|
||||
onChange: newCategory => {
|
||||
ServiceService.updateServiceCategory({ requestBody: { category: newCategory } }).then(({
|
||||
ok,
|
||||
message,
|
||||
}) => {
|
||||
notifications.guess(ok, { message });
|
||||
if (!ok) return;
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ["getAllServices"],
|
||||
}).then(() => {
|
||||
});
|
||||
},
|
||||
);
|
||||
},
|
||||
},
|
||||
});
|
||||
}} variant={"default"}>
|
||||
<IconEdit />
|
||||
</ActionIcon>
|
||||
</Tooltip>
|
||||
),
|
||||
},
|
||||
},
|
||||
enableRowActions: true,
|
||||
renderRowActions: ({ row }) => (
|
||||
|
||||
@@ -2,19 +2,18 @@ import { ServiceCategorySchema } from "../../../client";
|
||||
import { Button, Flex, rem, TextInput } from "@mantine/core";
|
||||
import { useForm } from "@mantine/form";
|
||||
import { ContextModalProps } from "@mantine/modals";
|
||||
import { CreateEditFormProps } from "../../ClientsPage/modals/BaseFormModal/BaseFormModal.tsx";
|
||||
|
||||
type Props = {
|
||||
onCreate: (category: ServiceCategorySchema) => void;
|
||||
};
|
||||
type Props = CreateEditFormProps<ServiceCategorySchema>;
|
||||
const CreateServiceCategoryModal = ({
|
||||
context,
|
||||
id,
|
||||
innerProps,
|
||||
}: ContextModalProps<Props>) => {
|
||||
context,
|
||||
id,
|
||||
innerProps,
|
||||
}: ContextModalProps<Props>) => {
|
||||
const isEditing = "onChange" in innerProps;
|
||||
const initialValues = isEditing ? innerProps.element : { name: "" };
|
||||
const form = useForm({
|
||||
initialValues: {
|
||||
name: "",
|
||||
},
|
||||
initialValues,
|
||||
validate: {
|
||||
name: name =>
|
||||
name.trim() !== ""
|
||||
@@ -23,7 +22,15 @@ const CreateServiceCategoryModal = ({
|
||||
},
|
||||
});
|
||||
const onSubmit = (values: { name: string }) => {
|
||||
innerProps.onCreate({ name: values.name, id: -1 });
|
||||
if (isEditing) {
|
||||
innerProps.onChange({ ...innerProps.element, ...values });
|
||||
} else {
|
||||
innerProps.onCreate({
|
||||
...values,
|
||||
dealServiceRank: "",
|
||||
productServiceRank: "", id: -1,
|
||||
});
|
||||
}
|
||||
context.closeContextModal(id);
|
||||
};
|
||||
const onCancelClick = () => {
|
||||
|
||||
Reference in New Issue
Block a user