muffin-admin 2.5.2 → 2.5.3

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.
@@ -6,13 +6,11 @@ import { buildIcon, findBuilder } from "../utils";
6
6
  export function BulkActionButton({ label, icon, title, action }) {
7
7
  const resource = useResourceContext();
8
8
  const { selectedIds } = useListContext();
9
- const [payload, setPayload] = useState(null);
10
9
  const [payloadActive, setPayloadActive] = useState(false);
11
- const actionData = { payload, ids: selectedIds };
12
10
  const PayloadBuilder = findBuilder(["action", "payload", action]);
13
11
  const refresh = useRefresh(), unselectAll = useUnselectAll(resource), notify = useNotify();
14
12
  const { mutate, isLoading } = useAction(action);
15
- const process = () => mutate(actionData, {
13
+ const process = (payload) => mutate({ ids: selectedIds, payload }, {
16
14
  onSuccess: ({ data }) => {
17
15
  if (data && data.message)
18
16
  notify(data.message, { type: "success" });
@@ -27,21 +25,15 @@ export function BulkActionButton({ label, icon, title, action }) {
27
25
  notify(typeof err === "string" ? err : err.message, { type: "error" });
28
26
  },
29
27
  });
30
- return (_jsxs(_Fragment, { children: [_jsx(Button, { label: label, title: title, onClick: PayloadBuilder ? () => setPayloadActive(true) : process, disabled: isLoading, children: buildIcon(icon) }), PayloadBuilder && (_jsx(PayloadBuilder, { active: payloadActive, onChange: (payload) => {
31
- setPayloadActive(false);
32
- setPayload(payload);
33
- process();
34
- }, onClose: () => setPayloadActive(false) }))] }));
28
+ return (_jsxs(_Fragment, { children: [_jsx(Button, { label: label, title: title, onClick: PayloadBuilder ? () => setPayloadActive(true) : process, disabled: isLoading, children: buildIcon(icon) }), PayloadBuilder && (_jsx(PayloadBuilder, { active: payloadActive, onHandle: (payload) => process(payload), onClose: () => setPayloadActive(false) }))] }));
35
29
  }
36
30
  export function ActionButton({ icon, label, title, action }) {
37
- const [payload, setPayload] = useState(null);
38
31
  const [payloadActive, setPayloadActive] = useState(false);
39
32
  const record = useRecordContext();
40
- const actionData = { record, payload };
41
33
  const { mutate, isLoading } = useAction(action);
42
34
  const PayloadBuilder = findBuilder(["action", "payload", action]);
43
35
  const refresh = useRefresh(), notify = useNotify();
44
- const process = () => mutate(actionData, {
36
+ const process = (payload) => mutate({ record, payload }, {
45
37
  onSuccess: ({ data }) => {
46
38
  if (data && data.message)
47
39
  notify(data.message, { type: "success" });
@@ -54,9 +46,5 @@ export function ActionButton({ icon, label, title, action }) {
54
46
  notify(typeof err === "string" ? err : err.message, { type: "error" });
55
47
  },
56
48
  });
57
- return (_jsxs(_Fragment, { children: [_jsx(Button, { label: label, title: title, onClick: PayloadBuilder ? () => setPayloadActive(true) : process, disabled: isLoading, children: buildIcon(icon) }), PayloadBuilder && (_jsx(PayloadBuilder, { active: payloadActive, onChange: (payload) => {
58
- setPayloadActive(false);
59
- setPayload(payload);
60
- process();
61
- }, onClose: () => setPayloadActive(false) }))] }));
49
+ return (_jsxs(_Fragment, { children: [_jsx(Button, { label: label, title: title, onClick: PayloadBuilder ? () => setPayloadActive(true) : process, disabled: isLoading, children: buildIcon(icon) }), PayloadBuilder && (_jsx(PayloadBuilder, { active: payloadActive, onHandle: (payload) => process(payload), onClose: () => setPayloadActive(false) }))] }));
62
50
  }