muffin-admin 8.5.5 → 8.5.6

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/dist/utils.d.ts CHANGED
@@ -25,3 +25,4 @@ export declare function makeRequest(url: string, params?: APIParams): Promise<{
25
25
  export declare function findIcon(icon?: string): any;
26
26
  export declare function buildIcon(icon?: string): import("react/jsx-runtime").JSX.Element;
27
27
  export declare function deepMerge(target: any, ...sources: any[]): any;
28
+ export declare function prepareFilters(filter: any): string;
package/dist/utils.js CHANGED
@@ -76,3 +76,9 @@ export function deepMerge(target, ...sources) {
76
76
  }
77
77
  return deepMerge(target, ...sources);
78
78
  }
79
+ export function prepareFilters(filter) {
80
+ return JSON.stringify(Object.entries(filter).reduce((acc, [key, value]) => {
81
+ acc[key] = Array.isArray(value) ? { $in: value } : value;
82
+ return acc;
83
+ }, {}));
84
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muffin-admin",
3
- "version": "8.5.5",
3
+ "version": "8.5.6",
4
4
  "description": "NPM package for https://github.com/klen/muffin-admin",
5
5
  "files": [
6
6
  "src",
@@ -17,7 +17,7 @@ import { HelpLink } from "../common/HelpLink"
17
17
  import { useMuffinAdminOpts } from "../hooks"
18
18
  import { useAction } from "../hooks/useAction"
19
19
  import { AdminAction, AdminPayloadProps } from "../types"
20
- import { buildIcon, findBuilder, requestHeaders } from "../utils"
20
+ import { buildIcon, findBuilder, prepareFilters, requestHeaders } from "../utils"
21
21
 
22
22
  export type ActionPayloadProps = {
23
23
  active: boolean
@@ -38,9 +38,9 @@ export function ActionButton({ paths, confirm, file, ...props }: AdminAction) {
38
38
  const confirmMessage =
39
39
  typeof confirm === "string" ? translate(confirm) : "Do you confirm this action?"
40
40
 
41
- const onHandle = async (payload?) => {
41
+ const onHandle = async (payload?: any) => {
42
42
  const process = confirm ? await confirmation.confirm({ message: confirmMessage }) : true
43
- if (process) await mutate({ record, payload })
43
+ if (process) mutate({ record, payload })
44
44
  }
45
45
 
46
46
  return <ActionButtonBase {...props} isPending={isPending} onHandle={onHandle} />
@@ -200,7 +200,7 @@ function FileButton({
200
200
  if (record) url = url.replace("{id}", record.id as string)
201
201
  const authorization = requestHeaders["Authorization"]
202
202
  if (authorization) url += `&t=${authorization}`
203
- if (Object.keys(filterValues).length) url += `&where=${JSON.stringify(filterValues)}`
203
+ if (Object.keys(filterValues).length) url += `&where=${prepareFilters(filterValues)}`
204
204
 
205
205
  return (
206
206
  <Button href={url} label={label} component={Link}>
@@ -1,5 +1,5 @@
1
1
  import { TID } from "./types"
2
- import { APIParams, makeRequest, setupAdmin } from "./utils"
2
+ import { APIParams, makeRequest, prepareFilters, setupAdmin } from "./utils"
3
3
 
4
4
  export function MuffinDataprovider(apiUrl: string) {
5
5
  async function request(url: string, options?: APIParams) {
@@ -13,14 +13,7 @@ export function MuffinDataprovider(apiUrl: string) {
13
13
  getList: async (resource: string, params: any) => {
14
14
  const { filter, pagination, sort } = params
15
15
  const query: APIParams["query"] = {}
16
- if (filter) {
17
- query.where = JSON.stringify(
18
- Object.entries(filter).reduce((acc, [key, value]) => {
19
- acc[key] = Array.isArray(value) ? { $in: value } : value
20
- return acc
21
- }, {})
22
- )
23
- }
16
+ if (filter) query.where = prepareFilters(filter)
24
17
  if (pagination) {
25
18
  const { page, perPage: limit } = pagination
26
19
  query.limit = limit
package/src/i18n/ru.ts CHANGED
@@ -9,4 +9,6 @@ const muffinRussianMessages = {
9
9
  },
10
10
  } as unknown as TranslationMessages
11
11
 
12
+ muffinRussianMessages.ra.action.edit = "Изменить"
13
+
12
14
  export default muffinRussianMessages
package/src/index.tsx CHANGED
@@ -36,4 +36,4 @@ export async function initAdmin(prefix = "", containerId: string = "root") {
36
36
  )
37
37
  }
38
38
 
39
- export const VERSION = "8.5.5"
39
+ export const VERSION = "8.5.6"
package/src/utils.tsx CHANGED
@@ -86,3 +86,12 @@ export function deepMerge(target: any, ...sources: any[]): any {
86
86
  }
87
87
  return deepMerge(target, ...sources)
88
88
  }
89
+
90
+ export function prepareFilters(filter: any) {
91
+ return JSON.stringify(
92
+ Object.entries(filter).reduce((acc, [key, value]) => {
93
+ acc[key] = Array.isArray(value) ? { $in: value } : value
94
+ return acc
95
+ }, {})
96
+ )
97
+ }