prevent to view list of tenant if haven't permission.
This commit is contained in:
parent
b645aec55f
commit
7808a39aa0
@ -16,6 +16,8 @@ import {
|
||||
import TenantFilterPanel from "../../components/Tenant/TenantFilterPanel";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { setCurrentTenant } from "../../slices/globalVariablesSlice";
|
||||
import { hasUserPermission } from "../../utils/authUtils";
|
||||
import { SUPPER_TENANT, VIEW_TENANTS } from "../../utils/constants";
|
||||
|
||||
// This is context that wrapping all components tenant releated , but must pass inside 'TenantContext.Provider'
|
||||
export const TenantContext = createContext();
|
||||
@ -37,6 +39,8 @@ const TenantPage = () => {
|
||||
const contextValue = {
|
||||
};
|
||||
const navigate = useNavigate();
|
||||
const IsSupperTenant = hasUserPermission(SUPPER_TENANT)
|
||||
const IsViewTenant = hasUserPermission(VIEW_TENANTS)
|
||||
|
||||
const { setOffcanvasContent, setShowTrigger } = useFab();
|
||||
|
||||
@ -88,7 +92,8 @@ const handleNewTenant =()=>{
|
||||
Refresh <i className={`bx bx-refresh ms-1 ${isRefetching ? "bx-spin":""}`}></i>
|
||||
</span>
|
||||
|
||||
<button
|
||||
{IsSupperTenant && (
|
||||
<button
|
||||
type="button"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-offset="0,8"
|
||||
@ -100,13 +105,19 @@ const handleNewTenant =()=>{
|
||||
>
|
||||
<i className="bx bx-plus fs-4 text-white"></i>
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<TenantsList filters={filters} searchText={debouncedSearch} setIsRefetching={setRefetching}
|
||||
{IsViewTenant ? (<TenantsList filters={filters} searchText={debouncedSearch} setIsRefetching={setRefetching}
|
||||
setRefetchFn={setRefetchFn}
|
||||
/>
|
||||
/>):(
|
||||
<div className="text-center my-2">
|
||||
<i className="fa-solid fa-triangle-exclamation fs-5"></i>
|
||||
<p>Access Denied: You don't have permission to perform this action. !</p>
|
||||
</div>
|
||||
) }
|
||||
|
||||
</div>
|
||||
</TenantContext.Provider>
|
||||
);
|
||||
|
@ -64,7 +64,7 @@ export const EXPENSE_REJECTEDBY = ["d1ee5eec-24b6-4364-8673-a8f859c60729","965ed
|
||||
|
||||
export const EXPENSE_DRAFT = "297e0d8f-f668-41b5-bfea-e03b354251c8"
|
||||
|
||||
export const SUPPER_Tenant = "d032cb1a-3f30-462c-bef0-7ace73a71c0b"
|
||||
export const SUPPER_TENANT = "d032cb1a-3f30-462c-bef0-7ace73a71c0b"
|
||||
export const MANAGE_TENANTS = "00e20637-ce8d-4417-bec4-9b31b5e65092"
|
||||
export const VIEW_TENANTS = "647145c6-2108-4c98-aab4-178602236e55"
|
||||
export const ActiveTenant = "297e0d8f-f668-41b5-bfea-e03b354251c8"
|
||||
|
Loading…
x
Reference in New Issue
Block a user