Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cancel button in update encounter form #9772

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions public/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1472,6 +1472,9 @@
"quantity_approved": "Quantity Approved",
"quantity_requested": "Quantity Requested",
"quantity_required": "Quantity Required",
"questionnaire": "Questionnaire",
"questionnaire_error_loading": "Error loading questionnaire",
"questionnaire_not_exist": "The questionnaire you tried to access does not exist.",
"raise_consent_request": "Raise a consent request to fetch patient records over ABDM",
"ration_card__APL": "APL",
"ration_card__BPL": "BPL",
Expand Down
7 changes: 6 additions & 1 deletion src/components/Patient/EncounterQuestionnaire.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { t } from "i18next";
import { navigate } from "raviger";

import { Card, CardContent } from "@/components/ui/card";

import Page from "@/components/Common/Page";
import { QuestionnaireForm } from "@/components/Questionnaire/QuestionnaireForm";

import useAppHistory from "@/hooks/useAppHistory";

interface Props {
facilityId: string;
patientId: string;
Expand All @@ -20,9 +23,10 @@ export default function EncounterQuestionnaire({
questionnaireSlug,
subjectType,
}: Props) {
const { goBack } = useAppHistory();
return (
<Page
title="Questionnaire"
title={t("questionnaire")}
backUrl={`/facility/${facilityId}/patient/${patientId}/encounter/${encounterId}`}
>
<Card className="mt-2">
Expand All @@ -42,6 +46,7 @@ export default function EncounterQuestionnaire({
navigate(`/patient/${patientId}/updates`);
}
}}
onCancel={() => goBack()}
/>
</CardContent>
</Card>
Expand Down
14 changes: 6 additions & 8 deletions src/components/Questionnaire/QuestionnaireForm.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { t } from "i18next";
import { useEffect, useState } from "react";
import { toast } from "sonner";

Expand Down Expand Up @@ -104,13 +105,10 @@ export function QuestionnaireForm({
}

if (questionnaireError) {
console.log(questionnaireError);
return (
<Alert variant="destructive" className="m-4">
<AlertTitle>Error loading questionnaire</AlertTitle>
<AlertDescription>
The questionnaire you tried to access does not exist.
</AlertDescription>
<AlertTitle>{t("questionnaire_error_loading")}</AlertTitle>
<AlertDescription>{t("questionnaire_not_exist")}</AlertDescription>
</Alert>
);
}
Expand Down Expand Up @@ -406,7 +404,7 @@ export function QuestionnaireForm({
onClick={onCancel}
disabled={isProcessing}
>
Cancel
{t("cancel")}
</Button>
<Button
type="button"
Expand All @@ -416,13 +414,13 @@ export function QuestionnaireForm({
>
{isProcessing ? (
<>
<span className="opacity-0">Submit</span>
<span className="opacity-0">{t("submit")}</span>
<div className="absolute inset-0 flex items-center justify-center">
<div className="h-5 w-5 animate-spin rounded-full border-b-2 border-white" />
</div>
</>
) : (
"Submit"
t("submit")
)}
</Button>
</div>
Expand Down
Loading