Skip to content

Commit 53d8804

Browse files
committed
Add local unit global validator permission for validation and edit
1 parent 7b38a4b commit 53d8804

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

app/src/hooks/domain/usePermissions.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ function usePermissions() {
4545

4646
const isSuperUser = !isGuestUser && !!userMe?.is_superuser;
4747

48+
const isGlobalValidator = !isGuestUser && !!userMe?.is_global_validator;
49+
4850
return {
4951
isDrefRegionalCoordinator,
5052
isRegionAdmin,
@@ -55,6 +57,7 @@ function usePermissions() {
5557
isIfrcAdmin,
5658
isSuperUser,
5759
isGuestUser,
60+
isGlobalValidator,
5861
};
5962
},
6063
[userMe],

app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsFormModal/LocalUnitsForm/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ function LocalUnitsForm(props: Props) {
161161

162162
const {
163163
isSuperUser,
164+
isGlobalValidator,
164165
isRegionAdmin,
165166
isCountryAdmin,
166167
isGuestUser,
@@ -172,6 +173,7 @@ function LocalUnitsForm(props: Props) {
172173
const { countryId, countryResponse } = useOutletContext<CountryOutletContext>();
173174

174175
const hasValidatePermission = isSuperUser
176+
|| isGlobalValidator
175177
|| isCountryAdmin(Number(countryId))
176178
|| isRegionAdmin(Number(countryResponse?.region));
177179

app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsTable/LocalUnitTableActions/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ function LocalUnitsTableActions(props: Props) {
5151

5252
const {
5353
isSuperUser,
54+
isGlobalValidator,
5455
isRegionAdmin,
5556
isCountryAdmin,
5657
isGuestUser,
@@ -59,6 +60,7 @@ function LocalUnitsTableActions(props: Props) {
5960
const { isAuthenticated } = useAuth();
6061

6162
const hasValidatePermission = isSuperUser
63+
|| isGlobalValidator
6264
|| isCountryAdmin(Number(countryId))
6365
|| isRegionAdmin(Number(countryDetails?.region));
6466

app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/index.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@ function NationalSocietyLocalUnits(props: Props) {
5252
const [activeTab, setActiveTab] = useState<'map'| 'table'>('map');
5353
const { isAuthenticated } = useAuth();
5454
const { countryResponse } = useOutletContext<CountryOutletContext>();
55-
const { isSuperUser, isCountryAdmin, isGuestUser } = usePermissions();
55+
const {
56+
isSuperUser,
57+
isCountryAdmin,
58+
isGuestUser,
59+
isGlobalValidator,
60+
} = usePermissions();
5661
const containerRef = useRef<HTMLDivElement>(null);
5762

5863
// NOTE: key is used to refresh the page when local unit data is updated
@@ -111,7 +116,9 @@ function NationalSocietyLocalUnits(props: Props) {
111116

112117
const strings = useTranslation(i18n);
113118

114-
const hasAddEditLocalUnitPermission = isCountryAdmin(countryResponse?.id) || isSuperUser;
119+
const hasAddEditLocalUnitPermission = isCountryAdmin(countryResponse?.id)
120+
|| isSuperUser
121+
|| isGlobalValidator;
115122

116123
useEffect(() => {
117124
document.addEventListener('fullscreenchange', handleFullScreenChange);

0 commit comments

Comments
 (0)