Skip to content

Commit 6613b6b

Browse files
committed
refactor(scheduling): update availability calendar and form layout for improved structure and functionality
- Change start script in package.json to use next dev and add start:prod for production - Enhance AvailabilityCalendar with tooltip positioning and refactor pointer position handling - Integrate Card components in AvailabilityForm for better layout and styling - Simplify form structure and improve error message display
1 parent f202acf commit 6613b6b

3 files changed

Lines changed: 40 additions & 39 deletions

File tree

components/scheduling/availability-calendar.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"use client";
22

33
import * as React from "react";
4+
import { Separator } from "@/components/ui/separator";
5+
import { Skeleton } from "@/components/ui/skeleton";
46
import { cn } from "@/lib/utils";
57
import {
68
buildCalendarRange,
@@ -268,19 +270,16 @@ export function AvailabilityCalendar({
268270

269271
if (!anchor) {
270272
return (
271-
<div
272-
className={cn(
273-
"min-h-[480px] w-full animate-pulse rounded-xl bg-muted/40",
274-
className,
275-
)}
273+
<Skeleton
274+
className={cn("min-h-[480px] w-full rounded-none", className)}
276275
aria-busy="true"
277276
aria-label="Loading availability calendar"
278277
/>
279278
);
280279
}
281280

282281
return (
283-
<div className={cn("mx-auto w-full max-w-6xl bg-card", className)}>
282+
<div className={cn("w-full", className)}>
284283
<div className="overflow-x-auto">
285284
<div
286285
style={{ minWidth: `${Math.max(720, 80 + columnCount * 56)}px` }}
@@ -365,7 +364,8 @@ export function AvailabilityCalendar({
365364

366365
{tooltip && pointerPos ? (
367366
<div
368-
className="pointer-events-none fixed z-50 rounded-md bg-foreground px-3 py-1.5 text-xs font-medium text-background shadow-lg"
367+
role="tooltip"
368+
className="pointer-events-none fixed z-50 inline-flex w-fit items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background"
369369
style={{
370370
left: pointerPos.x,
371371
top: pointerPos.y,
@@ -378,7 +378,8 @@ export function AvailabilityCalendar({
378378
</div>
379379
</div>
380380
</div>
381-
<footer className="flex flex-col gap-4 border-t border-border px-4 py-4 sm:flex-row sm:items-center sm:justify-between">
381+
<Separator />
382+
<div className="flex flex-col gap-4 px-4 py-4 sm:flex-row sm:items-center sm:justify-between">
382383
<div className="flex flex-wrap items-center gap-4 text-xs text-muted-foreground">
383384
<span className="font-semibold tracking-wider text-foreground/70">
384385
YOUR SELECTIONS:
@@ -396,7 +397,7 @@ export function AvailabilityCalendar({
396397
{slotCount} slot{slotCount === 1 ? "" : "s"} selected ·{" "}
397398
{hoursTotal.toFixed(2)} hrs total
398399
</p>
399-
</footer>
400+
</div>
400401
</div>
401402
);
402403
}

components/scheduling/availability-form.tsx

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useActionState } from "react";
55

66
import { AvailabilityCalendar } from "@/components/scheduling/availability-calendar";
77
import { MessageYourCoach } from "@/components/scheduling/message-your-coach";
8+
import { Card, CardContent, CardFooter } from "@/components/ui/card";
89
import { cn } from "@/lib/utils";
910
import type { TimeSlot, Weekday } from "@/lib/scheduling/time-slot";
1011
import {
@@ -47,44 +48,42 @@ export function AvailabilityForm({
4748
const errors = state?.errors;
4849

4950
return (
50-
<form
51-
action={formAction}
52-
className={cn(
53-
"mx-auto w-full max-w-6xl overflow-hidden rounded-xl border border-border bg-card shadow-sm",
54-
className,
55-
)}
56-
>
51+
<form action={formAction}>
5752
<input type="hidden" name="session_id" value={sessionId} />
5853
<input
5954
type="hidden"
6055
name="time_slots"
6156
value={JSON.stringify(slots)}
6257
/>
6358

64-
<AvailabilityCalendar
65-
weeks={weeks}
66-
daysOfWeek={daysOfWeek}
67-
startHour={startHour}
68-
endHour={endHour}
69-
anchor={anchor}
70-
value={slots}
71-
onChange={setSlots}
72-
/>
59+
<Card className={cn("mx-auto w-full max-w-6xl gap-0 py-0", className)}>
60+
<CardContent className="p-0">
61+
<AvailabilityCalendar
62+
weeks={weeks}
63+
daysOfWeek={daysOfWeek}
64+
startHour={startHour}
65+
endHour={endHour}
66+
anchor={anchor}
67+
value={slots}
68+
onChange={setSlots}
69+
/>
70+
</CardContent>
7371

74-
<div className="border-t border-border bg-accent/30 p-4">
75-
<MessageYourCoach
76-
name="notes"
77-
value={coachMessage}
78-
onChange={setCoachMessage}
79-
pending={pending}
80-
/>
72+
<CardFooter className="flex-col items-stretch gap-2">
73+
<MessageYourCoach
74+
name="notes"
75+
value={coachMessage}
76+
onChange={setCoachMessage}
77+
pending={pending}
78+
/>
8179

82-
<FormErrors errors={errors} />
80+
<FormErrors errors={errors} />
8381

84-
{state?.message && !errors ? (
85-
<p className="mt-2 text-sm text-primary">{state.message}</p>
86-
) : null}
87-
</div>
82+
{state?.message && !errors ? (
83+
<p className="text-sm text-primary">{state.message}</p>
84+
) : null}
85+
</CardFooter>
86+
</Card>
8887
</form>
8988
);
9089
}
@@ -94,7 +93,7 @@ function FormErrors({ errors }: { errors?: Record<string, string[]> }) {
9493
const messages = Object.values(errors).flat();
9594
if (messages.length === 0) return null;
9695
return (
97-
<ul className="mt-2 flex flex-col gap-0.5 text-sm text-destructive">
96+
<ul className="flex flex-col gap-0.5 text-sm text-destructive">
9897
{messages.map((m, i) => (
9998
<li key={i}>{m}</li>
10099
))}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"scripts": {
77
"dev": "next dev",
88
"build": "next build",
9-
"start": "next start",
9+
"start": "next dev",
10+
"start:prod": "next start",
1011
"lint": "eslint",
1112
"db:push": "drizzle-kit push",
1213
"db:generate": "drizzle-kit generate",

0 commit comments

Comments
 (0)