diff --git a/app/src/hooks/domain/usePermissions.ts b/app/src/hooks/domain/usePermissions.ts
index feff71b43..9c0e19523 100644
--- a/app/src/hooks/domain/usePermissions.ts
+++ b/app/src/hooks/domain/usePermissions.ts
@@ -20,7 +20,7 @@ function usePermissions() {
&& isDefined(countryId)
&& !!userMe?.is_admin_for_countries?.includes(countryId)
);
- const isRegionAdmin = (regionId: number | undefined) => (
+ const isRegionAdmin = (regionId: number | null | undefined) => (
!isGuestUser
&& isDefined(regionId)
&& !!userMe?.is_admin_for_regions?.includes(regionId)
diff --git a/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/ConfigureLocalUnitsModal/ConfirmationModal/index.tsx b/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/ConfigureLocalUnitsModal/ConfirmationModal/index.tsx
index 6d77015b4..e9993689d 100644
--- a/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/ConfigureLocalUnitsModal/ConfirmationModal/index.tsx
+++ b/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/ConfigureLocalUnitsModal/ConfirmationModal/index.tsx
@@ -111,8 +111,9 @@ function ConfirmationModal(props: Props) {
const handleConfirmButtonChange = useCallback(() => {
if (isNewManageLocalUnit) {
addManageLocalUnit(manageLocalUnitsValues);
+ } else {
+ updateManageLocalUnit(manageLocalUnitsValues);
}
- updateManageLocalUnit(manageLocalUnitsValues);
}, [isNewManageLocalUnit,
addManageLocalUnit, manageLocalUnitsValues, updateManageLocalUnit]);
diff --git a/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/ConfigureLocalUnitsModal/index.tsx b/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/ConfigureLocalUnitsModal/index.tsx
index f8e5d8425..6f19f6ab9 100644
--- a/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/ConfigureLocalUnitsModal/index.tsx
+++ b/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/ConfigureLocalUnitsModal/index.tsx
@@ -67,22 +67,13 @@ function ConfigureLocalUnitsModal(props: Props) {
const handleLocalUnitSwitchChange = useCallback((value: boolean, name: number) => {
setLocalUnitType(name);
- if (isNotDefined(manageResponse)
- && isDefined(countryResponse)
- ) {
- setManageLocalUnitsValues({
- id: undefined,
- country: countryResponse.id,
- local_unit_type: name,
- enabled: value,
- });
- }
- if (isDefined(manageResponse)
- && isDefined(manageResponse[name])
- && isDefined(countryResponse)
- ) {
+
+ if (isDefined(countryResponse)) {
+ const isNew = isNotDefined(manageResponse) || isNotDefined(manageResponse[name]);
+ const manageId = isNew ? undefined : manageResponse[name]?.externallyManagedId;
+
setManageLocalUnitsValues({
- id: manageResponse[name].externallyManagedId,
+ id: manageId,
country: countryResponse.id,
local_unit_type: name,
enabled: value,
@@ -97,8 +88,8 @@ function ConfigureLocalUnitsModal(props: Props) {
]);
const isNewManageLocalUnit = useMemo(() => {
- if (isDefined(manageLocalUnitsValues)
- && isDefined(manageLocalUnitsValues.id)) {
+ if (isNotDefined(manageLocalUnitsValues)
+ || isNotDefined(manageLocalUnitsValues?.id)) {
return true;
}
return false;
diff --git a/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitView/OtherProfilesDiffOutput/i18n.json b/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitView/OtherProfilesDiffOutput/i18n.json
index 64eccbeff..60a53c366 100644
--- a/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitView/OtherProfilesDiffOutput/i18n.json
+++ b/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitView/OtherProfilesDiffOutput/i18n.json
@@ -1,7 +1,6 @@
{
"namespace": "countryNsOverviewContextAndStructure",
"strings": {
- "otherProfileOutputLabel": "Other Profiles",
"otherProfilePositionOutputLabel": "Position",
"otherProfileNumberOutputLabel": "Number"
}
diff --git a/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitView/i18n.json b/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitView/i18n.json
index 257cb93a1..c170e0448 100644
--- a/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitView/i18n.json
+++ b/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitView/i18n.json
@@ -55,6 +55,7 @@
"localUnitViewDentist": "Dentist",
"localUnitViewNursingAid": "Nursing aid",
"localUnitViewMidwife": "Midwife",
+ "localUnitViewPharmacists": "Pharmacists",
"localUnitViewOtherProfiles": "Other profiles",
"localUnitViewRemovedOtherProfiles": "Removed Other profiles",
"localUnitViewOtherMedicalHeal": "Other medical heal",
diff --git a/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitView/index.tsx b/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitView/index.tsx
index 7d15bafc3..bfec9c8fd 100644
--- a/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitView/index.tsx
+++ b/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitView/index.tsx
@@ -892,6 +892,18 @@ function LocalUnitView(props: Props) {
value={newValue?.health?.midwife}
/>
+
+
+
{isDefined(changedOtherProfiles) && changedOtherProfiles.length > 0 && (
<>
diff --git a/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsFormModal/LocalUnitsForm/i18n.json b/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsFormModal/LocalUnitsForm/i18n.json
index 5b76094bf..6a8089556 100644
--- a/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsFormModal/LocalUnitsForm/i18n.json
+++ b/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsFormModal/LocalUnitsForm/i18n.json
@@ -67,6 +67,7 @@
"dentist": "Dentist",
"nursingAid": "Nursing aid",
"midwife": "Midwife",
+ "pharmacists": "Pharmacists",
"otherMedicalHeal": "Other medical heal",
"commentsNS": "Comments by the NS",
"addOtherProfilesButtonLabel": "Add Other Profiles",
diff --git a/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsFormModal/LocalUnitsForm/index.tsx b/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsFormModal/LocalUnitsForm/index.tsx
index 3c734ff28..a72af3fd9 100644
--- a/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsFormModal/LocalUnitsForm/index.tsx
+++ b/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsFormModal/LocalUnitsForm/index.tsx
@@ -155,6 +155,7 @@ function LocalUnitsForm(props: Props) {
const {
isSuperUser,
isCountryAdmin,
+ isRegionAdmin,
isLocalUnitGlobalValidatorByType,
isLocalUnitRegionValidatorByType,
isLocalUnitCountryValidatorByType,
@@ -271,8 +272,7 @@ function LocalUnitsForm(props: Props) {
);
}, [externallyManagedLocalUnitsResponse]);
- const isEditable = isDefined(localUnitDetailsResponse?.status)
- && localUnitDetailsResponse.status === VALIDATED;
+ const isEditable = localUnitDetailsResponse?.status === VALIDATED;
const isNewlyCreated = localUnitDetailsResponse?.status === UNVALIDATED;
const isExternallyManaged = localUnitDetailsResponse?.status === EXTERNALLY_MANAGED;
@@ -280,7 +280,7 @@ function LocalUnitsForm(props: Props) {
? !!(externallyManagedByLocalUnitType?.[value.type])
: false;
- const readOnly = readOnlyFromProps || !isEditable || isExternallyManaged;
+ const readOnly = readOnlyFromProps || isExternallyManaged || isExternallyManagedType;
const {
response: localUnitsOptions,
@@ -389,7 +389,12 @@ function LocalUnitsForm(props: Props) {
|| isLocalUnitRegionValidatorByType(countryResponse?.region, value.type)
);
- const hasUpdatePermission = isCountryAdmin(countryResponse?.id) || hasValidatePermission;
+ const hasUpdatePermission = isCountryAdmin(countryResponse?.id)
+ || isRegionAdmin(countryResponse?.region)
+ || hasValidatePermission;
+
+ const hasDeletePermission = isCountryAdmin(countryResponse?.id)
+ || hasValidatePermission;
const handleFormSubmit = useCallback(
() => {
@@ -538,7 +543,7 @@ function LocalUnitsForm(props: Props) {
{isDefined(localUnitDetailsResponse) && (
<>
- {hasUpdatePermission && (
+ {hasDeletePermission && (
{value.type === TYPE_HEALTH_CARE && (
- <>
-
-
+
+
+
+
+
+
+
-
- {hasUpdatePermission && (
- <>
-
+
+
+
+
-
-
-
+
+
+
-
-
- >
- )}
- >
- )}
- {value.type !== TYPE_HEALTH_CARE && hasUpdatePermission && (
- <>
-
-
-
-
-
-
- >
+ />
+
+ >
+ )
)}
{value.type !== TYPE_HEALTH_CARE && (
<>
@@ -1622,59 +1622,6 @@ function LocalUnitsForm(props: Props) {
)}
/>
- {value.health?.health_facility_type === HOSPITAL_TYPE && (
- <>
- {value.health?.is_in_patient_capacity && (
-
-
-
- )}
- {value.health?.is_isolation_rooms_wards && (
-
-
-
- )}
- >
- )}
{value?.health?.health_facility_type === HOSPITAL_TYPE && (
@@ -1730,6 +1677,30 @@ function LocalUnitsForm(props: Props) {
error={healthFormError?.is_in_patient_capacity}
/>
+ {value.health?.is_in_patient_capacity && (
+
+
+
+ )}
+ {value.health?.is_isolation_rooms_wards && (
+
+
+
+ )}
>
)}
@@ -1925,16 +1923,25 @@ function LocalUnitsForm(props: Props) {
)}
/>
- {!readOnly && (
-
- )}
+
+
+
{value.health?.other_profiles?.map((profile, i) => (
))}
+ {!readOnly && (
+
+ )}
diff --git a/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsFormModal/LocalUnitsForm/schema.ts b/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsFormModal/LocalUnitsForm/schema.ts
index 23c72af56..d03b37637 100644
--- a/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsFormModal/LocalUnitsForm/schema.ts
+++ b/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsFormModal/LocalUnitsForm/schema.ts
@@ -162,6 +162,7 @@ const schema: LocalUnitsFormSchema = {
],
},
focal_point_position: {
+ required: true,
validations: [lengthSmallerThanCondition(50)],
},
focal_point_phone_number: {
@@ -250,6 +251,11 @@ const schema: LocalUnitsFormSchema = {
positiveIntegerCondition,
],
},
+ pharmacists: {
+ validations: [
+ positiveIntegerCondition,
+ ],
+ },
other_medical_heal: {},
other_profiles: {
keySelector: (item) => item.client_id,
diff --git a/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsTable/LocalUnitTableActions/index.tsx b/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsTable/LocalUnitTableActions/index.tsx
index 4d4b65e1d..120311e70 100644
--- a/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsTable/LocalUnitTableActions/index.tsx
+++ b/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsTable/LocalUnitTableActions/index.tsx
@@ -64,27 +64,30 @@ function LocalUnitsTableActions(props: Props) {
isLocalUnitRegionValidatorByType,
isSuperUser,
isGuestUser,
+ isCountryAdmin,
+ isRegionAdmin,
} = usePermissions();
const isLocked = status !== VALIDATED;
+ const countryAdmin = isCountryAdmin(countryDetails?.id);
+ const regionAdmin = isRegionAdmin(countryDetails?.region);
+
const isExternallyManaged = status === EXTERNALLY_MANAGED
|| (isDefined(localUnitType)
&& isDefined(manageResponse)
&& !!manageResponse[localUnitType]?.enabled);
- const hasPermission = isAuthenticated
+ const hasValidatePermission = isAuthenticated
&& !isExternallyManaged
&& (isSuperUser
|| isLocalUnitGlobalValidatorByType(localUnitType)
|| isLocalUnitCountryValidatorByType(countryDetails?.id, localUnitType)
|| isLocalUnitRegionValidatorByType(countryDetails?.region, localUnitType));
- const hasValidatePermission = isAuthenticated
- && (isSuperUser
- || isLocalUnitGlobalValidatorByType(localUnitType)
- || isLocalUnitCountryValidatorByType(countryDetails?.id, localUnitType)
- || isLocalUnitRegionValidatorByType(countryDetails?.region, localUnitType));
+ const hasAddEditLocalUnitPermission = !isLocked && (
+ (hasValidatePermission || countryAdmin || regionAdmin)
+ && !isBulkUploadLocalUnit);
const [readOnlyLocalUnitModal, setReadOnlyLocalUnitModal] = useState(false);
@@ -165,7 +168,8 @@ function LocalUnitsTableActions(props: Props) {
>
{strings.localUnitActionsView}
- {(hasPermission && !isBulkUploadLocalUnit) && (
+ {((hasValidatePermission || countryAdmin)
+ && !isBulkUploadLocalUnit) && (
)}
- {!isLocked && (hasPermission && !isBulkUploadLocalUnit) && (
+ {hasAddEditLocalUnitPermission && (
)}
diff --git a/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsTable/index.tsx b/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsTable/index.tsx
index dafce1c21..a210233e5 100644
--- a/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsTable/index.tsx
+++ b/app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsTable/index.tsx
@@ -58,6 +58,7 @@ function LocalUnitsTable(props: Props) {
const {
isSuperUser,
isCountryAdmin,
+ isRegionAdmin,
isLocalUnitGlobalValidator,
isLocalUnitRegionValidator,
isLocalUnitCountryValidator,
@@ -71,6 +72,7 @@ function LocalUnitsTable(props: Props) {
|| isLocalUnitRegionValidator(countryResponse?.region ?? undefined);
const hasAddEditLocalUnitPermission = isCountryAdmin(countryResponse?.id)
+ || isRegionAdmin(countryResponse?.region)
|| hasPermission;
const {
diff --git a/go-api b/go-api
index 2960f07e4..e818755e8 160000
--- a/go-api
+++ b/go-api
@@ -1 +1 @@
-Subproject commit 2960f07e433fd8cf6e1fbd7f1ffe4d2b543000f9
+Subproject commit e818755e8c4119fadaeb820f70c1fd5df28b5d67