react-toolkits 2.13.35 → 2.13.36

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # react-toolkits
2
2
 
3
+ ## 2.13.36
4
+
5
+ ### Patch Changes
6
+
7
+ - dba6e3c: feat: usePermission hook default return true
8
+
3
9
  ## 2.13.35
4
10
 
5
11
  ### Patch Changes
package/lib/index.js CHANGED
@@ -633,22 +633,14 @@ function usePermission(code, config) {
633
633
  permissionCodes.length > 0 ? [url4, body, config] : null,
634
634
  (args) => axios2.post(...args).then((response) => response.data.data)
635
635
  );
636
- let newData;
637
- if (data !== void 0) {
638
- if (typeof code === "undefined") {
639
- newData = true;
640
- } else if (typeof code === "string") {
641
- newData = data.has_all ? true : data[code] ?? false;
642
- } else {
643
- if (code.length === 0) {
644
- newData = { [code[0]]: true };
645
- } else {
646
- newData = permissionCodes.reduce((acc, curr) => {
647
- acc[curr] = data.has_all ? true : data[curr] ?? false;
648
- return acc;
649
- }, {});
650
- }
651
- }
636
+ let newData = true;
637
+ if (typeof code === "string") {
638
+ newData = data?.has_all ? true : data?.[code] ?? false;
639
+ } else if (Array.isArray(code) && code.length > 0) {
640
+ newData = permissionCodes.reduce((acc, curr) => {
641
+ acc[curr] = data?.has_all ? true : data?.[curr] ?? false;
642
+ return acc;
643
+ }, {});
652
644
  }
653
645
  return {
654
646
  ...rest,