Skip to content

Commit 1fed7a8

Browse files
committed
Add local unit global validator permission for validation and edit
1 parent 14c3a98 commit 1fed7a8

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
@@ -49,6 +49,8 @@ function usePermissions() {
4949
&& ((userMe?.is_admin_for_countries.length ?? 0) > 0
5050
|| (userMe?.is_admin_for_regions.length ?? 0) > 0);
5151

52+
const isGlobalValidator = !isGuestUser && !!userMe?.is_global_validator;
53+
5254
return {
5355
isDrefRegionalCoordinator,
5456
isRegionAdmin,
@@ -60,6 +62,7 @@ function usePermissions() {
6062
isSuperUser,
6163
isGuestUser,
6264
isRegionalOrCountryAdmin,
65+
isGlobalValidator,
6366
};
6467
},
6568
[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)