muffin-admin 3.4.0 → 3.4.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muffin-admin",
3
- "version": "3.4.0",
3
+ "version": "3.4.2",
4
4
  "description": "NPM package for https://github.com/klen/muffin-admin",
5
5
  "files": [
6
6
  "src",
@@ -6,7 +6,7 @@ import {
6
6
  useTranslate,
7
7
  } from "react-admin"
8
8
 
9
- import { useState } from "react"
9
+ import { useMemo, useState } from "react"
10
10
  import { useConfirmation } from "../common"
11
11
  import { useAction } from "../hooks/useAction"
12
12
  import { AdminAction } from "../types"
@@ -23,15 +23,18 @@ export function ActionButton({ icon, label, title, action, id, confirm }: AdminA
23
23
  const record = useRecordContext()
24
24
  const resource = useResourceContext()
25
25
  const confirmation = useConfirmation()
26
- const { mutate, isPending } = useAction(action, {})
26
+ const { mutate, isPending } = useAction(action)
27
27
 
28
28
  const [payloadActive, setPayloadActive] = useState(false)
29
29
  const [payloadResolver, setPayloadResolver] = useState<(data: any) => void>()
30
30
 
31
31
  const PayloadBuilder = findBuilder(["action", "payload", id, resource])
32
- const buildPayload = PayloadBuilder
33
- ? new Promise((resolve) => setPayloadResolver(() => resolve))
34
- : Promise.resolve()
32
+ const buildPayload = useMemo(() => {
33
+ if (PayloadBuilder) {
34
+ return new Promise((resolve) => setPayloadResolver(() => resolve))
35
+ }
36
+ return Promise.resolve()
37
+ }, [PayloadBuilder])
35
38
  const confirmMessage =
36
39
  typeof confirm === "string" ? translate(confirm) : "Do you confirm this action?"
37
40
 
@@ -71,9 +74,12 @@ export function BulkActionButton({ label, icon, title, action, id, confirm }: Ad
71
74
  const [payloadResolver, setPayloadResolver] = useState<(data: any) => void>()
72
75
 
73
76
  const PayloadBuilder = findBuilder(["action", "payload", id, resource])
74
- const buildPayload = PayloadBuilder
75
- ? new Promise((resolve) => setPayloadResolver(() => resolve))
76
- : Promise.resolve()
77
+ const buildPayload = useMemo(() => {
78
+ if (PayloadBuilder) {
79
+ return new Promise((resolve) => setPayloadResolver(() => resolve))
80
+ }
81
+ return Promise.resolve()
82
+ }, [PayloadBuilder])
77
83
  const confirmMessage =
78
84
  typeof confirm === "string" ? translate(confirm) : "Do you confirm this action?"
79
85
 
@@ -4,7 +4,7 @@ import { PropsWithChildren } from "react"
4
4
  interface IProps {
5
5
  open: boolean
6
6
  onClose: () => void
7
- title?: string
7
+ title?: React.ReactNode
8
8
  actions?: React.ReactNode
9
9
  }
10
10