Skip to content

Commit 485eaea

Browse files
shreeyash07frozenhelium
authored andcommitted
feat(status-update): add reason in local unit view and update errors
1 parent b20e658 commit 485eaea

File tree

11 files changed

+71
-10
lines changed

11 files changed

+71
-10
lines changed

app/src/utils/localUnits.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ export function getFormFields(value: LocalUnitResponse | PartialLocalUnits) {
2323
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2424
modified_by_details,
2525
// eslint-disable-next-line @typescript-eslint/no-unused-vars
26-
is_locked,
27-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2826
status,
2927
// eslint-disable-next-line @typescript-eslint/no-unused-vars
3028
version_id,

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,15 @@ function LocalUnitBulkUploadModal(props: Props) {
8989
|| isLocalUnitRegionValidatorByType(countryResponse?.region, localUnitType);
9090

9191
const { response: localUnitsOptions } = useRequest({ url: '/api/v2/local-units-options/' });
92+
9293
const { response: bulkUploadHealthTemplate } = useRequest({
9394
url: '/api/v2/bulk-upload-local-unit/get-bulk-upload-template/',
94-
pathVariables: { bulk_upload_template: 'health_care' },
95+
query: { bulk_upload_template: 'health_care' },
9596
});
97+
9698
const { response: bulkUploadDefaultTemplate } = useRequest({
9799
url: '/api/v2/bulk-upload-local-unit/get-bulk-upload-template/',
98-
pathVariables: { bulk_upload_template: 'local_unit' },
100+
query: { bulk_upload_template: 'local_unit' },
99101
});
100102

101103
const {
@@ -213,6 +215,10 @@ function LocalUnitBulkUploadModal(props: Props) {
213215
error={permissionError}
214216
/>
215217
)}
218+
<NonFieldError
219+
className={styles.nonFieldError}
220+
error={importSummaryResponse?.error_message}
221+
/>
216222
{isNotDefined(importSummaryResponse) && (
217223
<Container
218224
className={styles.uploadSummary}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,14 @@
6868
"localUnitViewLocalUnitDeleteButtonLabel": "Delete",
6969
"localUnitViewDoneButtonLabel": "Done",
7070
"localUnitViewRevertButtonLabel": "Revert",
71-
"localUnitViewReasonLabel": "Reason",
7271
"localUnitViewRevertChangesModalHeading": "Revert the Changes",
7372
"localUnitViewRevertChangesContentQuestion": "Are you sure you want to have these changes revert in this project?",
7473
"localUnitViewConfirmChangesModalHeading": "Confirm the Changes",
7574
"localUnitViewConfirmChangesContentQuestion": "Are you sure you want to have these changes in this local unit?",
7675
"localUnitViewNewLocalUnitDescription": "New local unit",
7776
"localUnitViewLatitude": "Latitude",
7877
"localUnitViewLongitude": "Longitude",
78+
"localUnitViewUpdateReason": "Edit reason",
7979
"localUnitViewNoChanges": "No changes found"
8080
}
8181
}

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {
3333
} from '../LocalUnitsFormModal/LocalUnitsForm/schema';
3434

3535
import i18n from './i18n.json';
36+
import styles from './styles.module.css';
3637

3738
type VisibilityOptions = NonNullable<GoApiResponse<'/api/v2/global-enums/'>['api_visibility_choices']>[number]
3839
type LocalUnitResponse = NonNullable<GoApiResponse<'/api/v2/local-units/{id}/'>>;
@@ -104,6 +105,21 @@ function LocalUnitView(props: Props) {
104105
emptyMessage={strings.localUnitViewNoChanges}
105106
contentViewType="grid"
106107
numPreferredGridContentColumns={3}
108+
footerContentClassName={styles.localUnitViewFooter}
109+
footerContent={(
110+
<DiffWrapper
111+
hideOnPristine
112+
diffViewEnabled
113+
value={newValue?.update_reason_overview}
114+
previousValue={oldValue?.update_reason_overview}
115+
>
116+
<TextOutput
117+
strongValue
118+
value={newValue?.update_reason_overview}
119+
label={strings.localUnitViewUpdateReason}
120+
/>
121+
</DiffWrapper>
122+
)}
107123
>
108124
<SelectDiffWrapper
109125
showOnlyDiff
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.local-unit-view-footer {
2+
border-top: var(--go-ui-width-separator-thin) solid var(--go-ui-color-separator);
3+
padding-top: var(--go-ui-spacing-md);
4+
font-style: italic;
5+
}

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

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

403403
const showChanges = !isNewLocalUnit
404404
&& isLocked
405+
&& showValueChanges
405406
&& !isExternallyManaged;
406407

407408
const showViewChanges = !isNewLocalUnit
@@ -550,7 +551,7 @@ function LocalUnitsForm(props: Props) {
550551
onChange={setFieldValue}
551552
keySelector={numericIdSelector}
552553
labelSelector={stringNameSelector}
553-
readOnly={readOnly}
554+
readOnly={readOnlyFromProps || isLocked}
554555
error={error?.type}
555556
nonClearable
556557
/>
@@ -1842,7 +1843,6 @@ function LocalUnitsForm(props: Props) {
18421843
value={updateReason}
18431844
onChange={setUpdateReason}
18441845
/>
1845-
18461846
</LocalUnitViewModal>
18471847
)}
18481848
{showValidateLocalUnitModal

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ import {
7171
import type { FilterValue } from '../Filters';
7272
import LocalUnitsFormModal from '../LocalUnitsFormModal';
7373
import { TYPE_HEALTH_CARE } from '../LocalUnitsFormModal/LocalUnitsForm/schema';
74+
import LocalUnitStatus from '../LocalUnitStatus';
7475

7576
import i18n from './i18n.json';
7677
import styles from './styles.module.css';
@@ -467,6 +468,7 @@ function LocalUnitsMap(props: Props) {
467468
popupClassName={styles.mapPopup}
468469
coordinates={clickedPointProperties.center}
469470
onCloseButtonClick={handlePointClose}
471+
headingContainerClassName={styles.headingDescription}
470472
heading={(
471473
<Button
472474
name=""
@@ -477,6 +479,12 @@ function LocalUnitsMap(props: Props) {
477479
{localUnitName}
478480
</Button>
479481
)}
482+
headingDescription={(
483+
<LocalUnitStatus
484+
value={localUnitDetail?.status}
485+
valueDisplay={localUnitDetail?.status_details}
486+
/>
487+
)}
480488
contentViewType="vertical"
481489
pending={localUnitDetailPending}
482490
errored={isDefined(localUnitDetailError)}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
}
3939
}
4040

41+
.heading-description {
42+
flex-direction: column;
43+
}
44+
4145
.map-popup {
4246
height: 16rem;
4347
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
import { isDefined } from '@togglecorp/fujs';
1111

1212
import DropdownMenuItem from '#components/DropdownMenuItem';
13+
import { environment } from '#config';
1314
import useAuth from '#hooks/domain/useAuth';
1415
import useCountry from '#hooks/domain/useCountry';
1516
import usePermissions from '#hooks/domain/usePermissions';
@@ -157,7 +158,7 @@ function LocalUnitsTableActions(props: Props) {
157158
<>
158159
<TableActions
159160
persistent
160-
extraActions={(
161+
extraActions={environment !== 'production' && (
161162
<>
162163
<DropdownMenuItem
163164
type="button"
@@ -188,7 +189,7 @@ function LocalUnitsTableActions(props: Props) {
188189
</>
189190
)}
190191
>
191-
{hasValidatePermission && (
192+
{hasValidatePermission && (environment !== 'production') && (
192193
<LocalUnitValidateButton
193194
onClick={handleValidateLocalUnitClick}
194195
status={status}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
} from '@togglecorp/fujs';
3535

3636
import DropdownMenuItem from '#components/DropdownMenuItem';
37+
import { environment } from '#config';
3738
import useAuth from '#hooks/domain/useAuth';
3839
import usePermissions from '#hooks/domain/usePermissions';
3940
import useFilterState from '#hooks/useFilterState';
@@ -249,7 +250,7 @@ function NationalSocietyLocalUnits(props: Props) {
249250
filtered={filtered}
250251
/>
251252
)}
252-
actions={isAuthenticated && (
253+
actions={isAuthenticated && (environment !== 'production') && (
253254
<>
254255
<Button
255256
name={undefined}

0 commit comments

Comments
 (0)