Skip to content

Commit 01a7d4d

Browse files
committed
fix(local-unit): update permission to delete local unit
- update zoom level in local unit form map - update descriptions in import modal
1 parent 0c87168 commit 01a7d4d

File tree

12 files changed

+123
-71
lines changed

12 files changed

+123
-71
lines changed

app/src/components/domain/BaseMapPointInput/index.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,15 @@ function BaseMapPointInput<NAME extends string>(props: Props<NAME>) {
219219
const [searchResult, setSearchResult] = useState<LocationSearchResult | undefined>();
220220

221221
const center = useMemo(() => {
222-
if (isNotDefined(searchResult)) {
223-
return undefined;
222+
if (isDefined(value?.lng) && isDefined(value?.lat)) {
223+
return [value.lng, value.lat] satisfies [number, number];
224+
}
225+
if (isDefined(searchResult)) {
226+
return [+searchResult.lon, +searchResult.lat] satisfies [number, number];
224227
}
225228

226-
return [+searchResult.lon, +searchResult.lat] satisfies [number, number];
227-
}, [searchResult]);
229+
return undefined;
230+
}, [searchResult, value?.lng, value?.lat]);
228231

229232
return (
230233
<div className={_cs(styles.baseMapPointInput, className)}>

app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitImportModal/i18n.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
"closeButtonLabel": "Close",
88
"localUnitTypeInputLabel": "Local unit type",
99
"uploadFileSectionTitle": "Upload xlsx file",
10-
"uploadFileSectionDescription": "Please make sure to select a supported file format (xlsx) with size less than 10MB",
10+
"uploadFileSectionDescription": "Please make sure to select a supported file format (xlsx, xlsm) with size less than 10MB",
1111
"selectFileButtonLabel": "Select a file",
1212
"cancelUploadButtonLabel": "Cancel",
1313
"startUploadButtonLabel": "Upload",
1414
"contentStructureDescription": "The contents in the xlsx should follow the structure provided in {templateLink}.",
15+
"contentStructureNoteLabel": "Note",
16+
"contentStructureNote": "To enable multi-select functionality in certain fields, please click “Enable Macros” when prompted after opening the downloaded template file.",
1517
"templateLinkLabel": "this template",
1618
"noPermissionBothDescription": "You don't have permission and this unit is not externally managed.",
1719
"noPermissionErrorDescription": "You do not have the permission to upload local unit data",

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

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
Modal,
1515
RawFileInput,
1616
SelectInput,
17+
TextOutput,
1718
} from '@ifrc-go/ui';
1819
import { useTranslation } from '@ifrc-go/ui/hooks';
1920
import {
@@ -230,24 +231,32 @@ function LocalUnitBulkUploadModal(props: Props) {
230231
withInternalPadding
231232
footerContent={(
232233
<div className={styles.fileStructureDescription}>
233-
{resolveToComponent(
234-
strings.contentStructureDescription,
235-
{
236-
templateLink: (
237-
<Link
238-
external
239-
href={localUnitType === TYPE_HEALTH_CARE
240-
? bulkUploadHealthTemplate?.template_url
241-
: bulkUploadDefaultTemplate?.template_url}
242-
variant="tertiary"
243-
iconsContainerClassName={styles.downloadLink}
244-
withUnderline
245-
>
246-
{strings.templateLinkLabel}
247-
</Link>
248-
),
249-
},
250-
)}
234+
<span>
235+
{resolveToComponent(
236+
strings.contentStructureDescription,
237+
{
238+
templateLink: (
239+
<Link
240+
external
241+
href={localUnitType === TYPE_HEALTH_CARE
242+
? bulkUploadHealthTemplate?.template_url
243+
: bulkUploadDefaultTemplate?.template_url}
244+
variant="tertiary"
245+
iconsContainerClassName={styles.downloadLink}
246+
withUnderline
247+
>
248+
{strings.templateLinkLabel}
249+
</Link>
250+
),
251+
},
252+
)}
253+
</span>
254+
<TextOutput
255+
strongLabel
256+
valueType="text"
257+
label={strings.contentStructureNoteLabel}
258+
value={strings.contentStructureNote}
259+
/>
251260
</div>
252261
)}
253262
>
@@ -258,7 +267,7 @@ function LocalUnitBulkUploadModal(props: Props) {
258267
{isNotDefined(bulkUploadFile) && (
259268
<RawFileInput
260269
name="file"
261-
accept=".xlsx"
270+
accept=".xlsx, .xlsm"
262271
onChange={setBulkUploadFile}
263272
variant="secondary"
264273
disabled={

app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitImportModal/styles.module.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
background-color: var(--go-ui-color-background);
55
}
66

7+
.file-structure-description {
8+
display: flex;
9+
flex-direction: column;
10+
gap: var(--go-ui-spacing-md);
11+
}
12+
713
.upload-section {
814
display: flex;
915
align-items: start;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"namespace": "countryNsOverviewContextAndStructure",
3+
"strings": {
4+
"localUnitReviewButtonLabel": "Review"
5+
}
6+
}

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { Button } from '@ifrc-go/ui';
2+
import { useTranslation } from '@ifrc-go/ui/hooks';
23
import { _cs } from '@togglecorp/fujs';
34

45
import { VALIDATED } from '../common';
56

7+
import i18n from './i18n.json';
68
import styles from './styles.module.css';
79

810
interface Props {
@@ -13,11 +15,12 @@ interface Props {
1315
function LocalUnitValidateButton(props: Props) {
1416
const {
1517
status,
16-
// statusDetails,
1718
onClick,
1819
hasValidatePermission,
1920
} = props;
2021

22+
const strings = useTranslation(i18n);
23+
2124
const isValidated = status === VALIDATED;
2225

2326
if (isValidated || !hasValidatePermission) {
@@ -36,9 +39,8 @@ function LocalUnitValidateButton(props: Props) {
3639
!hasValidatePermission
3740
|| isValidated
3841
}
39-
// FIXME: use translations
4042
>
41-
Review
43+
{strings.localUnitReviewButtonLabel}
4244
</Button>
4345
);
4446
}

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

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -382,13 +382,13 @@ function LocalUnitsForm(props: Props) {
382382
},
383383
});
384384

385-
const hasValidatePermission = isAuthenticated && (
386-
!isExternallyManaged
387-
|| isSuperUser
388-
|| isLocalUnitGlobalValidatorByType(value.type)
389-
|| isLocalUnitCountryValidatorByType(countryResponse?.id, value.type)
390-
|| isLocalUnitRegionValidatorByType(countryResponse?.region, value.type)
391-
);
385+
const hasValidatePermission = isAuthenticated
386+
&& !isExternallyManaged
387+
&& (isSuperUser
388+
|| isLocalUnitGlobalValidatorByType(value.type)
389+
|| isLocalUnitCountryValidatorByType(countryResponse?.id, value.type)
390+
|| isLocalUnitRegionValidatorByType(countryResponse?.region, value.type)
391+
);
392392

393393
const hasUpdatePermission = isCountryAdmin(countryResponse?.id)
394394
|| isRegionAdmin(countryResponse?.region)
@@ -542,20 +542,20 @@ function LocalUnitsForm(props: Props) {
542542
{isDefined(localUnitDetailsResponse) && (
543543
<>
544544
{hasValidatePermission && (
545-
<Button
546-
name={undefined}
547-
onClick={setShowDeleteLocalUnitModalTrue}
548-
variant="secondary"
549-
>
550-
{strings.localUnitDeleteButtonLabel}
551-
</Button>
552-
)}
553-
{hasValidatePermission && (
554-
<LocalUnitValidateButton
555-
onClick={setShowValidateLocalUnitModalTrue}
556-
status={localUnitDetailsResponse.status}
557-
hasValidatePermission={hasValidatePermission}
558-
/>
545+
<>
546+
<Button
547+
name={undefined}
548+
onClick={setShowDeleteLocalUnitModalTrue}
549+
variant="secondary"
550+
>
551+
{strings.localUnitDeleteButtonLabel}
552+
</Button>
553+
<LocalUnitValidateButton
554+
onClick={setShowValidateLocalUnitModalTrue}
555+
status={localUnitDetailsResponse.status}
556+
hasValidatePermission={hasValidatePermission}
557+
/>
558+
</>
559559
)}
560560
{readOnlyFromProps
561561
&& isEditable

app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsFormModal/LocalUnitsForm/schema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { isNotDefined } from '@togglecorp/fujs';
12
import {
23
addCondition,
34
emailCondition,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ function LocalUnitsTableActions(props: Props) {
168168
>
169169
{strings.localUnitActionsView}
170170
</DropdownMenuItem>
171-
{((hasValidatePermission || countryAdmin)
171+
{(hasValidatePermission
172172
&& !isBulkUploadLocalUnit) && (
173173
<DropdownMenuItem
174174
type="button"

app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsTable/i18n.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
"localUnitsTableName": "Name",
55
"localUnitsTableAddress": "Address",
66
"localUnitsTableType": "Type",
7-
"localUnitsTableFocal": "Focal Person",
8-
"localUnitsTableStatus": "Status",
9-
"localUnitsTablePhoneNumber": "Phone Number",
10-
"localUnitsTableEmail": "Email"
7+
"localUnitsTableStatus": "Status"
118
}
129
}

0 commit comments

Comments
 (0)