coronasafe/care_fe

View on GitHub
src/pages/Appointments/AppointmentDetail.tsx

Summary

Maintainability
F
6 days
Test Coverage

Showing 13 of 13 total issues

File AppointmentDetail.tsx has 597 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {
CalendarIcon,
CheckCircledIcon,
ClockIcon,
DownloadIcon,
Severity: Major
Found in src/pages/Appointments/AppointmentDetail.tsx - About 1 day to fix

Function AppointmentDetail has 123 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function AppointmentDetail(props: Props) {
const { t } = useTranslation();
const queryClient = useQueryClient();
const { hasPermission } = usePermissions();
const { goBack } = useAppHistory();
Severity: Major
Found in src/pages/Appointments/AppointmentDetail.tsx - About 4 hrs to fix

Function AppointmentActions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

const AppointmentActions = ({
facilityId,
appointment,
onChange,
onViewPatient,
Severity: Minor
Found in src/pages/Appointments/AppointmentDetail.tsx - About 45 mins to fix

Function AppointmentDetail has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export default function AppointmentDetail(props: Props) {
const { t } = useTranslation();
const queryClient = useQueryClient();
const { hasPermission } = usePermissions();
const { goBack } = useAppHistory();
Severity: Minor
Found in src/pages/Appointments/AppointmentDetail.tsx - About 25 mins to fix

Similar blocks of code found in 2 locations. Consider refactoring.
Open

<AlertDialog>
<AlertDialogTrigger asChild>
<Button variant="outline" size="lg">
<BanIcon className="size-4 mr-2" />
{t("mark_as_entered_in_error")}
Severity: Major
Found in src/pages/Appointments/AppointmentDetail.tsx and 1 other location - About 1 day to fix
src/pages/Appointments/AppointmentDetail.tsx on lines 566..599

Similar blocks of code found in 2 locations. Consider refactoring.
Open

<AlertDialog>
<AlertDialogTrigger asChild>
<Button variant="outline" size="lg">
<BanIcon className="size-4 mr-2" />
{t("cancel_appointment")}
Severity: Major
Found in src/pages/Appointments/AppointmentDetail.tsx and 1 other location - About 1 day to fix
src/pages/Appointments/AppointmentDetail.tsx on lines 601..634

Similar blocks of code found in 2 locations. Consider refactoring.
Open

<Button
disabled={!isToday}
variant="outline_primary"
onClick={() => onChange("checked_in")}
size="lg"
Severity: Major
Found in src/pages/Appointments/AppointmentDetail.tsx and 1 other location - About 1 hr to fix
src/pages/Appointments/AppointmentDetail.tsx on lines 548..556

Similar blocks of code found in 2 locations. Consider refactoring.
Open

<Button
disabled={!isToday}
variant="outline_primary"
onClick={() => onChange("fulfilled")}
size="lg"
Severity: Major
Found in src/pages/Appointments/AppointmentDetail.tsx and 1 other location - About 1 hr to fix
src/pages/Appointments/AppointmentDetail.tsx on lines 521..529

Similar blocks of code found in 3 locations. Consider refactoring.
Open

<div className="text-sm">
<p className="font-medium">{t("facility")}</p>
<p className="text-gray-600">{facility.name}</p>
</div>
Severity: Major
Found in src/pages/Appointments/AppointmentDetail.tsx and 2 other locations - About 1 hr to fix
src/components/Patient/PatientDetailsTab/PatientUsers.tsx on lines 355..358
src/components/Resource/ResourceDetails.tsx on lines 38..41

Similar blocks of code found in 2 locations. Consider refactoring.
Open

const { data: facilityData, isLoading: isFacilityLoading } = useQuery({
queryKey: ["facility", props.facilityId],
queryFn: query(routes.getPermittedFacility, {
pathParams: {
id: props.facilityId,
Severity: Major
Found in src/pages/Appointments/AppointmentDetail.tsx and 1 other location - About 1 hr to fix
src/pages/Patients/VerifyPatient.tsx on lines 46..51

Similar blocks of code found in 2 locations. Consider refactoring.
Open

<a
href={`tel:${appointment.patient.phone_number}`}
className="text-primary hover:underline"
>
{formatPhoneNumberIntl(appointment.patient.phone_number)}
Severity: Major
Found in src/pages/Appointments/AppointmentDetail.tsx and 1 other location - About 1 hr to fix
src/pages/Appointments/AppointmentDetail.tsx on lines 344..351

Similar blocks of code found in 2 locations. Consider refactoring.
Open

<a
href={`tel:${appointment.patient.emergency_phone_number}`}
className="text-primary hover:underline"
>
{formatPhoneNumberIntl(
Severity: Major
Found in src/pages/Appointments/AppointmentDetail.tsx and 1 other location - About 1 hr to fix
src/pages/Appointments/AppointmentDetail.tsx on lines 334..339

Similar blocks of code found in 2 locations. Consider refactoring.
Open

onSuccess: () => {
toast.success(t("appointment_cancelled"));
queryClient.invalidateQueries({
queryKey: ["appointment", appointment.id],
});
Severity: Minor
Found in src/pages/Appointments/AppointmentDetail.tsx and 1 other location - About 40 mins to fix
src/components/Encounter/EncounterActions.tsx on lines 61..64
Category
Status