@larose-ui/data 0.1.1 → 0.1.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/dist/index.js +3 -3
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -105,7 +105,7 @@ function queryReducer(state, action) {
|
|
|
105
105
|
function useQuery(url, options = {}) {
|
|
106
106
|
const { enabled = true, permission, resource, initialData, ...fetchOptions } = options;
|
|
107
107
|
const { check } = usePermissions();
|
|
108
|
-
const
|
|
108
|
+
const permissionAllowed = permission ? check(permission, resource).allowed : true;
|
|
109
109
|
const [state, dispatch] = useReducer(queryReducer, {
|
|
110
110
|
status: "idle",
|
|
111
111
|
data: initialData ?? null,
|
|
@@ -116,7 +116,7 @@ function useQuery(url, options = {}) {
|
|
|
116
116
|
fetchOptionsRef.current = fetchOptions;
|
|
117
117
|
const execute = useCallback(async () => {
|
|
118
118
|
if (!url) return;
|
|
119
|
-
if (
|
|
119
|
+
if (!permissionAllowed) {
|
|
120
120
|
dispatch({ type: "UNAUTHORIZED" });
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
@@ -138,7 +138,7 @@ function useQuery(url, options = {}) {
|
|
|
138
138
|
});
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
-
}, [url,
|
|
141
|
+
}, [url, permissionAllowed]);
|
|
142
142
|
useEffect(() => {
|
|
143
143
|
if (enabled && url) void execute();
|
|
144
144
|
}, [enabled, url, execute, state.retryCount]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@larose-ui/data",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Backend-aware data layer for laRose UI platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"README.md"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@larose-ui/core": "0.1.
|
|
21
|
-
"@larose-ui/permissions": "0.1.
|
|
20
|
+
"@larose-ui/core": "0.1.2",
|
|
21
|
+
"@larose-ui/permissions": "0.1.2"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"react": ">=18"
|