gomtm 0.0.340 → 0.0.341
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -20,27 +20,46 @@ var __async = (__this, __arguments, generator) => {
|
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
22
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
23
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
24
|
+
import { useMtRouter } from "mtxuilib/hooks/use-router";
|
|
23
25
|
import { Dialog, DialogContent, DialogTitle } from "mtxuilib/ui/dialog";
|
|
24
26
|
import { MtButton } from "mtxuilib/ui/ui-mt/Button";
|
|
27
|
+
import { useCallback } from "react";
|
|
25
28
|
import { useGomtmMutation } from "../../gomtmQuery";
|
|
26
29
|
import { useListview } from "../listview/list-store";
|
|
27
|
-
|
|
30
|
+
function useCurdRemove() {
|
|
28
31
|
const svc = useListview((x) => x.svc);
|
|
29
32
|
const openRemove = useListview((x) => x.openRemove);
|
|
30
33
|
const setOpenRemove = useListview((x) => x.setOpenRemove);
|
|
31
34
|
const methodDelete = useListview((x) => x.methodDelete);
|
|
32
35
|
const mutation = useGomtmMutation(svc, methodDelete);
|
|
33
36
|
const activateItem = useListview((x) => x.activateItem);
|
|
34
|
-
|
|
37
|
+
const router = useMtRouter();
|
|
38
|
+
const queryClient = useQueryClient();
|
|
39
|
+
const handlerSubmit = useCallback(() => __async(this, null, function* () {
|
|
40
|
+
yield mutation.mutateAsync({
|
|
41
|
+
id: activateItem == null ? void 0 : activateItem.id
|
|
42
|
+
});
|
|
43
|
+
setOpenRemove(false);
|
|
44
|
+
router.refresh();
|
|
45
|
+
queryClient.invalidateQueries();
|
|
46
|
+
}), [activateItem == null ? void 0 : activateItem.id, mutation, queryClient, router, setOpenRemove]);
|
|
47
|
+
return {
|
|
48
|
+
handlerSubmit,
|
|
49
|
+
open: openRemove,
|
|
50
|
+
setOpen: setOpenRemove
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const PanelRemove = () => {
|
|
54
|
+
const curdRemove = useCurdRemove();
|
|
55
|
+
return /* @__PURE__ */ jsx(Dialog, { open: curdRemove.open, onOpenChange: curdRemove.setOpen, children: /* @__PURE__ */ jsxs(DialogContent, { children: [
|
|
35
56
|
/* @__PURE__ */ jsx(DialogTitle, { children: "remove item" }),
|
|
36
|
-
/* @__PURE__ */ jsx(MtButton, { onClick: () =>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
});
|
|
40
|
-
setOpenRemove(false);
|
|
41
|
-
}), children: "ok" })
|
|
57
|
+
/* @__PURE__ */ jsx(MtButton, { onClick: () => {
|
|
58
|
+
curdRemove.handlerSubmit();
|
|
59
|
+
}, children: "ok" })
|
|
42
60
|
] }) });
|
|
43
61
|
};
|
|
44
62
|
export {
|
|
45
|
-
PanelRemove
|
|
63
|
+
PanelRemove,
|
|
64
|
+
useCurdRemove
|
|
46
65
|
};
|