small bugs fixed

This commit is contained in:
2025-07-18 19:28:15 +05:30
parent 1071b80930
commit 46be622851
4 changed files with 52 additions and 23 deletions

View File

@@ -9,7 +9,12 @@ interface Props {
onClear: () => void; onClear: () => void;
} }
export const SeleniumTaskBanner = ({ status, message, show, onClear }: Props) => { export const SeleniumTaskBanner = ({
status,
message,
show,
onClear,
}: Props) => {
if (!show) return null; if (!show) return null;
const getIcon = () => { const getIcon = () => {
@@ -26,7 +31,7 @@ export const SeleniumTaskBanner = ({ status, message, show, onClear }: Props) =>
}; };
return ( return (
<div className="bg-white border border-gray-200 shadow-md rounded-lg p-3 mb-4 flex items-start justify-between"> <div className="bg-white border border-gray-200 shadow-md rounded-lg p-3 m-4 flex items-start justify-between">
<div className="flex items-start gap-3"> <div className="flex items-start gap-3">
{getIcon()} {getIcon()}
<div> <div>
@@ -34,8 +39,8 @@ export const SeleniumTaskBanner = ({ status, message, show, onClear }: Props) =>
{status === "pending" {status === "pending"
? "Selenium Task In Progress" ? "Selenium Task In Progress"
: status === "success" : status === "success"
? "Selenium Task Completed" ? "Selenium Task Completed"
: "Selenium Task Error"} : "Selenium Task Error"}
</div> </div>
<p className="text-gray-600 text-sm">{message}</p> <p className="text-gray-600 text-sm">{message}</p>
</div> </div>

View File

@@ -1,4 +1,4 @@
import { useMemo, useState } from "react"; import { useEffect, useMemo, useState } from "react";
import { import {
Table, Table,
TableBody, TableBody,
@@ -69,6 +69,8 @@ interface PatientTableProps {
allowDelete?: boolean; allowDelete?: boolean;
allowCheckbox?: boolean; allowCheckbox?: boolean;
onSelectPatient?: (patient: Patient | null) => void; onSelectPatient?: (patient: Patient | null) => void;
onPageChange?: (page: number) => void;
onSearchChange?: (searchTerm: string) => void;
} }
export function PatientTable({ export function PatientTable({
@@ -77,6 +79,8 @@ export function PatientTable({
allowDelete, allowDelete,
allowCheckbox, allowCheckbox,
onSelectPatient, onSelectPatient,
onPageChange,
onSearchChange,
}: PatientTableProps) { }: PatientTableProps) {
const { toast } = useToast(); const { toast } = useToast();
const { user } = useAuth(); const { user } = useAuth();
@@ -289,6 +293,15 @@ export function PatientTable({
} }
}; };
useEffect(() => {
if (onPageChange) onPageChange(currentPage);
}, [currentPage, onPageChange]);
useEffect(() => {
const term = debouncedSearchCriteria?.searchTerm?.trim() || "recent";
if (onSearchChange) onSearchChange(term);
}, [debouncedSearchCriteria, onSearchChange]);
const totalPages = useMemo( const totalPages = useMemo(
() => Math.ceil((patientsData?.totalCount || 0) / patientsPerPage), () => Math.ceil((patientsData?.totalCount || 0) / patientsPerPage),
[patientsData] [patientsData]

View File

@@ -47,10 +47,6 @@ export default function DocumentsPage() {
setSelectedGroupId(null); setSelectedGroupId(null);
}, [selectedPatient]); }, [selectedPatient]);
const handleSelectGroup = (groupId: number) => {
setSelectedGroupId((prev) => (prev === groupId ? null : groupId));
};
const { data: groups = [] } = useQuery({ const { data: groups = [] } = useQuery({
queryKey: ["groups", selectedPatient?.id], queryKey: ["groups", selectedPatient?.id],
enabled: !!selectedPatient, enabled: !!selectedPatient,

View File

@@ -12,11 +12,7 @@ import {
CardTitle, CardTitle,
} from "@/components/ui/card"; } from "@/components/ui/card";
import { Label } from "@/components/ui/label"; import { Label } from "@/components/ui/label";
import { import { CalendarIcon, CheckCircle, LoaderCircleIcon } from "lucide-react";
CalendarIcon,
CheckCircle,
LoaderCircleIcon,
} from "lucide-react";
import { PatientUncheckedCreateInputObjectSchema } from "@repo/db/usedSchemas"; import { PatientUncheckedCreateInputObjectSchema } from "@repo/db/usedSchemas";
import { useAuth } from "@/hooks/use-auth"; import { useAuth } from "@/hooks/use-auth";
import { useToast } from "@/hooks/use-toast"; import { useToast } from "@/hooks/use-toast";
@@ -63,6 +59,11 @@ export default function InsuranceEligibilityPage() {
(state) => state.seleniumEligibilityCheckTask (state) => state.seleniumEligibilityCheckTask
); );
const [selectedPatient, setSelectedPatient] = useState<Patient | null>(null); const [selectedPatient, setSelectedPatient] = useState<Patient | null>(null);
const [currentTablePage, setCurrentTablePage] = useState<number | null>(null);
const [currentTableSearchTerm, setCurrentTableSearchTerm] = useState<
string | null
>(null);
const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false); const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);
const toggleMobileMenu = () => { const toggleMobileMenu = () => {
setIsMobileMenuOpen(!isMobileMenuOpen); setIsMobileMenuOpen(!isMobileMenuOpen);
@@ -116,7 +117,7 @@ export default function InsuranceEligibilityPage() {
toast({ toast({
title: "Patient already exists", title: "Patient already exists",
description: msg, description: msg,
variant: "default", variant: "destructive",
}); });
} else { } else {
toast({ toast({
@@ -156,14 +157,14 @@ export default function InsuranceEligibilityPage() {
setTaskStatus({ setTaskStatus({
status: "success", status: "success",
message: message:
"Patient status is updated, and Its eligibility pdf is uploaded at Document Page.", "Patient status is updated, and its eligibility pdf is uploaded at Document Page.",
}) })
); );
toast({ toast({
title: "Selenium service notified", title: "Selenium service done.",
description: description:
"Your claim data was successfully sent to Selenium, Waitinig for its response.", "Your Patient Eligibility is fetched and updated, Kindly search through the patient.",
variant: "default", variant: "default",
}); });
} catch (error: any) { } catch (error: any) {
@@ -178,8 +179,6 @@ export default function InsuranceEligibilityPage() {
description: error.message || "An error occurred.", description: error.message || "An error occurred.",
variant: "destructive", variant: "destructive",
}); });
} finally {
setIsCheckingEligibility(false); // End loading
} }
}; };
@@ -213,11 +212,25 @@ export default function InsuranceEligibilityPage() {
setIsCheckingEligibility(true); setIsCheckingEligibility(true);
// Adding patient if same patient exists then it will skip. // Adding patient if same patient exists then it will skip.
handleAddPatient(); try {
if (!selectedPatient) {
await handleAddPatient();
}
handleSelenium(); await handleSelenium();
await queryClient.invalidateQueries({ queryKey: ["patients"] }); await queryClient.invalidateQueries({
queryKey: [
"patients",
{
page: currentTablePage ?? 1,
search: currentTableSearchTerm ?? "recent",
},
],
});
} finally {
setIsCheckingEligibility(false);
}
}; };
return ( return (
@@ -353,6 +366,8 @@ export default function InsuranceEligibilityPage() {
allowCheckbox={true} allowCheckbox={true}
allowEdit={true} allowEdit={true}
onSelectPatient={setSelectedPatient} onSelectPatient={setSelectedPatient}
onPageChange={setCurrentTablePage}
onSearchChange={setCurrentTableSearchTerm}
/> />
</CardContent> </CardContent>
</Card> </Card>