Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/ohcnetwork/care_fe into …
Browse files Browse the repository at this point in the history
…dual-valueset-field-medication
  • Loading branch information
amjithtitus09 committed Jan 17, 2025
2 parents ed02dd6 + c5c52b6 commit 4785ba0
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 33 deletions.
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"clsx": "^2.1.1",
"cmdk": "^1.0.4",
"cross-env": "^7.0.3",
"cypress": "^13.17.0",
"cypress": "^14.0.0",
"date-fns": "^3.6.0",
"dayjs": "^1.11.13",
"echarts": "^5.5.1",
Expand Down
1 change: 1 addition & 0 deletions public/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,7 @@
"error_fetching_slots_data": "Error while fetching slots data",
"error_fetching_user_data": "Error while fetching user data",
"error_fetching_user_details": "Error while fetching user details: ",
"error_loading_questionnaire_response": "Error loading questionnaire response",
"error_sending_otp": "Error while sending OTP, Please try again later",
"error_updating_encounter": "Error to Updating Encounter",
"error_verifying_otp": "Error while verifying OTP, Please request a new OTP",
Expand Down
10 changes: 7 additions & 3 deletions src/components/ErrorPages/DefaultErrorPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { useEffect } from "react";
import { useTranslation } from "react-i18next";
import { toast } from "sonner";

import useAppHistory from "@/hooks/useAppHistory";

import { Button } from "../ui/button";

type ErrorType = "PAGE_NOT_FOUND" | "PAGE_LOAD_ERROR" | "CUSTOM_ERROR";
Expand All @@ -18,6 +20,7 @@ export default function ErrorPage({
...props
}: ErrorPageProps) {
const { t } = useTranslation();
const { goBack } = useAppHistory();

useEffect(() => {
toast.dismiss();
Expand Down Expand Up @@ -56,10 +59,11 @@ export default function ErrorPage({
<br />
<br />
<Button
onClick={() =>
onClick={() => {
// Refresh the Page
window.location.reload()
}
goBack("/");
window.location.reload();
}}
className="inline-block rounded-lg bg-primary-600 px-4 py-2 text-white hover:bg-primary-700 hover:text-white"
>
{t("return_to_care")}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useQuery } from "@tanstack/react-query";
import { useTranslation } from "react-i18next";

import CareIcon from "@/CAREUI/icons/CareIcon";
Expand All @@ -9,28 +10,27 @@ import { Skeleton } from "@/components/ui/skeleton";
import Page from "@/components/Common/Page";

import routes from "@/Utils/request/api";
import useQuery from "@/Utils/request/useQuery";
import query from "@/Utils/request/query";
import { formatDateTime } from "@/Utils/utils";
import { QuestionnaireResponse as Response } from "@/types/questionnaire/form";
import { Question } from "@/types/questionnaire/question";

export default function QuestionnaireResponseView({
responseId,

patientId,
}: {
responseId: string;
patientId: string;
}) {
const { t } = useTranslation();
const { data: formResponse, loading } = useQuery(
routes.getQuestionnaireResponse,
{
const { data: formResponse, isLoading } = useQuery({
queryKey: ["getQuestionnaireResponse", patientId, responseId],
queryFn: query(routes.getQuestionnaireResponse, {
pathParams: { patientId, responseId },
},
);
}),
});

if (loading) {
if (isLoading) {
return (
<div className="flex h-full items-center justify-center">
<Skeleton className="h-8 w-64" />
Expand Down
15 changes: 9 additions & 6 deletions src/components/Questionnaire/QuestionnaireEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DragDropContext, Draggable, Droppable } from "@hello-pangea/dnd";
import { useMutation } from "@tanstack/react-query";
import { useMutation, useQuery } from "@tanstack/react-query";
import { useNavigate } from "raviger";
import { useEffect, useState } from "react";
import { toast } from "sonner";
Expand Down Expand Up @@ -29,7 +29,7 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { Textarea } from "@/components/ui/textarea";

import mutate from "@/Utils/request/mutate";
import useQuery from "@/Utils/request/useQuery";
import query from "@/Utils/request/query";
import {
AnswerOption,
EnableWhen,
Expand Down Expand Up @@ -60,10 +60,13 @@ export default function QuestionnaireEditor({ id }: QuestionnaireEditorProps) {

const {
data: initialQuestionnaire,
loading,
isLoading,
error,
} = useQuery(questionnaireApi.detail, {
pathParams: { id },
} = useQuery({
queryKey: ["questionnaireDetail", id],
queryFn: query(questionnaireApi.detail, {
pathParams: { id },
}),
});

const { mutate: updateQuestionnaire, isPending } = useMutation({
Expand All @@ -87,7 +90,7 @@ export default function QuestionnaireEditor({ id }: QuestionnaireEditorProps) {
}
}, [initialQuestionnaire]);

if (loading) return <Loading />;
if (isLoading) return <Loading />;
if (error) {
return (
<Alert variant="destructive">
Expand Down
15 changes: 9 additions & 6 deletions src/components/Questionnaire/QuestionnaireForm.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMutation } from "@tanstack/react-query";
import { useMutation, useQuery } from "@tanstack/react-query";
import { t } from "i18next";
import { useNavigationPrompt } from "raviger";
import { useEffect, useState } from "react";
Expand All @@ -16,7 +16,7 @@ import Loading from "@/components/Common/Loading";
import { PLUGIN_Component } from "@/PluginEngine";
import routes from "@/Utils/request/api";
import mutate from "@/Utils/request/mutate";
import useQuery from "@/Utils/request/useQuery";
import query from "@/Utils/request/query";
import {
DetailedValidationError,
QuestionValidationError,
Expand Down Expand Up @@ -74,11 +74,14 @@ export function QuestionnaireForm({

const {
data: questionnaireData,
loading: isQuestionnaireLoading,
isLoading: isQuestionnaireLoading,
error: questionnaireError,
} = useQuery(questionnaireApi.detail, {
pathParams: { id: questionnaireSlug ?? "" },
prefetch: !!questionnaireSlug && !FIXED_QUESTIONNAIRES[questionnaireSlug],
} = useQuery({
queryKey: ["questionnaireDetail", questionnaireSlug],
queryFn: query(questionnaireApi.detail, {
pathParams: { id: questionnaireSlug ?? "" },
}),
enabled: !!questionnaireSlug && !FIXED_QUESTIONNAIRES[questionnaireSlug],
});

const { mutate: submitBatch, isPending } = useMutation({
Expand Down
10 changes: 7 additions & 3 deletions src/components/Questionnaire/index.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import { useQuery } from "@tanstack/react-query";
import { useNavigate } from "raviger";

import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";

import useQuery from "@/Utils/request/useQuery";
import query from "@/Utils/request/query";
import { QuestionnaireDetail } from "@/types/questionnaire/questionnaire";
import questionnaireApi from "@/types/questionnaire/questionnaireApi";

import Loading from "../Common/Loading";

export function QuestionnaireList() {
const navigate = useNavigate();
const { data: response, loading } = useQuery(questionnaireApi.list);
const { data: response, isLoading } = useQuery({
queryKey: ["questionnaires"],
queryFn: query(questionnaireApi.list),
});

if (loading) {
if (isLoading) {
return <Loading />;
}

Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useQuestionnaireOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const DEFAULT_OPTIONS: EditQuestionnaireOption[] = [

export default function useQuestionnaireOptions(slug: string) {
const { data } = useQuery({
queryKey: ["questionnaire", slug] as const,
queryKey: ["questionnaires", slug] as const,
queryFn: query(questionnaireApi.list, {
queryParams: {
tag_slug: slug,
Expand Down

0 comments on commit 4785ba0

Please sign in to comment.