coronasafe/care_fe

View on GitHub
src/pages/PublicAppointments/Schedule.tsx

Summary

Maintainability
D
3 days
Test Coverage

Showing 6 of 6 total issues

Function ScheduleAppointment has 286 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function ScheduleAppointment(props: AppointmentsProps) {
const { t } = useTranslation();
const { goBack } = useAppHistory();
const { facilityId, staffId, appointmentId } = props;
const [selectedMonth, setSelectedMonth] = useState(new Date());
Severity: Major
Found in src/pages/PublicAppointments/Schedule.tsx - About 1 day to fix

File Schedule.tsx has 324 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { isWithinInterval } from "date-fns";
import { Loader2 } from "lucide-react";
import { navigate } from "raviger";
import { useEffect, useState } from "react";
Severity: Minor
Found in src/pages/PublicAppointments/Schedule.tsx - About 3 hrs to fix

Function ScheduleAppointment has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

export function ScheduleAppointment(props: AppointmentsProps) {
const { t } = useTranslation();
const { goBack } = useAppHistory();
const { facilityId, staffId, appointmentId } = props;
const [selectedMonth, setSelectedMonth] = useState(new Date());
Severity: Minor
Found in src/pages/PublicAppointments/Schedule.tsx - About 2 hrs to fix

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

onSuccess: (data: Appointment) => {
toast.success(t("appointment_created_success"));
queryClient.invalidateQueries({
queryKey: [
["patients", tokenData.phoneNumber],
Severity: Major
Found in src/pages/PublicAppointments/Schedule.tsx and 1 other location - About 3 hrs to fix
src/pages/PublicAppointments/PatientSelect.tsx on lines 160..171

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

<div>
<Label className="mb-2">{t("reason_for_visit")}</Label>
<Textarea
placeholder={t("reason_for_visit_placeholder")}
value={reason}
Severity: Major
Found in src/pages/PublicAppointments/Schedule.tsx and 1 other location - About 2 hrs to fix
src/pages/Appointments/BookAppointment.tsx on lines 105..112

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

if (!staffId) {
toast.error(t("staff_username_not_found"));
navigate(`/facility/${facilityId}/`);
} else if (!tokenData) {
toast.error(t("phone_number_not_found"));
Severity: Minor
Found in src/pages/PublicAppointments/Schedule.tsx and 1 other location - About 30 mins to fix
src/pages/PublicAppointments/PatientSelect.tsx on lines 130..138

There are no issues that match your filters.

Category
Status