muffin-admin 3.6.2 → 3.7.0
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.
|
@@ -4,8 +4,8 @@ export type ActionPayloadProps = {
|
|
|
4
4
|
onClose: () => void;
|
|
5
5
|
onHandle: (payload: any) => void;
|
|
6
6
|
};
|
|
7
|
-
export declare function ActionButton({
|
|
8
|
-
export declare function BulkActionButton({
|
|
7
|
+
export declare function ActionButton({ paths, confirm, ...props }: AdminAction): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function BulkActionButton({ paths, confirm, ...props }: AdminAction): import("react/jsx-runtime").JSX.Element;
|
|
9
9
|
export declare function CommonPayload({ active, onClose, onHandle, schema, title }: {
|
|
10
10
|
active: any;
|
|
11
11
|
onClose: any;
|
|
@@ -26,11 +26,12 @@ import { AdminModal, PayloadButtons, useConfirmation } from "../common";
|
|
|
26
26
|
import { useAction } from "../hooks/useAction";
|
|
27
27
|
import { buildIcon, findBuilder } from "../utils";
|
|
28
28
|
export function ActionButton(_a) {
|
|
29
|
-
var {
|
|
29
|
+
var { paths, confirm } = _a, props = __rest(_a, ["paths", "confirm"]);
|
|
30
30
|
const translate = useTranslate();
|
|
31
31
|
const record = useRecordContext();
|
|
32
32
|
const confirmation = useConfirmation();
|
|
33
|
-
const
|
|
33
|
+
const path = paths.find((p) => p.includes("{id}")) || paths[paths.length - 1];
|
|
34
|
+
const { mutate, isPending } = useAction(path);
|
|
34
35
|
const confirmMessage = typeof confirm === "string" ? translate(confirm) : "Do you confirm this action?";
|
|
35
36
|
const onHandle = (payload) => __awaiter(this, void 0, void 0, function* () {
|
|
36
37
|
const process = confirm ? yield confirmation.confirm({ message: confirmMessage }) : true;
|
|
@@ -40,10 +41,11 @@ export function ActionButton(_a) {
|
|
|
40
41
|
return _jsx(ActionButtonBase, Object.assign({}, props, { isPending: isPending, onHandle: onHandle }));
|
|
41
42
|
}
|
|
42
43
|
export function BulkActionButton(_a) {
|
|
43
|
-
var {
|
|
44
|
+
var { paths, confirm } = _a, props = __rest(_a, ["paths", "confirm"]);
|
|
44
45
|
const translate = useTranslate();
|
|
45
46
|
const { selectedIds } = useListContext();
|
|
46
|
-
const
|
|
47
|
+
const path = paths.find((p) => !p.includes("{id}")) || paths[0];
|
|
48
|
+
const { mutate, isPending } = useAction(path);
|
|
47
49
|
const confirmation = useConfirmation();
|
|
48
50
|
const confirmMessage = typeof confirm === "string" ? translate(confirm) : "Do you confirm this action?";
|
|
49
51
|
const onHandle = (payload) => __awaiter(this, void 0, void 0, function* () {
|