fix: address code review issues from Task 3 (unused import, dead code, DrawerFooter layout)

This commit is contained in:
2026-05-24 22:32:30 -04:00
parent 260b77ee10
commit 77dcb98c25
2 changed files with 12 additions and 52 deletions

View File

@@ -26,7 +26,6 @@ import {
validateEventFormValues,
} from "@/lib/event-form";
import { parseRecurrenceRule, validateRecurrence } from "@/lib/recurrence";
import { cn } from "@/lib/utils";
interface EventDialogProps {
open: boolean;
@@ -63,7 +62,6 @@ export const EventDialog = ({
register,
reset,
setError,
setValue,
watch,
formState: { errors },
} = useForm<EventFormValues>({
@@ -85,25 +83,6 @@ export const EventDialog = ({
onOpenChange(nextOpen);
};
const DURATIONS = [
{ label: "+15 min", minutes: 15 },
{ label: "+30 min", minutes: 30 },
{ label: "+1 hour", minutes: 60 },
{ label: "+3 hours", minutes: 180 },
];
const handleApplyDuration = (minutes: number, currentAllDay: boolean, currentStart: string) => {
if (!currentStart) return;
const base = parseISO(currentStart);
if (!isValid(base)) return;
const next = minutes < 60 ? addMinutes(base, minutes) : addHours(base, minutes / 60);
const pad = (value: number) => String(value).padStart(2, "0");
const result = currentAllDay
? `${next.getFullYear()}-${pad(next.getMonth() + 1)}-${pad(next.getDate())}`
: `${next.getFullYear()}-${pad(next.getMonth() + 1)}-${pad(next.getDate())}T${pad(next.getHours())}:${pad(next.getMinutes())}:00`;
setValue("end", result, { shouldDirty: true });
};
const onSubmit = handleSubmit((values) => {
const result = validateEventFormValues(values);
if (!result.success) {
@@ -146,6 +125,7 @@ export const EventDialog = ({
</DialogHeader>
<form className="grid gap-6 px-6 py-5" onSubmit={onSubmit}>
{/* TODO(Task 4): replace this inline banner with <AiDraftBanner /> */}
{isAiDraft && (
<div className="rounded-md border border-primary/20 bg-primary/5 px-3 py-2 text-xs leading-relaxed text-primary">
This draft was generated from natural language. Double-check dates, times, location,
@@ -232,29 +212,6 @@ export const EventDialog = ({
/>
)}
/>
{!allDay && (
<Controller
name="end"
control={control}
render={() => (
<div className="flex gap-1 pl-0.5">
{DURATIONS.map(({ label, minutes }) => (
<Button
key={label}
type="button"
variant="ghost"
size="sm"
disabled={!start}
onClick={() => handleApplyDuration(minutes, allDay, start)}
className="px-2 py-1 text-xs text-muted-foreground"
>
{label}
</Button>
))}
</div>
)}
/>
)}
<Controller
name="end"
control={control}

View File

@@ -1,6 +1,6 @@
"use client";
import * as React from "react";
import type * as React from "react";
import { Drawer as DrawerPrimitive } from "vaul";
import { cn } from "@/lib/utils";
@@ -81,7 +81,10 @@ function DrawerFooter({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="drawer-footer"
className={cn("mt-auto flex flex-col gap-2 p-4", className)}
className={cn(
"sticky bottom-0 grid grid-cols-[0.8fr_1.2fr] gap-3 bg-gradient-to-t from-card via-card/95 to-transparent px-4 pb-6 pt-4",
className,
)}
{...props}
/>
);
@@ -112,13 +115,13 @@ function DrawerDescription({
export {
Drawer,
DrawerPortal,
DrawerOverlay,
DrawerTrigger,
DrawerClose,
DrawerContent,
DrawerHeader,
DrawerFooter,
DrawerTitle,
DrawerDescription,
DrawerFooter,
DrawerHeader,
DrawerOverlay,
DrawerPortal,
DrawerTitle,
DrawerTrigger,
};