From 1eea6a43a39720cf0d0c631e44cc8c0a309ad31b Mon Sep 17 00:00:00 2001 From: Shreeyash Shrestha Date: Tue, 16 Sep 2025 11:50:22 +0545 Subject: [PATCH 1/2] feat(dref-translation): remove language mismatch bloker to edit and view dref form --- app/src/views/DrefApplicationForm/index.tsx | 13 +++++++------ app/src/views/DrefFinalReportForm/index.tsx | 4 ++-- app/src/views/DrefOperationalUpdateForm/index.tsx | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app/src/views/DrefApplicationForm/index.tsx b/app/src/views/DrefApplicationForm/index.tsx index 755dc09d2..ec6eaed8d 100644 --- a/app/src/views/DrefApplicationForm/index.tsx +++ b/app/src/views/DrefApplicationForm/index.tsx @@ -609,13 +609,14 @@ export function Component() { const disabled = fetchingDref || saveDrefPending; // New DREFs can only be created in English - const nonEnglishCreate = isNotDefined(drefId) && currentLanguage !== 'en'; + // const nonEnglishCreate = isNotDefined(drefId) && currentLanguage !== 'en'; + const languageMismatch = isDefined(drefId) && isDefined(drefResponse) && currentLanguage !== drefResponse?.translation_module_original_language; - const shouldHideForm = nonEnglishCreate - || languageMismatch - || fetchingDref + + const shouldHideForm = fetchingDref + // || nonEnglishCreate || isDefined(drefResponseError); return ( @@ -730,11 +731,11 @@ export function Component() { originalLanguage={drefResponse.translation_module_original_language} /> )} - {nonEnglishCreate && ( + {/* nonEnglishCreate && ( - )} + ) */} {isDefined(drefResponseError) && ( Date: Thu, 18 Sep 2025 16:32:06 +0545 Subject: [PATCH 2/2] feat(dref-translation): update dref status and publish api to approve --- app/src/utils/constants.ts | 3 ++- .../AccountMyFormsDref/ActiveDrefTable/index.tsx | 5 ++++- .../DrefTableActions/index.tsx | 16 ++++++++-------- app/src/views/DrefApplicationForm/index.tsx | 3 ++- app/src/views/DrefFinalReportForm/index.tsx | 1 + .../views/DrefOperationalUpdateForm/index.tsx | 4 +++- go-api | 2 +- 7 files changed, 21 insertions(+), 13 deletions(-) diff --git a/app/src/utils/constants.ts b/app/src/utils/constants.ts index 79eee5799..8075e6b3f 100644 --- a/app/src/utils/constants.ts +++ b/app/src/utils/constants.ts @@ -84,7 +84,8 @@ export const FONT_FAMILY_HEADER = 'Montserrat'; // This should not be the same as OperationType. export type DrefStatus = components<'read'>['schemas']['DrefDrefStatusEnumKey']; // const DREF_STATUS_COMPLETED = 1 satisfies DrefStatus; -export const DREF_STATUS_IN_PROGRESS = 0 satisfies DrefStatus; +export const DREF_STATUS_DRAFT = 1 satisfies DrefStatus; +export const DREF_STATUS_APPROVED = 4 satisfies DrefStatus; export type TypeOfDrefEnum = components<'read'>['schemas']['DrefDrefDrefTypeEnumKey']; export const DREF_TYPE_IMMINENT = 0 satisfies TypeOfDrefEnum; diff --git a/app/src/views/AccountMyFormsDref/ActiveDrefTable/index.tsx b/app/src/views/AccountMyFormsDref/ActiveDrefTable/index.tsx index 5e00c6747..e4bc615e0 100644 --- a/app/src/views/AccountMyFormsDref/ActiveDrefTable/index.tsx +++ b/app/src/views/AccountMyFormsDref/ActiveDrefTable/index.tsx @@ -30,6 +30,7 @@ import { import useUserMe from '#hooks/domain/useUserMe'; import useFilterState from '#hooks/useFilterState'; import { + DREF_STATUS_APPROVED, DREF_TYPE_LOAN, type TypeOfDrefEnum, } from '#utils/constants'; @@ -230,13 +231,15 @@ function ActiveDrefTable(props: Props) { const { unpublished_op_update_count, - is_published, + status, has_ops_update, has_final_report, country_details, is_dref_imminent_v2, } = originalDref; + const is_published = status === DREF_STATUS_APPROVED; + const canAddOpsUpdate = (is_published ?? false) && (applicationType === 'DREF' || applicationType === 'OPS_UPDATE') && !has_final_report diff --git a/app/src/views/AccountMyFormsDref/DrefTableActions/index.tsx b/app/src/views/AccountMyFormsDref/DrefTableActions/index.tsx index 8b16ad1f7..6e3f28989 100644 --- a/app/src/views/AccountMyFormsDref/DrefTableActions/index.tsx +++ b/app/src/views/AccountMyFormsDref/DrefTableActions/index.tsx @@ -27,7 +27,7 @@ import Link from '#components/Link'; import useAlert from '#hooks/useAlert'; import useRouting from '#hooks/useRouting'; import { - DREF_STATUS_IN_PROGRESS, + DREF_STATUS_DRAFT, DREF_TYPE_IMMINENT, DREF_TYPE_LOAN, type DrefStatus, @@ -167,7 +167,7 @@ function DrefTableActions(props: Props) { pending: publishDrefPending, } = useLazyRequest({ method: 'POST', - url: '/api/v2/dref/{id}/publish/', + url: '/api/v2/dref/{id}/approve/', pathVariables: { id: String(id) }, // FIXME: typings should be fixed in the server body: () => ({} as never), @@ -198,7 +198,7 @@ function DrefTableActions(props: Props) { pending: publishOpsUpdatePending, } = useLazyRequest({ method: 'POST', - url: '/api/v2/dref-op-update/{id}/publish/', + url: '/api/v2/dref-op-update/{id}/approve/', pathVariables: { id: String(id) }, // FIXME: typings should be fixed in the server body: () => ({} as never), @@ -229,7 +229,7 @@ function DrefTableActions(props: Props) { pending: publishFinalReportPending, } = useLazyRequest({ method: 'POST', - url: '/api/v2/dref-final-report/{id}/publish/', + url: '/api/v2/dref-final-report/{id}/approve/', pathVariables: { id: String(id) }, // FIXME: typings should be fixed in the server body: () => ({} as never), @@ -385,7 +385,7 @@ function DrefTableActions(props: Props) { const canDownloadAllocation = (applicationType === 'DREF' || applicationType === 'OPS_UPDATE'); - const canApprove = status === DREF_STATUS_IN_PROGRESS && hasPermissionToApprove; + const canApprove = status === DREF_STATUS_DRAFT && hasPermissionToApprove; const shouldConfirmImminentAddOpsUpdate = drefType === DREF_TYPE_IMMINENT && isDrefImminentV2; @@ -494,7 +494,7 @@ function DrefTableActions(props: Props) { )} > - {status === DREF_STATUS_IN_PROGRESS && applicationType === 'DREF' && ( + {status === DREF_STATUS_DRAFT && applicationType === 'DREF' && ( )} - {status === DREF_STATUS_IN_PROGRESS && applicationType === 'OPS_UPDATE' && ( + {status === DREF_STATUS_DRAFT && applicationType === 'OPS_UPDATE' && ( )} - {status === DREF_STATUS_IN_PROGRESS && applicationType === 'FINAL_REPORT' && ( + {status === DREF_STATUS_DRAFT && applicationType === 'FINAL_REPORT' && ( formFields, + useCurrentLanguageForMutation: true, onSuccess: (response) => { alert.show( strings.formSaveRequestSuccessMessage, @@ -479,6 +479,7 @@ export function Component() { url: '/api/v2/dref/', method: 'POST', body: (formFields: DrefRequestPostBody) => formFields, + useCurrentLanguageForMutation: true, onSuccess: (response) => { alert.show( strings.formSaveRequestSuccessMessage, diff --git a/app/src/views/DrefFinalReportForm/index.tsx b/app/src/views/DrefFinalReportForm/index.tsx index b863231d1..c8cdfce51 100644 --- a/app/src/views/DrefFinalReportForm/index.tsx +++ b/app/src/views/DrefFinalReportForm/index.tsx @@ -305,6 +305,7 @@ export function Component() { method: 'PATCH', pathVariables: isDefined(finalReportId) ? { id: finalReportId } : undefined, body: (formFields: FinalReportRequestBody) => formFields, + useCurrentLanguageForMutation: true, onSuccess: (response) => { alert.show( strings.formSaveRequestSuccessMessage, diff --git a/app/src/views/DrefOperationalUpdateForm/index.tsx b/app/src/views/DrefOperationalUpdateForm/index.tsx index e02b78f28..254b3ef67 100644 --- a/app/src/views/DrefOperationalUpdateForm/index.tsx +++ b/app/src/views/DrefOperationalUpdateForm/index.tsx @@ -43,6 +43,7 @@ import NonFieldError from '#components/NonFieldError'; import Page from '#components/Page'; import useCurrentLanguage from '#hooks/domain/useCurrentLanguage'; import useAlert from '#hooks/useAlert'; +import { DREF_STATUS_APPROVED } from '#utils/constants'; import { type GoApiResponse, useLazyRequest, @@ -313,7 +314,7 @@ export function Component() { const prevOperationalUpdateId = useMemo(() => { const currentOpsUpdate = drefResponse ?.operational_update_details - ?.find((ou) => !ou.is_published); + ?.find((ou) => !(ou.status === DREF_STATUS_APPROVED)); if (isNotDefined(currentOpsUpdate)) { return undefined; @@ -344,6 +345,7 @@ export function Component() { } = useLazyRequest({ url: '/api/v2/dref-op-update/{id}/', method: 'PATCH', + useCurrentLanguageForMutation: true, pathVariables: isDefined(opsUpdateId) ? { id: opsUpdateId } : undefined, body: (formFields: OpsUpdateRequestBody) => formFields, onSuccess: (response) => { diff --git a/go-api b/go-api index 0b28ce554..6745b93ae 160000 --- a/go-api +++ b/go-api @@ -1 +1 @@ -Subproject commit 0b28ce5542941c45666320b7411c4d9de6f6291a +Subproject commit 6745b93aed93aff3d57751a91d6ee94c651f8112