Skip to content

Commit eb36b71

Browse files
committed
feat(dref-translation): update dref status and publish api to approve
1 parent 1eea6a4 commit eb36b71

File tree

7 files changed

+21
-13
lines changed

7 files changed

+21
-13
lines changed

app/src/utils/constants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ export const FONT_FAMILY_HEADER = 'Montserrat';
8484
// This should not be the same as OperationType.
8585
export type DrefStatus = components<'read'>['schemas']['DrefDrefStatusEnumKey'];
8686
// const DREF_STATUS_COMPLETED = 1 satisfies DrefStatus;
87-
export const DREF_STATUS_IN_PROGRESS = 0 satisfies DrefStatus;
87+
export const DREF_STATUS_DRAFT = 1 satisfies DrefStatus;
88+
export const DREF_STATUS_APPROVED = 4 satisfies DrefStatus;
8889

8990
export type TypeOfDrefEnum = components<'read'>['schemas']['DrefDrefDrefTypeEnumKey'];
9091
export const DREF_TYPE_IMMINENT = 0 satisfies TypeOfDrefEnum;

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import {
3030
import useUserMe from '#hooks/domain/useUserMe';
3131
import useFilterState from '#hooks/useFilterState';
3232
import {
33+
DREF_STATUS_APPROVED,
3334
DREF_TYPE_LOAN,
3435
type TypeOfDrefEnum,
3536
} from '#utils/constants';
@@ -230,13 +231,15 @@ function ActiveDrefTable(props: Props) {
230231

231232
const {
232233
unpublished_op_update_count,
233-
is_published,
234+
status,
234235
has_ops_update,
235236
has_final_report,
236237
country_details,
237238
is_dref_imminent_v2,
238239
} = originalDref;
239240

241+
const is_published = status === DREF_STATUS_APPROVED;
242+
240243
const canAddOpsUpdate = (is_published ?? false)
241244
&& (applicationType === 'DREF' || applicationType === 'OPS_UPDATE')
242245
&& !has_final_report

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import Link from '#components/Link';
2727
import useAlert from '#hooks/useAlert';
2828
import useRouting from '#hooks/useRouting';
2929
import {
30-
DREF_STATUS_IN_PROGRESS,
30+
DREF_STATUS_DRAFT,
3131
DREF_TYPE_IMMINENT,
3232
DREF_TYPE_LOAN,
3333
type DrefStatus,
@@ -167,7 +167,7 @@ function DrefTableActions(props: Props) {
167167
pending: publishDrefPending,
168168
} = useLazyRequest({
169169
method: 'POST',
170-
url: '/api/v2/dref/{id}/publish/',
170+
url: '/api/v2/dref/{id}/approve/',
171171
pathVariables: { id: String(id) },
172172
// FIXME: typings should be fixed in the server
173173
body: () => ({} as never),
@@ -198,7 +198,7 @@ function DrefTableActions(props: Props) {
198198
pending: publishOpsUpdatePending,
199199
} = useLazyRequest({
200200
method: 'POST',
201-
url: '/api/v2/dref-op-update/{id}/publish/',
201+
url: '/api/v2/dref-op-update/{id}/approve/',
202202
pathVariables: { id: String(id) },
203203
// FIXME: typings should be fixed in the server
204204
body: () => ({} as never),
@@ -229,7 +229,7 @@ function DrefTableActions(props: Props) {
229229
pending: publishFinalReportPending,
230230
} = useLazyRequest({
231231
method: 'POST',
232-
url: '/api/v2/dref-final-report/{id}/publish/',
232+
url: '/api/v2/dref-final-report/{id}/approve/',
233233
pathVariables: { id: String(id) },
234234
// FIXME: typings should be fixed in the server
235235
body: () => ({} as never),
@@ -385,7 +385,7 @@ function DrefTableActions(props: Props) {
385385

386386
const canDownloadAllocation = (applicationType === 'DREF' || applicationType === 'OPS_UPDATE');
387387

388-
const canApprove = status === DREF_STATUS_IN_PROGRESS && hasPermissionToApprove;
388+
const canApprove = status === DREF_STATUS_DRAFT && hasPermissionToApprove;
389389

390390
const shouldConfirmImminentAddOpsUpdate = drefType === DREF_TYPE_IMMINENT && isDrefImminentV2;
391391

@@ -494,7 +494,7 @@ function DrefTableActions(props: Props) {
494494
</>
495495
)}
496496
>
497-
{status === DREF_STATUS_IN_PROGRESS && applicationType === 'DREF' && (
497+
{status === DREF_STATUS_DRAFT && applicationType === 'DREF' && (
498498
<Link
499499
to="drefApplicationForm"
500500
urlParams={{ drefId: id }}
@@ -504,7 +504,7 @@ function DrefTableActions(props: Props) {
504504
{strings.dropdownActionEditLabel}
505505
</Link>
506506
)}
507-
{status === DREF_STATUS_IN_PROGRESS && applicationType === 'OPS_UPDATE' && (
507+
{status === DREF_STATUS_DRAFT && applicationType === 'OPS_UPDATE' && (
508508
<Link
509509
to="drefOperationalUpdateForm"
510510
urlParams={{ opsUpdateId: id }}
@@ -514,7 +514,7 @@ function DrefTableActions(props: Props) {
514514
{strings.dropdownActionEditLabel}
515515
</Link>
516516
)}
517-
{status === DREF_STATUS_IN_PROGRESS && applicationType === 'FINAL_REPORT' && (
517+
{status === DREF_STATUS_DRAFT && applicationType === 'FINAL_REPORT' && (
518518
<Link
519519
to={isDrefImminentV2 ? 'drefFinalReportForm' : 'oldDrefFinalReportForm'}
520520
urlParams={{ finalReportId: id }}

app/src/views/DrefApplicationForm/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import DrefExportModal from '#components/domain/DrefExportModal';
3636
import { type FieldReportItem as FieldReportSearchItem } from '#components/domain/FieldReportSearchSelectInput';
3737
import FormFailedToLoadMessage from '#components/domain/FormFailedToLoadMessage';
3838
import LanguageMismatchMessage from '#components/domain/LanguageMismatchMessage';
39-
import NonEnglishFormCreationMessage from '#components/domain/NonEnglishFormCreationMessage';
4039
import Link from '#components/Link';
4140
import NonFieldError from '#components/NonFieldError';
4241
import Page from '#components/Page';
@@ -383,6 +382,7 @@ export function Component() {
383382
method: 'PATCH',
384383
pathVariables: isDefined(drefId) ? { id: drefId } : undefined,
385384
body: (formFields: DrefRequestBody) => formFields,
385+
useCurrentLanguageForMutation: true,
386386
onSuccess: (response) => {
387387
alert.show(
388388
strings.formSaveRequestSuccessMessage,
@@ -479,6 +479,7 @@ export function Component() {
479479
url: '/api/v2/dref/',
480480
method: 'POST',
481481
body: (formFields: DrefRequestPostBody) => formFields,
482+
useCurrentLanguageForMutation: true,
482483
onSuccess: (response) => {
483484
alert.show(
484485
strings.formSaveRequestSuccessMessage,

app/src/views/DrefFinalReportForm/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ export function Component() {
305305
method: 'PATCH',
306306
pathVariables: isDefined(finalReportId) ? { id: finalReportId } : undefined,
307307
body: (formFields: FinalReportRequestBody) => formFields,
308+
useCurrentLanguageForMutation: true,
308309
onSuccess: (response) => {
309310
alert.show(
310311
strings.formSaveRequestSuccessMessage,

app/src/views/DrefOperationalUpdateForm/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import NonFieldError from '#components/NonFieldError';
4343
import Page from '#components/Page';
4444
import useCurrentLanguage from '#hooks/domain/useCurrentLanguage';
4545
import useAlert from '#hooks/useAlert';
46+
import { DREF_STATUS_APPROVED } from '#utils/constants';
4647
import {
4748
type GoApiResponse,
4849
useLazyRequest,
@@ -313,7 +314,7 @@ export function Component() {
313314
const prevOperationalUpdateId = useMemo(() => {
314315
const currentOpsUpdate = drefResponse
315316
?.operational_update_details
316-
?.find((ou) => !ou.is_published);
317+
?.find((ou) => !(ou.status === DREF_STATUS_APPROVED));
317318

318319
if (isNotDefined(currentOpsUpdate)) {
319320
return undefined;
@@ -344,6 +345,7 @@ export function Component() {
344345
} = useLazyRequest({
345346
url: '/api/v2/dref-op-update/{id}/',
346347
method: 'PATCH',
348+
useCurrentLanguageForMutation: true,
347349
pathVariables: isDefined(opsUpdateId) ? { id: opsUpdateId } : undefined,
348350
body: (formFields: OpsUpdateRequestBody) => formFields,
349351
onSuccess: (response) => {

0 commit comments

Comments
 (0)