-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b494260
commit 0be38d8
Showing
5 changed files
with
49 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 11 additions & 6 deletions
17
src/components/accessories/patientSummary/PatientSummary.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,20 @@ | ||
import React, { FunctionComponent } from 'react'; | ||
import { patientSummaryTabs } from "./tabsConfig"; | ||
import Tabs from '../tabs/Tabs'; | ||
import React, { FunctionComponent } from "react"; | ||
import { usePermission } from "../../../libraries/permissionUtils/usePermission"; | ||
import { PermissionDenied } from "../permissionDenied/PermissionDenied"; | ||
import Tabs from "../tabs/Tabs"; | ||
import "./styles.scss"; | ||
import { patientSummaryTabs } from "./tabsConfig"; | ||
|
||
const PatientSummary: FunctionComponent = () => { | ||
const canRead = usePermission("summary.read"); | ||
|
||
return ( | ||
return canRead ? ( | ||
<div className="patientSummary"> | ||
<Tabs config={patientSummaryTabs} /> | ||
</div> | ||
) : ( | ||
<PermissionDenied /> | ||
); | ||
} | ||
}; | ||
|
||
export default PatientSummary; | ||
export default PatientSummary; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
src/components/accessories/permissionDenied/PermissionDenied.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import React, { FunctionComponent } from "react"; | ||
|
||
// TODO: Add style and a proper message | ||
export const PermissionDenied: FunctionComponent = () => <>Permission denied</>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { useSelector } from "react-redux"; | ||
import { IState, TPermission } from "../../types"; | ||
|
||
export const usePermission = (name: TPermission): boolean => { | ||
const permissions = useSelector<IState, string[]>( | ||
(state) => state.main.me?.data?.permission || [] | ||
); | ||
|
||
return Boolean(permissions.find((permission: string) => permission === name)); | ||
}; |