Skip to content

Commit

Permalink
add type to useQueryParams
Browse files Browse the repository at this point in the history
  • Loading branch information
rajku-dev committed Feb 3, 2025
1 parent 865aa8f commit e205f00
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ export default function QuestionnaireResponsesList({
patientId,
}: Props) {
const { t } = useTranslation();
const [qParams, setQueryParams] = useQueryParams();
const [qParams, setQueryParams] = useQueryParams<{ page?: number }>();

const { data: questionnarieResponses, isLoading } = useQuery({
queryKey: ["questionnaireResponses", patientId, qParams],
Expand Down Expand Up @@ -327,7 +327,7 @@ export default function QuestionnaireResponsesList({
)}
>
<PaginationComponent
cPage={qParams.page}
cPage={qParams.page ?? 1}
defaultPerPage={15}
data={{ totalCount: questionnarieResponses?.count ?? 0 }}
onChange={(page) => setQueryParams({ page })}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Patient/PatientDetailsTab/EncounterHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const EncounterHistory = (props: PatientProps) => {

const { t } = useTranslation();

const [qParams, setQueryParams] = useQueryParams();
const [qParams, setQueryParams] = useQueryParams<{ page?: number }>();

const { data: encounterData, isLoading } = useQuery({
queryKey: ["encounterHistory", patientId, qParams],
Expand Down Expand Up @@ -83,7 +83,7 @@ const EncounterHistory = (props: PatientProps) => {
)}
>
<PaginationComponent
cPage={qParams.page}
cPage={qParams.page ?? 1}
defaultPerPage={5}
data={{ totalCount: encounterData?.count ?? 0 }}
onChange={(page) => setQueryParams({ page })}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Patient/PatientDetailsTab/patientUpdates.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const Updates = (props: PatientProps) => {
const { facilityId, patientId } = props;
const { t } = useTranslation();

const [qParams, setQueryParams] = useQueryParams();
const [qParams, setQueryParams] = useQueryParams<{ page?: number }>();

const { data: patientUpdatesData, isLoading } = useQuery({
queryKey: ["patientUpdates", patientId, qParams],
Expand Down Expand Up @@ -117,7 +117,7 @@ export const Updates = (props: PatientProps) => {
)}
>
<PaginationComponent
cPage={qParams.page}
cPage={qParams.page ?? 1}
defaultPerPage={7}
data={{ totalCount: patientUpdatesData?.count ?? 0 }}
onChange={(page) => setQueryParams({ page })}
Expand Down
6 changes: 3 additions & 3 deletions src/components/Resource/ResourceCommentSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const CommentSection = (props: { id: string }) => {
const [commentBox, setCommentBox] = useState("");
const queryClient = useQueryClient();

const [qParams, setQueryParams] = useQueryParams();
const [qParams, setQueryParams] = useQueryParams<{ page?: number }>();

const { data: resourceComments, isLoading } = useQuery({
queryKey: ["resourceComments", id, qParams],
Expand All @@ -43,7 +43,7 @@ const CommentSection = (props: { id: string }) => {
}),
onSuccess: () => {
toast.success(t("comment_added_successfully"));
queryClient.invalidateQueries({ queryKey: ["resourceComments"] });
queryClient.invalidateQueries({ queryKey: ["resourceComments", id] });
},
});

Expand Down Expand Up @@ -104,7 +104,7 @@ const CommentSection = (props: { id: string }) => {
)}
>
<PaginationComponent
cPage={qParams.page}
cPage={qParams.page ?? 1}
defaultPerPage={15}
data={{ totalCount: resourceComments?.count ?? 0 }}
onChange={(page) => setQueryParams({ page })}
Expand Down

0 comments on commit e205f00

Please sign in to comment.