Skip to content

Commit f56d65f

Browse files
committed
Update the logic to access operation update for dref type imminent
1 parent 9564fd3 commit f56d65f

File tree

7 files changed

+44
-26
lines changed

7 files changed

+44
-26
lines changed

app/src/views/AccountMyFormsDref/ActiveDrefTable/index.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import {
3030
import useUserMe from '#hooks/domain/useUserMe';
3131
import useFilterState from '#hooks/useFilterState';
3232
import {
33-
DREF_TYPE_IMMINENT,
3433
DREF_TYPE_LOAN,
3534
type TypeOfDrefEnum,
3635
} from '#utils/constants';
@@ -239,12 +238,7 @@ function ActiveDrefTable(props: Props) {
239238
const canAddOpsUpdate = (is_published ?? false)
240239
&& (applicationType === 'DREF' || applicationType === 'OPS_UPDATE')
241240
&& !has_final_report
242-
&& unpublished_op_update_count === 0
243-
// NOTE: Adding this to disable updates just for the old imminents
244-
&& (item.type_of_dref !== DREF_TYPE_IMMINENT
245-
|| (item.type_of_dref === DREF_TYPE_IMMINENT
246-
&& !!is_dref_imminent_v2)
247-
);
241+
&& unpublished_op_update_count === 0;
248242

249243
const canCreateFinalReport = !has_final_report
250244
&& (applicationType === 'DREF' || applicationType === 'OPS_UPDATE')
@@ -268,6 +262,7 @@ function ActiveDrefTable(props: Props) {
268262
drefId: originalDref.id,
269263
drefType,
270264
status: item.status,
265+
isDrefImminentV2: is_dref_imminent_v2,
271266
applicationType,
272267
canAddOpsUpdate,
273268
canCreateFinalReport,

app/src/views/AccountMyFormsDref/DrefTableActions/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export interface Props {
5252
canAddOpsUpdate: boolean;
5353
canCreateFinalReport: boolean;
5454
hasPermissionToApprove?: boolean;
55+
isDrefImminentV2?: boolean;
5556

5657
onPublishSuccess?: () => void;
5758
drefType?: TypeOfDrefEnum | null | undefined;
@@ -66,6 +67,7 @@ function DrefTableActions(props: Props) {
6667
canAddOpsUpdate,
6768
canCreateFinalReport,
6869
hasPermissionToApprove,
70+
isDrefImminentV2,
6971
onPublishSuccess,
7072
drefType,
7173
} = props;
@@ -383,7 +385,7 @@ function DrefTableActions(props: Props) {
383385

384386
const canApprove = status === DREF_STATUS_IN_PROGRESS && hasPermissionToApprove;
385387

386-
const shouldConfirmImminentAddOpsUpdate = drefType === DREF_TYPE_IMMINENT;
388+
const shouldConfirmImminentAddOpsUpdate = drefType === DREF_TYPE_IMMINENT && isDrefImminentV2;
387389

388390
const disabled = fetchingDref
389391
|| fetchingOpsUpdate

app/src/views/DrefFinalReportForm/Overview/index.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ interface Props {
8484
setFieldValue: (...entries: EntriesAsList<PartialFinalReport>) => void;
8585
error: Error<PartialFinalReport> | undefined;
8686
disabled?: boolean;
87+
isPreviousImminent: boolean;
8788

8889
fileIdToUrlMap: Record<number, string>;
8990
setFileIdToUrlMap?: React.Dispatch<React.SetStateAction<Record<number, string>>>;
@@ -96,6 +97,7 @@ function Overview(props: Props) {
9697
const {
9798
value,
9899
setFieldValue,
100+
isPreviousImminent,
99101
error: formError,
100102
fileIdToUrlMap,
101103
setFileIdToUrlMap,
@@ -153,6 +155,12 @@ function Overview(props: Props) {
153155
user,
154156
}), []);
155157

158+
const imminentFilteredTypeOfDrefOptions = useMemo(() => (
159+
typeOfDrefOptions?.filter(
160+
(option) => option.key !== TYPE_LOAN,
161+
)
162+
), [typeOfDrefOptions]);
163+
156164
const filteredTypeOfDrefOptions = useMemo(() => (
157165
typeOfDrefOptions?.filter(
158166
(option) => option.key !== TYPE_LOAN && option.key !== TYPE_IMMINENT,
@@ -241,7 +249,10 @@ function Overview(props: Props) {
241249
<SelectInput
242250
name="type_of_dref"
243251
label={strings.drefFormTypeOfDref}
244-
options={filteredTypeOfDrefOptions}
252+
options={
253+
isPreviousImminent ? imminentFilteredTypeOfDrefOptions
254+
: filteredTypeOfDrefOptions
255+
}
245256
keySelector={typeOfDrefKeySelector}
246257
labelSelector={stringValueSelector}
247258
onChange={setFieldValue}

app/src/views/DrefFinalReportForm/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import NonFieldError from '#components/NonFieldError';
3838
import Page from '#components/Page';
3939
import useCurrentLanguage from '#hooks/domain/useCurrentLanguage';
4040
import useAlert from '#hooks/useAlert';
41+
import { DREF_TYPE_IMMINENT } from '#utils/constants';
4142
import {
4243
type GoApiResponse,
4344
useLazyRequest,
@@ -97,6 +98,7 @@ export function Component() {
9798
const formContentRef = useRef<ElementRef<'div'>>(null);
9899

99100
const [activeTab, setActiveTab] = useState<TabKeys>('overview');
101+
const [isPreviousImminent, setIsPreviousImminent] = useState(false);
100102
const [fileIdToUrlMap, setFileIdToUrlMap] = useState<Record<number, string>>({});
101103
const [districtOptions, setDistrictOptions] = useState<
102104
DistrictItem[] | undefined | null
@@ -206,6 +208,7 @@ export function Component() {
206208
} : undefined,
207209
onSuccess: (response) => {
208210
handleFinalReportLoad(response);
211+
setIsPreviousImminent(response.type_of_dref === DREF_TYPE_IMMINENT);
209212

210213
const {
211214
planned_interventions,
@@ -482,6 +485,7 @@ export function Component() {
482485
value={value}
483486
setFieldValue={setFieldValue}
484487
fileIdToUrlMap={fileIdToUrlMap}
488+
isPreviousImminent={isPreviousImminent}
485489
setFileIdToUrlMap={setFileIdToUrlMap}
486490
error={formError}
487491
disabled={disabled}

app/src/views/DrefOperationalUpdateForm/Overview/index.tsx

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ const userKeySelector = (item: User) => item.id;
9393

9494
interface Props {
9595
value: PartialOpsUpdate;
96+
isPreviousImminent: boolean;
9697
setFieldValue: (...entries: EntriesAsList<PartialOpsUpdate>) => void;
9798
error: Error<PartialOpsUpdate> | undefined;
9899
disabled?: boolean;
@@ -107,6 +108,7 @@ interface Props {
107108
function Overview(props: Props) {
108109
const {
109110
value,
111+
isPreviousImminent,
110112
setFieldValue,
111113
error: formError,
112114
fileIdToUrlMap,
@@ -220,6 +222,7 @@ function Overview(props: Props) {
220222
return (
221223
<div className={styles.operationOverview}>
222224
{state?.isNewOpsUpdate
225+
&& !isPreviousImminent
223226
&& showChangeDrefTypeModal
224227
&& value?.type_of_dref === TYPE_ASSESSMENT && (
225228
<Modal
@@ -247,22 +250,6 @@ function Overview(props: Props) {
247250
{strings.isDrefChangingToResponse}
248251
</Modal>
249252
)}
250-
{value.type_of_dref === TYPE_IMMINENT && (
251-
<Modal
252-
size="sm"
253-
heading={strings.overviewChangeTypeHeading}
254-
footerActions={(
255-
<Button
256-
name={undefined}
257-
onClick={handleChangeToResponse}
258-
>
259-
{strings.overviewChangeTypeButtonLabel}
260-
</Button>
261-
)}
262-
>
263-
{strings.overviewChangeTypeMessage}
264-
</Modal>
265-
)}
266253
<Container
267254
heading={strings.drefFormSharingHeading}
268255
childrenContainerClassName={styles.content}
@@ -321,7 +308,11 @@ function Overview(props: Props) {
321308
<SelectInput
322309
name="type_of_dref"
323310
label={strings.drefFormTypeOfDref}
324-
options={typeOfDrefOptionsWithoutImminent}
311+
options={
312+
isPreviousImminent
313+
? typeOfDrefOptions
314+
: typeOfDrefOptionsWithoutImminent
315+
}
325316
keySelector={typeOfDrefKeySelector}
326317
labelSelector={stringValueSelector}
327318
onChange={setFieldValue}

app/src/views/DrefOperationalUpdateForm/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import {
5757
import Actions from './Actions';
5858
import {
5959
checkTabErrors,
60+
TYPE_IMMINENT,
6061
TYPE_LOAN,
6162
type TypeOfDrefEnum,
6263
} from './common';
@@ -120,6 +121,7 @@ export function Component() {
120121
const formContentRef = useRef<ElementRef<'div'>>(null);
121122

122123
const [activeTab, setActiveTab] = useState<TabKeys>('overview');
124+
const [isPreviousImminent, setIsPreviousImminent] = useState(false);
123125
const [fileIdToUrlMap, setFileIdToUrlMap] = useState<Record<number, string>>({});
124126
const [
125127
showObsoletePayloadModal,
@@ -256,6 +258,7 @@ export function Component() {
256258
// is_assessment_report,
257259
...otherValues
258260
} = removeNull(response);
261+
setIsPreviousImminent(response.type_of_dref === TYPE_IMMINENT);
259262
setValue({
260263
...otherValues,
261264
planned_interventions: planned_interventions?.map(
@@ -695,6 +698,7 @@ export function Component() {
695698
<TabPanel name="overview">
696699
<Overview
697700
value={value}
701+
isPreviousImminent={isPreviousImminent}
698702
setFieldValue={setFieldValue}
699703
fileIdToUrlMap={fileIdToUrlMap}
700704
setFileIdToUrlMap={setFileIdToUrlMap}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"parent": "000039-1750673601185.json",
3+
"actions": [
4+
{
5+
"action": "add",
6+
"key": "drefFormAssessmentReportUploadDescription",
7+
"namespace": "drefOperationalUpdateForm",
8+
"value": "Assessment report file type: pdf, docx, pptx, xlsx."
9+
}
10+
]
11+
}

0 commit comments

Comments
 (0)