Skip to content

Commit 2f47b7c

Browse files
committed
Hide delete local units button temporarily
1 parent 453a397 commit 2f47b7c

File tree

4 files changed

+58
-34
lines changed

4 files changed

+58
-34
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import { useLazyRequest } from '#utils/restRequest';
1111

1212
import i18n from './i18n.json';
1313

14+
const hideDelete = true;
15+
1416
interface Props {
1517
countryId: number;
1618
localUnitId: number;
@@ -74,6 +76,10 @@ function LocalUnitDeleteButton(props: Props) {
7476
},
7577
});
7678

79+
if (hideDelete) {
80+
return null;
81+
}
82+
7783
return (
7884
<ConfirmButton
7985
variant={variant}

app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsFormModal/LocalUnitsForm/i18n.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"namespace": "localUnitsForm",
33
"strings": {
4+
"lastUpdateLabel": "Last update: {modifiedAt} by {modifiedBy}",
45
"successMessage": "Local unit added successfully!",
56
"failedMessage": "Failed to add local unit",
67
"updateMessage": "Local unit updated successfully!",

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

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,19 @@ import {
99
Button,
1010
Container,
1111
DateInput,
12+
DateOutput,
1213
MultiSelectInput,
1314
NumberInput,
1415
PageContainer,
1516
Portal,
1617
SelectInput,
1718
TextArea,
1819
TextInput,
19-
TextOutput,
2020
} from '@ifrc-go/ui';
2121
import { useTranslation } from '@ifrc-go/ui/hooks';
2222
import {
2323
numericIdSelector,
24+
resolveToComponent,
2425
stringNameSelector,
2526
stringValueSelector,
2627
} from '@ifrc-go/ui/utils';
@@ -44,6 +45,7 @@ import useGlobalEnums from '#hooks/domain/useGlobalEnums';
4445
import useAlert from '#hooks/useAlert';
4546
import { getFirstTruthyString } from '#utils/common';
4647
import { VISIBILITY_PUBLIC } from '#utils/constants';
48+
import { getUserName } from '#utils/domain/user';
4749
import { CountryOutletContext } from '#utils/outletContext';
4850
import {
4951
type GoApiResponse,
@@ -312,10 +314,7 @@ function LocalUnitsForm(props: Props) {
312314
);
313315

314316
return (
315-
<PageContainer
316-
className={styles.localUnitsForm}
317-
contentClassName={styles.formContent}
318-
>
317+
<div className={styles.localUnitsForm}>
319318
{!readOnly
320319
&& isDefined(actionsContainerRef)
321320
&& isDefined(actionsContainerRef.current)
@@ -326,12 +325,21 @@ function LocalUnitsForm(props: Props) {
326325
)}
327326
{isDefined(headingDescriptionRef) && isDefined(headingDescriptionRef.current) && (
328327
<Portal container={headingDescriptionRef.current}>
329-
<TextOutput
330-
// FIXME: use strings
331-
label="Last updated on"
332-
// FIXME: use actual value
333-
value="2020-10-12"
334-
/>
328+
<div className={styles.lastUpdateLabel}>
329+
{resolveToComponent(
330+
strings.lastUpdateLabel,
331+
{
332+
modifiedAt: (
333+
<DateOutput
334+
value={localUnitDetailsResponse?.modified_at}
335+
/>
336+
),
337+
modifiedBy: getUserName(
338+
localUnitDetailsResponse?.modified_by_details,
339+
),
340+
},
341+
)}
342+
</div>
335343
</Portal>
336344
)}
337345
{isDefined(headerDescriptionRef.current) && (
@@ -350,26 +358,25 @@ function LocalUnitsForm(props: Props) {
350358
error={error?.type}
351359
nonClearable
352360
/>
353-
<SelectInput
354-
label={strings.visibility}
355-
name="visibility"
356-
required
357-
nonClearable
358-
options={visibilityOptions}
359-
value={value.visibility}
360-
onChange={setFieldValue}
361-
keySelector={VisibilityOptions}
362-
labelSelector={stringValueSelector}
363-
readOnly={readOnly}
364-
error={error?.type}
365-
/>
366-
{isDefined(countryId)
367-
&& isDefined(localUnitId)
368-
&& isDefined(onSuccess)
369-
&& isDefined(isValidated)
370-
&& (
371-
<>
372-
<div />
361+
<FormGrid>
362+
<SelectInput
363+
label={strings.visibility}
364+
name="visibility"
365+
required
366+
nonClearable
367+
options={visibilityOptions}
368+
value={value.visibility}
369+
onChange={setFieldValue}
370+
keySelector={VisibilityOptions}
371+
labelSelector={stringValueSelector}
372+
readOnly={readOnly}
373+
error={error?.type}
374+
/>
375+
{isDefined(countryId)
376+
&& isDefined(localUnitId)
377+
&& isDefined(onSuccess)
378+
&& isDefined(isValidated)
379+
&& (
373380
<div className={styles.actions}>
374381
<LocalUnitDeleteButton
375382
countryId={Number(countryId)}
@@ -394,8 +401,8 @@ function LocalUnitsForm(props: Props) {
394401
readOnly={!pristine}
395402
/>
396403
</div>
397-
</>
398-
)}
404+
)}
405+
</FormGrid>
399406
</FormGrid>
400407
</Portal>
401408
)}
@@ -1038,7 +1045,7 @@ function LocalUnitsForm(props: Props) {
10381045
</>
10391046
)}
10401047
</Container>
1041-
</PageContainer>
1048+
</div>
10421049
);
10431050
}
10441051

app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsFormModal/LocalUnitsForm/styles.module.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,21 @@
1010
display: grid;
1111
grid-template-columns: 1fr 1fr;
1212
gap: var(--go-ui-spacing-lg);
13+
14+
@media screen and (max-width: 60rem) {
15+
grid-template-columns: 1fr;
16+
}
1317
}
1418

1519
/* NOTE: this element is portaled */
1620
.actions {
1721
display: flex;
1822
gap: var(--go-ui-spacing-md);
23+
align-self: end;
24+
flex-wrap: wrap;
1925
justify-content: flex-end;
2026
}
27+
28+
.last-update-label {
29+
color: var(--go-ui-color-text-light);
30+
}

0 commit comments

Comments
 (0)