diff --git a/components/case/caseLink.tsx b/components/case/caseLink.tsx index 89b7818..79a9f09 100644 --- a/components/case/caseLink.tsx +++ b/components/case/caseLink.tsx @@ -1,17 +1,20 @@ import Link from "next/link"; import React from "react"; +import { useTranslation } from "react-i18next"; type CaseLinkProps = { caseId?: string; }; const CaseLink: React.FC = ({ caseId }) => { + const { t } = useTranslation(); + if (caseId == undefined) { return null; } return (
- Case + {t("status.case", "Case")}
); diff --git a/components/report/list.tsx b/components/report/list.tsx index 5699faf..dc3ce3e 100644 --- a/components/report/list.tsx +++ b/components/report/list.tsx @@ -187,7 +187,7 @@ const ReportList = () => { { label: "", get: record => ( -
+
diff --git a/components/report/report.tsx b/components/report/report.tsx index 3d026bb..0fe9797 100644 --- a/components/report/report.tsx +++ b/components/report/report.tsx @@ -14,6 +14,7 @@ import Spinner from "components/widgets/spinner"; import { useRouter } from "next/router"; import CaseLink from "components/case/caseLink"; import { RenderData, TR } from "components/widgets/renderData"; +import ConfirmDialog from "components/widgets/dialogs/confirmDialog"; import dynamic from "next/dynamic"; import Comments from "components/widgets/comments"; import GalleryDialog from "components/widgets/dialogs/galleryDialog"; @@ -135,14 +136,16 @@ const Report = (props: { id: string }) => { const { t } = useTranslation(); useEffect(() => { - setViewModel( - new ReportViewModel( - id as string, - services.reportService, - services.caseService, - services.outbreakService - ) + const model = new ReportViewModel( + id as string, + services.reportService, + services.caseService, + services.outbreakService ); + model.registerDialog("confirmToTest"); + model.registerDialog("confirmToPromoteToCase"); + + setViewModel(model); }, [setViewModel, id, services]); if (viewModel === undefined) { @@ -166,13 +169,13 @@ const Report = (props: { id: string }) => { { - const caseId = await viewModel.promoteToCase(); - if (caseId) router.push(`/cases/${caseId}`); - }} + onClick={() => + viewModel.dialog("confirmToPromoteToCase")?.open(null) + } > {viewModel.isLoading && } -  Promote To Case +   + {t("status.actions.promoteToCase", "Promote to case")} )} {viewModel.shouldDisplayConvertToTestReport && ( @@ -180,11 +183,15 @@ const Report = (props: { id: string }) => { disabled={viewModel.converting} type="button" onClick={async () => { - await viewModel.convertToTestReport(); + viewModel.dialog("confirmToTest")?.open(null); }} > {viewModel.converting && } -  Convert to Test Report +   + {t( + "status.actions.convertToTest", + "Convert to test report" + )} )}
@@ -230,6 +237,29 @@ const Report = (props: { id: string }) => { + viewModel.convertToTestReport()} + onNo={() => viewModel.dialog("confirmDelete")?.close()} + /> + + { + const caseId = await viewModel.promoteToCase(); + if (caseId) router.push(`/cases/${caseId}`); + }} + onNo={() => viewModel.dialog("confirmToPromoteToCase")?.close()} + /> + diff --git a/components/report/reportViewModel.ts b/components/report/reportViewModel.ts index d0e8a1f..81be05c 100644 --- a/components/report/reportViewModel.ts +++ b/components/report/reportViewModel.ts @@ -153,7 +153,7 @@ export class ReportViewModel extends BaseViewModel { } get shouldDisplayConvertToTestReport() { - return this.data.testFlag == false && this.data.caseId == null; + return this.data.testFlag == false; } get shouldDisplayPromoteToCase() { diff --git a/i18n/translations.en.json b/i18n/translations.en.json index 98b3f84..340f45f 100644 --- a/i18n/translations.en.json +++ b/i18n/translations.en.json @@ -190,7 +190,8 @@ "confirmDelete": "Confirm Delete", "confirmPublishReportType": "Publish this report to mobile application.", "confirmUnpublishReportType": "Unpublish this report from moible application.", - "confirmTransition": "Are you want to change status to {{stepName}} ?" + "confirmTransition": "Are you want to change status to {{stepName}} ?", + "confirmConvertToTest": "Would like to change this report to test report?" } }, "title": { @@ -221,5 +222,14 @@ "qr": { "login": "Login QR Code", "reportTypeFormDefinition": "Form Definition QR Code" + }, + "status": { + "case": "case", + "suspectedOutbreak": "suspected outbreak", + "outbreak": "outbreak", + "actions": { + "promoteToCase": "Promote to case", + "convertToTest": "Convert to test report" + } } } diff --git a/i18n/translations.la.json b/i18n/translations.la.json index b1dead6..d85c857 100644 --- a/i18n/translations.la.json +++ b/i18n/translations.la.json @@ -12,8 +12,8 @@ "caseDefinitions": "ຄໍານິຍາມກໍລະນີ", "stateDefinitions": "ຕັ້ງ​ສະ​ຖາ​ນະ​ພາບ​", "notificationTemplates": "ແມ່ແບບການແຈ້ງເຕືອນ", - "notifications": "ແຈ້ງການ", - "reporterNotifications": "ແຈ້ງ​ການ​ນັກ​ຂ່າວ​", + "notifications": "ແຈ້ງເຕືອນ", + "reporterNotifications": "ແຈ້ງ​ຄືນໃຫ້ອາສາ", "profile": "ໂປຣໄຟລ໌", "create": "ສ້າງ", "update": "ອັບເດດ", @@ -25,8 +25,8 @@ "contributions": "ລາຍ​ງານ​ປະ​ຫວັດ​ສາດ​", "observationDefinitions": "ຄໍາ​ນິ​ຍາມ​ການ​ສັງ​ເກດ​ການ", "observationMonitoringDefinitions": "ຄໍານິຍາມການຕິດຕາມການສັງເກດ", - "inactiveReporter": "ນັກຂ່າວທີ່ບໍ່ເຄື່ອນໄຫວ", - "reporterPerformance": "ຜົນງານຂອງນັກຂ່າວ" + "inactiveReporter": "ອາສາທີ່ບໍ່ເຄື່ອນໄຫວ", + "reporterPerformance": "ຜົນງານຂອງອາສາ" }, "filter": { "searchButton": "ປຸ່ມຊອກຫາ", @@ -191,7 +191,9 @@ "confirmDelete": "ຢືນຢັນການລຶບ ?", "confirmPublishReportType": "ທ່ານແນ່ໃຈບໍ່ວ່າຢືນຢັນການເຜີຍແຜ່ປະເພດລາຍງານ ?", "confirmUnpublishReportType": "ທ່ານແນ່ໃຈບໍ່ວ່າຢືນຢັນປະເພດລາຍງານທີ່ບໍ່ໄດ້ເຜີຍແຜ່ ?", - "confirmTransition": "ທ່ານຕ້ອງການປ່ຽນສະຖານະເປັນ {{stepName}} ?" + "confirmTransition": "ທ່ານຕ້ອງການປ່ຽນສະຖານະເປັນ {{stepName}} ?", + "confirmConvertToTest": "ທ່ານຕ້ອງການປ່ຽນສະຖານະເປັນທົດສອບ ?", + "confirmToPromoteToCase": "ທ່ານຕ້ອງການປ່ຽນສະຖານະເປັນກໍລະນີ ?" } }, "title": { @@ -230,5 +232,15 @@ "qr": { "login": "ເຂົ້າສູ່ລະບົບດ້ວຍລະຫັດ qr", "reportTypeFormDefinition": "Form Definition QR Code" + }, + "status": { + "test": "ທົດສອບ", + "case": "ກໍລະນີ", + "suspectedOutbreak": "suspected outbreak", + "outbreak": "outbreak", + "actions": { + "promoteToCase": "ປ່ຽນເປັນກໍລະນີ", + "convertToTest": "ປ່ຽນເປັນທົດສອບ" + } } }