From e354bf44b4c43628993f64e934b77760eb5f70ae Mon Sep 17 00:00:00 2001 From: LWangllix Date: Tue, 5 Dec 2023 12:09:32 +0200 Subject: [PATCH 1/3] freelancer cannot see tenantUser tab --- src/utils/hooks.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/utils/hooks.ts b/src/utils/hooks.ts index 334f622..d9d8a73 100644 --- a/src/utils/hooks.ts +++ b/src/utils/hooks.ts @@ -24,7 +24,9 @@ export const useFilteredRoutes = () => { return routes.filter((route) => { if (!route?.slug) return false; - if (route.tenantOwner && profile?.role) { + if (route.tenantOwner) { + if (!profile?.role) return false; + return [RolesTypes.USER_ADMIN, RolesTypes.OWNER].includes(profile?.role); } From 759349dc14334f5657ced843b1a276fd39cb6bc6 Mon Sep 17 00:00:00 2001 From: LWangllix Date: Tue, 5 Dec 2023 12:25:01 +0200 Subject: [PATCH 2/3] x-profile fix --- src/utils/api.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/api.ts b/src/utils/api.ts index 50be5d1..c15f370 100644 --- a/src/utils/api.ts +++ b/src/utils/api.ts @@ -1,5 +1,4 @@ import Axios, { AxiosInstance, AxiosResponse } from 'axios'; -import { isNaN } from 'lodash'; import { FishStocking, FishType, Tenant, TenantUser, User } from './types'; import { isEmpty } from 'lodash'; @@ -93,7 +92,8 @@ class Api { config.url = this.proxy + config.url; if (token) { config.headers!.Authorization = 'Bearer ' + token; - if (!isNaN(profileId)) config.headers!['X-Profile'] = profileId; + + if (profileId && !isNaN(profileId)) config.headers!['X-Profile'] = profileId; } return config; From 9aa0160f2cc937e775e1fe33cb877ef149e987b0 Mon Sep 17 00:00:00 2001 From: LWangllix Date: Wed, 13 Dec 2023 22:55:11 +0200 Subject: [PATCH 3/3] use isfinite to check a number --- package.json | 1 + src/utils/api.ts | 3 ++- yarn.lock | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index c2fb34a..3dd0c5b 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "@testing-library/react": "^13.4.0", "@testing-library/user-event": "^13.5.0", "@types/jest": "^27.5.2", + "@types/lodash": "^4.14.202", "@types/node": "^17.0.45", "@types/react": "^18.0.33", "@types/react-dom": "^18.0.11", diff --git a/src/utils/api.ts b/src/utils/api.ts index c15f370..5bb551f 100644 --- a/src/utils/api.ts +++ b/src/utils/api.ts @@ -1,4 +1,5 @@ import Axios, { AxiosInstance, AxiosResponse } from 'axios'; +import { isFinite } from 'lodash'; import { FishStocking, FishType, Tenant, TenantUser, User } from './types'; import { isEmpty } from 'lodash'; @@ -93,7 +94,7 @@ class Api { if (token) { config.headers!.Authorization = 'Bearer ' + token; - if (profileId && !isNaN(profileId)) config.headers!['X-Profile'] = profileId; + if (isFinite(parseInt(profileId))) config.headers!['X-Profile'] = profileId; } return config; diff --git a/yarn.lock b/yarn.lock index 447d7a2..fa87d7c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1866,6 +1866,11 @@ resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841" integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA== +"@types/lodash@^4.14.202": + version "4.14.202" + resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.202.tgz#f09dbd2fb082d507178b2f2a5c7e74bd72ff98f8" + integrity sha512-OvlIYQK9tNneDlS0VN54LLd5uiPCBOp7gS5Z0f1mjoJYBrtStzgmJBxONW3U6OZqdtNzZPmn9BS/7WI7BFFcFQ== + "@types/node@*": version "20.10.1" resolved "https://registry.yarnpkg.com/@types/node/-/node-20.10.1.tgz#d2c96f356c3125fedc983d74c424910c3767141c"