11"use client" ;
22
3- import React from "react" ;
3+ import React , { useState } from "react" ;
44import { format } from "date-fns" ;
55import { Card , CardHeader } from "@/components/ui/card" ;
66import { Button } from "@/components/ui/button" ;
77import Link from "next/link" ;
88import { useCoachingSessionStateStore } from "@/lib/providers/coaching-session-state-store-provider" ;
99import { useOverarchingGoalBySession } from "@/lib/api/overarching-goals" ;
1010import { Id } from "@/types/general" ;
11+ import {
12+ DropdownMenu ,
13+ DropdownMenuContent ,
14+ DropdownMenuItem ,
15+ DropdownMenuTrigger ,
16+ } from "@/components/ui/dropdown-menu" ;
17+ import { MoreHorizontal } from "lucide-react" ;
18+ import { CoachingSessionDialog } from "@/components/ui/dashboard/coaching-session-dialog" ;
19+ import { DateTime } from "ts-luxon" ;
1120
1221interface CoachingSessionProps {
1322 coachingSession : {
1423 id : Id ;
1524 date : string ;
25+ coaching_relationship_id : Id ;
26+ created_at : DateTime ;
27+ updated_at : DateTime ;
1628 } ;
1729}
1830
@@ -22,29 +34,58 @@ const CoachingSession: React.FC<CoachingSessionProps> = ({
2234 const { setCurrentCoachingSessionId } = useCoachingSessionStateStore (
2335 ( state ) => state
2436 ) ;
37+ const [ updateDialogOpen , setUpdateDialogOpen ] = useState ( false ) ;
2538
2639 return (
27- < Card >
28- < CardHeader className = "p-4" >
29- < div className = "flex flex-col sm:flex-row sm:items-center justify-between gap-2" >
30- < div className = "space-y-1" >
31- < OverarchingGoal coachingSessionId = { coachingSession . id } />
32- < div className = "text-sm text-muted-foreground" >
33- { format ( new Date ( coachingSession . date ) , "MMMM d, yyyy h:mm a" ) }
40+ < >
41+ < Card >
42+ < CardHeader className = "p-4" >
43+ < div className = "flex flex-col sm:flex-row sm:items-center justify-between gap-2" >
44+ < div className = "space-y-1" >
45+ < OverarchingGoal coachingSessionId = { coachingSession . id } />
46+ < div className = "text-sm text-muted-foreground" >
47+ { format ( new Date ( coachingSession . date ) , "MMMM d, yyyy h:mm a" ) }
48+ </ div >
3449 </ div >
50+ < DropdownMenu >
51+ < DropdownMenuTrigger asChild >
52+ < Button variant = "ghost" size = "icon" >
53+ < MoreHorizontal className = "h-4 w-4" />
54+ </ Button >
55+ </ DropdownMenuTrigger >
56+ < DropdownMenuContent align = "end" >
57+ < DropdownMenuItem asChild >
58+ < Link
59+ href = { `/coaching-sessions/${ coachingSession . id } ` }
60+ onClick = { ( ) =>
61+ setCurrentCoachingSessionId ( coachingSession . id )
62+ }
63+ >
64+ Join Session
65+ </ Link >
66+ </ DropdownMenuItem >
67+ < DropdownMenuItem onClick = { ( ) => setUpdateDialogOpen ( true ) } >
68+ Update Session
69+ </ DropdownMenuItem >
70+ < DropdownMenuItem className = "text-destructive" >
71+ Delete Session
72+ </ DropdownMenuItem >
73+ </ DropdownMenuContent >
74+ </ DropdownMenu >
3575 </ div >
36- < Link href = { `/coaching-sessions/${ coachingSession . id } ` } passHref >
37- < Button
38- size = "sm"
39- className = "w-full sm:w-auto mt-2 sm:mt-0"
40- onClick = { ( ) => setCurrentCoachingSessionId ( coachingSession . id ) }
41- >
42- Join Session
43- </ Button >
44- </ Link >
45- </ div >
46- </ CardHeader >
47- </ Card >
76+ </ CardHeader >
77+ </ Card >
78+ < CoachingSessionDialog
79+ open = { updateDialogOpen }
80+ onOpenChange = { setUpdateDialogOpen }
81+ onCoachingSessionUpdated = { ( ) => {
82+ // Refresh the list of coaching sessions
83+ window . location . reload ( ) ;
84+ } }
85+ existingSession = { coachingSession }
86+ mode = "update"
87+ />
88+ </ >
4889 ) ;
4990} ;
5091
0 commit comments