Skip to content

Commit fdc58a3

Browse files
committed
Move validate button to main local units table
1 parent 61fa52a commit fdc58a3

File tree

7 files changed

+41
-33
lines changed

7 files changed

+41
-33
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,8 @@ function LocalUnitsMap(props: Props) {
261261
properties: {
262262
id: localUnit.id,
263263
localUnitId: localUnit.id,
264+
// NOTE: we're adding radius here because of some bug in mapbox (not sure)
265+
// which doesn't render circle if there aren't any expressions
264266
radius: 12,
265267
type: localUnit.type,
266268
subType: localUnit.type === TYPE_HEALTH_CARE
@@ -386,6 +388,8 @@ function LocalUnitsMap(props: Props) {
386388
layerOptions={{
387389
type: 'circle',
388390
paint: {
391+
// NOTE: we're using expression for radius here because
392+
// of a bug in mapbox (potentially)
389393
'circle-radius': ['get', 'radius'],
390394
'circle-color': COLOR_PRIMARY_RED,
391395
'circle-opacity': 0.7,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"localUnitsView": "View",
66
"localUnitsDelete": "Delete",
77
"localUnitsValidate": "Validate",
8+
"localUnitsValidated": "Validated",
89
"deleteLocalUnitHeading": "Delete Local Unit Confirmation",
910
"deleteLocalUnitMessage": "Are you sure you want to delete \"{localUnitName}\"?",
1011
"validationMessage": "{localUnitName} was validated.",

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

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useCallback } from 'react';
2-
import { TableActions } from '@ifrc-go/ui';
2+
import { ConfirmButton, TableActions } from '@ifrc-go/ui';
33
import {
44
useBooleanState,
55
useTranslation,
@@ -19,6 +19,7 @@ import LocalUnitsFormModal from '../../LocalUnitsFormModal';
1919

2020
import i18n from './i18n.json';
2121
import styles from './styles.module.css';
22+
import { CheckboxCircleLineIcon } from '@ifrc-go/icons';
2223

2324
export interface Props {
2425
countryId: number;
@@ -92,6 +93,7 @@ function LocalUnitsTableActions(props: Props) {
9293
return (
9394
<>
9495
<TableActions
96+
className={styles.localUnitTableActions}
9597
persistent
9698
extraActions={(
9799
<>
@@ -113,30 +115,29 @@ function LocalUnitsTableActions(props: Props) {
113115
{strings.localUnitsEdit}
114116
</DropdownMenuItem>
115117
)}
116-
<DropdownMenuItem
117-
persist
118-
// NOTE sending an empty post request to validate the local unit
119-
name={null}
120-
type="confirm-button"
121-
variant="tertiary"
122-
className={styles.button}
123-
confirmHeading={strings.validateLocalUnitHeading}
124-
confirmMessage={resolveToString(
125-
strings.validateLocalUnitMessage,
126-
{ localUnitName: localUnitName ?? '' },
127-
)}
128-
onConfirm={validateLocalUnit}
129-
disabled={
130-
validateLocalUnitPending
131-
|| !hasValidatePermission
132-
|| isValidated
133-
}
134-
>
135-
{strings.localUnitsValidate}
136-
</DropdownMenuItem>
137118
</>
138119
)}
139-
/>
120+
>
121+
<ConfirmButton
122+
// NOTE sending an empty post request to validate the local unit
123+
name={null}
124+
spacing="compact"
125+
confirmHeading={strings.validateLocalUnitHeading}
126+
confirmMessage={resolveToString(
127+
strings.validateLocalUnitMessage,
128+
{ localUnitName: localUnitName ?? '' },
129+
)}
130+
onConfirm={validateLocalUnit}
131+
disabled={
132+
validateLocalUnitPending
133+
|| !hasValidatePermission
134+
|| isValidated
135+
}
136+
icons={isValidated && <CheckboxCircleLineIcon className={styles.icon} />}
137+
>
138+
{isValidated ? strings.localUnitsValidated : strings.localUnitsValidate}
139+
</ConfirmButton>
140+
</TableActions>
140141
{(showLocalUnitViewModal || showLocalUnitEditModal) && (
141142
<LocalUnitsFormModal
142143
onClose={handleLocalUnitsFormModalClose}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
.button {
2-
padding: var(--go-ui-spacing-sm) var(--go-ui-spacing-lg);
1+
.local-unit-table-actions {
2+
.icon {
3+
font-size: var(--go-ui-height-icon-multiplier);
4+
}
35
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"localUnitsTableType": "Type",
77
"localUnitsTableFocal": "Focal Person",
88
"localUnitsTablePhoneNumber": "Phone Number",
9-
"localUnitsTableEmail": "Email",
10-
"localUnitsTableValidated": "Validated"
9+
"localUnitsTableEmail": "Email"
1110
}
1211
}

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,22 +122,19 @@ function LocalUnitsTable(props: Props) {
122122
strings.localUnitsTableEmail,
123123
(item) => item.email,
124124
),
125-
createBooleanColumn<LocalUnitsTableListItem, number>(
126-
'validated',
127-
strings.localUnitsTableValidated,
128-
(item) => item.validated,
129-
),
130125
createElementColumn<LocalUnitsTableListItem, number, LocalUnitsTableActionsProps>(
131126
'actions',
132127
'',
133128
LocalUnitsTableActions,
129+
// FIXME: this should be added to a callback
134130
(_, item) => ({
135131
countryId: item.country,
136132
localUnitId: item.id,
137133
isValidated: item.validated,
138134
localUnitName: item.local_branch_name ?? item.english_branch_name,
139135
onActionSuccess: refetchLocalUnits,
140136
}),
137+
{ columnClassName: styles.actions },
141138
),
142139
]),
143140
[
@@ -147,7 +144,6 @@ function LocalUnitsTable(props: Props) {
147144
strings.localUnitsTableFocal,
148145
strings.localUnitsTablePhoneNumber,
149146
strings.localUnitsTableEmail,
150-
strings.localUnitsTableValidated,
151147
refetchLocalUnits,
152148
],
153149
);

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,9 @@
55
width: 8rem;
66
min-width: 8rem;
77
}
8+
9+
.actions {
10+
width: 11rem;
11+
min-width: 11rem;
12+
}
813
}

0 commit comments

Comments
 (0)