@@ -1,48 +1,48 @@
|
||||
import { useMutation } from "@apollo/client";
|
||||
import { Button, notification, Popconfirm } from "antd";
|
||||
import {useMutation} from "@apollo/client";
|
||||
import {Button, notification, Popconfirm} from "antd";
|
||||
import queryString from "query-string";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useNavigate, useLocation } from "react-router-dom";
|
||||
import { DELETE_TEMPLATE } from "../../graphql/templates.queries";
|
||||
import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||
import {useTranslation} from "react-i18next";
|
||||
import {useLocation, useNavigate} from "react-router-dom";
|
||||
import {DELETE_TEMPLATE} from "../../graphql/templates.queries";
|
||||
import {logImEXEvent} from "../../firebase/firebase.utils";
|
||||
|
||||
export default function ShopTemplateDeleteComponent({ templateId, refetch }) {
|
||||
const { t } = useTranslation();
|
||||
const search = queryString.parse(useLocation().search);
|
||||
const history = useNavigate();
|
||||
const [deleteTemplate] = useMutation(DELETE_TEMPLATE);
|
||||
export default function ShopTemplateDeleteComponent({templateId, refetch}) {
|
||||
const {t} = useTranslation();
|
||||
const search = queryString.parse(useLocation().search);
|
||||
const history = useNavigate();
|
||||
const [deleteTemplate] = useMutation(DELETE_TEMPLATE);
|
||||
|
||||
const handleDelete = async () => {
|
||||
logImEXEvent("shop_template_delete");
|
||||
const handleDelete = async () => {
|
||||
logImEXEvent("shop_template_delete");
|
||||
|
||||
const result = await deleteTemplate({
|
||||
variables: {
|
||||
templateId: templateId,
|
||||
},
|
||||
});
|
||||
const result = await deleteTemplate({
|
||||
variables: {
|
||||
templateId: templateId,
|
||||
},
|
||||
});
|
||||
|
||||
if (!!result.errors) {
|
||||
notification["error"]({
|
||||
message: t("bodyshop.errors.deletingtemplate", {
|
||||
message: JSON.stringify(result.errors),
|
||||
}),
|
||||
});
|
||||
} else {
|
||||
delete search.customTemplateId;
|
||||
history({ search: queryString.stringify(search) });
|
||||
if (!!refetch) refetch();
|
||||
}
|
||||
};
|
||||
if (!!result.errors) {
|
||||
notification["error"]({
|
||||
message: t("bodyshop.errors.deletingtemplate", {
|
||||
message: JSON.stringify(result.errors),
|
||||
}),
|
||||
});
|
||||
} else {
|
||||
delete search.customTemplateId;
|
||||
history({search: queryString.stringify(search)});
|
||||
if (!!refetch) refetch();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Popconfirm
|
||||
title={t("general.labels.areyousure")}
|
||||
okText={t("general.labels.yes")}
|
||||
cancelText={t("general.labels.no")}
|
||||
onConfirm={handleDelete}
|
||||
>
|
||||
<Button>{t("general.actions.delete")}</Button>
|
||||
</Popconfirm>
|
||||
);
|
||||
return (
|
||||
<Popconfirm
|
||||
title={t("general.labels.areyousure")}
|
||||
okText={t("general.labels.yes")}
|
||||
cancelText={t("general.labels.no")}
|
||||
onConfirm={handleDelete}
|
||||
>
|
||||
<Button>{t("general.actions.delete")}</Button>
|
||||
</Popconfirm>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user