coronasafe/care_fe

View on GitHub
src/pages/Scheduling/components/EditScheduleTemplateSheet.tsx

Summary

Maintainability
F
1 wk
Test Coverage

Showing 24 of 24 total issues

File EditScheduleTemplateSheet.tsx has 922 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { zodResolver } from "@hookform/resolvers/zod";
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { isBefore, parse } from "date-fns";
import { Loader2, SaveIcon, Trash2Icon } from "lucide-react";
import { useState } from "react";
Severity: Major
Found in src/pages/Scheduling/components/EditScheduleTemplateSheet.tsx - About 2 days to fix

Function NewAvailabilityCard has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

const NewAvailabilityCard = ({
scheduleId,
facilityId,
userId,
}: {
Severity: Minor
Found in src/pages/Scheduling/components/EditScheduleTemplateSheet.tsx - About 1 hr to fix

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

const AvailabilityEditor = ({
availability,
scheduleId,
facilityId,
userId,
Severity: Minor
Found in src/pages/Scheduling/components/EditScheduleTemplateSheet.tsx - About 25 mins to fix

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

<div className="grid md:grid-cols-2 gap-4">
<FormField
control={form.control}
name="valid_from"
render={({ field }) => (
src/pages/Scheduling/components/CreateScheduleTemplateSheet.tsx on lines 306..336

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

<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>{t("are_you_sure")}</AlertDialogTitle>
<AlertDialogDescription>
<Alert variant="destructive" className="mt-4">
src/pages/Scheduling/ScheduleExceptions.tsx on lines 155..187
src/pages/Scheduling/components/EditScheduleTemplateSheet.tsx on lines 437..469

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

<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>{t("are_you_sure")}</AlertDialogTitle>
<AlertDialogDescription>
<Alert variant="destructive" className="mt-4">
src/pages/Scheduling/ScheduleExceptions.tsx on lines 155..187
src/pages/Scheduling/components/EditScheduleTemplateSheet.tsx on lines 295..329

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

<FormField
control={form.control}
name="start_time"
render={({ field }) => (
<FormItem className="flex flex-col w-full">
src/pages/Scheduling/components/EditScheduleTemplateSheet.tsx on lines 801..820

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

<FormField
control={form.control}
name="end_time"
render={({ field }) => (
<FormItem className="flex flex-col w-full mt-2">
src/pages/Scheduling/components/EditScheduleTemplateSheet.tsx on lines 780..799

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

<FormField
control={form.control}
name="name"
render={({ field }) => (
<FormItem>
src/pages/Scheduling/components/CreateScheduleTemplateSheet.tsx on lines 287..304

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

render={({ field }) => (
<FormItem>
<FormLabel>{t("remarks")}</FormLabel>
<FormControl>
<Textarea
src/pages/Scheduling/components/CreateScheduleTemplateSheet.tsx on lines 648..660

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

<FormControl>
<Input
type="number"
min={0}
placeholder="e.g. 1"
src/pages/Scheduling/components/CreateScheduleTemplateSheet.tsx on lines 620..631

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

return (
<Callout variant="alert" badge="Info">
<Trans
i18nKey="schedule_slots_allocation_callout"
values={{
src/pages/Scheduling/components/CreateScheduleTemplateSheet.tsx on lines 237..247

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

const formSchema = z
.object({
name: z.string().min(1, t("field_required")),
slot_type: z.enum(["appointment", "open", "closed"]),
start_time: z
src/pages/Scheduling/components/CreateScheduleTemplateSheet.tsx on lines 96..146

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

<div className="flex items-center gap-3">
<CareIcon icon="l-clock" className="text-lg text-blue-600" />
<span className="font-semibold">{t("new_session")}</span>
</div>
src/components/Common/Drawings/DrawingTab.tsx on lines 106..109
src/pages/PublicAppointments/PatientRegistration.tsx on lines 301..304

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

<SheetHeader>
<SheetTitle>{t("edit_schedule_template")}</SheetTitle>
<SheetDescription className="sr-only">
{t("edit_schedule_template")}
</SheetDescription>
src/pages/Scheduling/components/CreateScheduleTemplateSheet.tsx on lines 277..282

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

onSuccess: () => {
toast.success(t("template_deleted"));
queryClient.invalidateQueries({
queryKey: ["user-schedule-templates", { facilityId, userId }],
});
src/pages/Scheduling/components/EditScheduleTemplateSheet.tsx on lines 370..375

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

onSuccess: () => {
toast.success(t("schedule_availability_deleted_successfully"));
queryClient.invalidateQueries({
queryKey: ["user-schedule-templates", { facilityId, userId }],
});
src/pages/Scheduling/components/EditScheduleTemplateSheet.tsx on lines 206..211

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

weekdays: z
.array(z.number() as unknown as z.ZodType<DayOfWeek>)
.min(1, t("schedule_weekdays_min_error")),
Severity: Minor
Found in src/pages/Scheduling/components/EditScheduleTemplateSheet.tsx and 1 other location - About 55 mins to fix
src/pages/Scheduling/components/CreateScheduleTemplateSheet.tsx on lines 91..93

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

<Button variant="primary" type="submit" disabled={isPending}>
{isPending ? t("creating") : t("create")}
</Button>
Severity: Minor
Found in src/pages/Scheduling/components/EditScheduleTemplateSheet.tsx and 2 other locations - About 35 mins to fix
src/components/Consent/LinkConsentDialog.tsx on lines 454..456
src/pages/Scheduling/components/CreateScheduleTemplateSheet.tsx on lines 704..706

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

const slots = Math.floor(
getSlotsPerSession(
availability.availability[0].start_time,
availability.availability[0].end_time,
availability.slot_size_in_minutes,
Severity: Minor
Found in src/pages/Scheduling/components/EditScheduleTemplateSheet.tsx and 1 other location - About 35 mins to fix
src/pages/Scheduling/ScheduleTemplates.tsx on lines 128..134

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

const ScheduleTemplateEditor = ({
template,
facilityId,
userId,
}: {
Severity: Minor
Found in src/pages/Scheduling/components/EditScheduleTemplateSheet.tsx and 1 other location - About 35 mins to fix
src/pages/Scheduling/ScheduleTemplates.tsx on lines 61..165

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

start_time: z
.string()
.min(1, t("field_required")) as unknown as z.ZodType<Time>,
Severity: Major
Found in src/pages/Scheduling/components/EditScheduleTemplateSheet.tsx and 7 other locations - About 30 mins to fix
src/pages/Scheduling/components/CreateScheduleExceptionSheet.tsx on lines 69..71
src/pages/Scheduling/components/CreateScheduleExceptionSheet.tsx on lines 72..74
src/pages/Scheduling/components/CreateScheduleTemplateSheet.tsx on lines 103..105
src/pages/Scheduling/components/CreateScheduleTemplateSheet.tsx on lines 106..108
src/pages/Scheduling/components/CreateScheduleTemplateSheet.tsx on lines 125..127
src/pages/Scheduling/components/CreateScheduleTemplateSheet.tsx on lines 128..130
src/pages/Scheduling/components/EditScheduleTemplateSheet.tsx on lines 577..579

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

end_time: z
.string()
.min(1, t("field_required")) as unknown as z.ZodType<Time>,
Severity: Major
Found in src/pages/Scheduling/components/EditScheduleTemplateSheet.tsx and 7 other locations - About 30 mins to fix
src/pages/Scheduling/components/CreateScheduleExceptionSheet.tsx on lines 69..71
src/pages/Scheduling/components/CreateScheduleExceptionSheet.tsx on lines 72..74
src/pages/Scheduling/components/CreateScheduleTemplateSheet.tsx on lines 103..105
src/pages/Scheduling/components/CreateScheduleTemplateSheet.tsx on lines 106..108
src/pages/Scheduling/components/CreateScheduleTemplateSheet.tsx on lines 125..127
src/pages/Scheduling/components/CreateScheduleTemplateSheet.tsx on lines 128..130
src/pages/Scheduling/components/EditScheduleTemplateSheet.tsx on lines 574..576

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

availability: values.weekdays.map((day) => ({
day_of_week: day,
start_time: values.start_time,
end_time: values.end_time,
})),
Severity: Minor
Found in src/pages/Scheduling/components/EditScheduleTemplateSheet.tsx and 1 other location - About 30 mins to fix
src/pages/Scheduling/components/CreateScheduleTemplateSheet.tsx on lines 206..210

There are no issues that match your filters.

Category
Status