44
55import * as React from "react" ;
66
7- import { Checkbox } from "@/components/ui/checkbox" ;
87import { Separator } from "@/components/ui/separator" ;
98import { Tabs , TabsContent , TabsList , TabsTrigger } from "@/components/ui/tabs" ;
109import { Textarea } from "@/components/ui/textarea" ;
1110
12- import { ChevronUp , ChevronDown , Plus , X } from "lucide-react" ;
13-
14- import { Button } from "@/components/ui/button" ;
15- import {
16- Collapsible ,
17- CollapsibleContent ,
18- CollapsibleTrigger ,
19- } from "@/components/ui/collapsible" ;
20-
21- import { LockClosedIcon } from "@radix-ui/react-icons" ;
22-
23- import {
24- Tooltip ,
25- TooltipContent ,
26- TooltipProvider ,
27- TooltipTrigger ,
28- } from "@/components/ui/tooltip" ;
29-
30- import { CodeViewer } from "@/components/ui/code-viewer" ;
3111import { MaxLengthSelector } from "@/components/ui/maxlength-selector" ;
3212import { ModelSelector } from "@/components/ui/model-selector" ;
3313import { PresetActions } from "@/components/ui/preset-actions" ;
3414import { PresetSelector } from "@/components/ui/preset-selector" ;
35- import { PresetShare } from "@/components/ui/preset-share" ;
3615import { TemperatureSelector } from "@/components/ui/temperature-selector" ;
3716import { TopPSelector } from "@/components/ui/top-p-selector" ;
38- import { cn } from "@/lib/utils" ;
3917import { models , types } from "@/data/models" ;
4018import { current , future , past } from "@/data/presets" ;
4119import { useAppStateStore } from "@/lib/providers/app-state-store-provider" ;
@@ -47,32 +25,22 @@ import {
4725} from "@/lib/api/notes" ;
4826import { noteToString } from "@/types/note" ;
4927import { useAuthStore } from "@/lib/providers/auth-store-provider" ;
50- import { ActionStatus , Id } from "@/types/general" ;
51- import { AgreementsList } from "@/components/ui/coaching-sessions/agreements-list" ;
52- import { Agreement } from "@/types/agreement" ;
53- import {
54- createAgreement ,
55- deleteAgreement ,
56- updateAgreement ,
57- } from "@/lib/api/agreements" ;
28+
5829import { siteConfig } from "@/site.config" ;
59- import { ActionsList } from "@/components/ui/coaching-sessions/actions-list" ;
60- import { Action } from "@/types/action" ;
61- import { createAction , deleteAction , updateAction } from "@/lib/api/actions" ;
62- import { DateTime } from "ts-luxon" ;
6330import { CoachingSessionTitle } from "@/components/ui/coaching-sessions/coaching-session-title" ;
31+ import { OverarchingGoalContainer } from "@/components/ui/coaching-sessions/overarching-goal-container" ;
32+ import { Id } from "@/types/general" ;
6433
6534// export const metadata: Metadata = {
6635// title: "Coaching Session",
6736// description: "Coaching session main page, where the good stuff happens.",
6837// };
6938
7039export default function CoachingSessionsPage ( ) {
71- const [ isOpen , setIsOpen ] = useState ( false ) ;
7240 const [ noteId , setNoteId ] = useState < Id > ( "" ) ;
7341 const [ note , setNote ] = useState < string > ( "" ) ;
7442 const [ syncStatus , setSyncStatus ] = useState < string > ( "" ) ;
75- const { userId } = useAuthStore ( ( state ) => state ) ;
43+ const { userId } = useAuthStore ( ( state ) => ( { userId : state . userId } ) ) ;
7644 const { coachingSession, coachingRelationship } = useAppStateStore (
7745 ( state ) => state
7846 ) ;
@@ -106,83 +74,6 @@ export default function CoachingSessionsPage() {
10674 fetchNote ( ) ;
10775 } , [ coachingSession . id , noteId ] ) ;
10876
109- const handleAgreementAdded = ( body : string ) : Promise < Agreement > => {
110- // Calls the backend endpoint that creates and stores a full Agreement entity
111- return createAgreement ( coachingSession . id , userId , body )
112- . then ( ( agreement ) => {
113- return agreement ;
114- } )
115- . catch ( ( err ) => {
116- console . error ( "Failed to create new Agreement: " + err ) ;
117- throw err ;
118- } ) ;
119- } ;
120-
121- const handleAgreementEdited = ( id : Id , body : string ) : Promise < Agreement > => {
122- return updateAgreement ( id , coachingSession . id , userId , body )
123- . then ( ( agreement ) => {
124- return agreement ;
125- } )
126- . catch ( ( err ) => {
127- console . error ( "Failed to update Agreement (id: " + id + "): " + err ) ;
128- throw err ;
129- } ) ;
130- } ;
131-
132- const handleAgreementDeleted = ( id : Id ) : Promise < Agreement > => {
133- return deleteAgreement ( id )
134- . then ( ( agreement ) => {
135- return agreement ;
136- } )
137- . catch ( ( err ) => {
138- console . error ( "Failed to update Agreement (id: " + id + "): " + err ) ;
139- throw err ;
140- } ) ;
141- } ;
142-
143- const handleActionAdded = (
144- body : string ,
145- status : ActionStatus ,
146- dueBy : DateTime
147- ) : Promise < Action > => {
148- // Calls the backend endpoint that creates and stores a full Action entity
149- return createAction ( coachingSession . id , body , status , dueBy )
150- . then ( ( action ) => {
151- return action ;
152- } )
153- . catch ( ( err ) => {
154- console . error ( "Failed to create new Action: " + err ) ;
155- throw err ;
156- } ) ;
157- } ;
158-
159- const handleActionEdited = (
160- id : Id ,
161- body : string ,
162- status : ActionStatus ,
163- dueBy : DateTime
164- ) : Promise < Action > => {
165- return updateAction ( id , coachingSession . id , body , status , dueBy )
166- . then ( ( action ) => {
167- return action ;
168- } )
169- . catch ( ( err ) => {
170- console . error ( "Failed to update Action (id: " + id + "): " + err ) ;
171- throw err ;
172- } ) ;
173- } ;
174-
175- const handleActionDeleted = ( id : Id ) : Promise < Action > => {
176- return deleteAction ( id )
177- . then ( ( action ) => {
178- return action ;
179- } )
180- . catch ( ( err ) => {
181- console . error ( "Failed to update Action (id: " + id + "): " + err ) ;
182- throw err ;
183- } ) ;
184- } ;
185-
18677 const handleInputChange = ( value : string ) => {
18778 setNote ( value ) ;
18879
@@ -240,144 +131,52 @@ export default function CoachingSessionsPage() {
240131
241132 < Separator />
242133
243- < div className = "grid grid-flow-row auto-rows-min gap-4" >
244- < div className = "row-span-1 pt-4" >
245- < Collapsible
246- open = { isOpen }
247- onOpenChange = { setIsOpen }
248- className = "w-full space-y-2"
249- >
250- < div className = "flex items-center justify-between space-x-4 px-4" >
251- < Button
252- variant = "outline"
253- className = { cn (
254- "relative h-8 w-full justify-start rounded-[0.5rem] bg-muted text-sm font-semibold text-muted-foreground shadow-inner"
255- ) }
256- onClick = { ( ) => setIsOpen ( ! isOpen ) }
257- >
258- < span className = "hidden md:inline-flex md:inline-flex" >
259- Overarching goal: to achieve...
260- </ span >
261- < span className = "inline-flex md:hidden" > Goal...</ span >
262- < div className = "ml-auto flex w-full space-x-2 justify-end" >
263- < div className = "flex items-center space-x-2" >
264- < TooltipProvider >
265- < Tooltip >
266- < TooltipTrigger asChild >
267- { /* FIXME: causes a React hydration error to put a checkbox here, not sure why */ }
268- { /* <Checkbox id="oa_achieved" /> */ }
269- </ TooltipTrigger >
270- < TooltipContent >
271- < p className = "font-normal" > Achieved?</ p >
272- </ TooltipContent >
273- </ Tooltip >
274- </ TooltipProvider >
275- </ div >
276- < span >
277- { ! isOpen && < ChevronDown className = "h-4 w-4" /> }
278- { isOpen && < ChevronUp className = "h-4 w-4" /> }
279- </ span >
280- </ div >
281- </ Button >
282- { /* <CollapsibleTrigger asChild>
283- <Button variant="ghost" size="sm" className="w-9 p-0">
284- <ChevronsUpDown className="h-4 w-4" />
285- <span className="sr-only">Toggle</span>
286- </Button>
287- </CollapsibleTrigger> */ }
288- </ div >
289- < CollapsibleContent className = "px-4" >
290- < div className = "flex-col space-y-4 sm:flex" >
291- < div className = "grid flex-1 items-start gap-4 sm:py-0 md:gap-8" >
292- < Tabs defaultValue = "agreements" >
293- < div className = "flex items-center" >
294- < TabsList className = "grid grid-cols-3" >
295- < TabsTrigger value = "agreements" > Agreements</ TabsTrigger >
296- < TabsTrigger value = "actions" > Actions</ TabsTrigger >
297- < TabsTrigger value = "program" > Program</ TabsTrigger >
298- </ TabsList >
299- </ div >
300- < TabsContent value = "agreements" >
301- < div className = "w-full" >
302- < AgreementsList
303- coachingSessionId = { coachingSession . id }
304- userId = { userId }
305- locale = { siteConfig . locale }
306- onAgreementAdded = { handleAgreementAdded }
307- onAgreementEdited = { handleAgreementEdited }
308- onAgreementDeleted = { handleAgreementDeleted }
309- > </ AgreementsList >
310- </ div >
311- </ TabsContent >
312- < TabsContent value = "actions" >
313- < div className = "w-full" >
314- < ActionsList
315- coachingSessionId = { coachingSession . id }
316- userId = { userId }
317- locale = { siteConfig . locale }
318- onActionAdded = { handleActionAdded }
319- onActionEdited = { handleActionEdited }
320- onActionDeleted = { handleActionDeleted }
321- > </ ActionsList >
322- </ div >
323- </ TabsContent >
324- < TabsContent value = "program" >
325- { /* <div className="bg-blue-500 text-white">Program</div> */ }
326- </ TabsContent >
327- </ Tabs >
328- </ div >
329- </ div >
330- </ CollapsibleContent >
331- </ Collapsible >
332- </ div >
134+ < OverarchingGoalContainer userId = { userId } />
333135
334- < div className = "row-span-1 h-full py-4 px-4" >
335- < div className = "grid h-full items-stretch gap-6 md:grid-cols-[1fr_200px]" >
336- < div className = "flex-col space-y-4 sm:flex md:order-1" >
337- < Tabs defaultValue = "notes" className = "flex-1" >
338- < TabsList className = "grid flex w-128 grid-cols-2 justify-start" >
339- < TabsTrigger value = "notes" > Notes</ TabsTrigger >
340- < TabsTrigger value = "console" > Console</ TabsTrigger >
341- { /* <TabsTrigger value="coachs_notes">
136+ < div className = "row-span-1 h-full py-4 px-4" >
137+ < div className = "grid h-full items-stretch gap-6 md:grid-cols-[1fr_200px]" >
138+ < div className = "flex-col space-y-4 sm:flex md:order-1" >
139+ < Tabs defaultValue = "notes" className = "flex-1" >
140+ < TabsList className = "grid flex w-128 grid-cols-2 justify-start" >
141+ < TabsTrigger value = "notes" > Notes</ TabsTrigger >
142+ < TabsTrigger value = "console" > Console</ TabsTrigger >
143+ { /* <TabsTrigger value="coachs_notes">
342144 <div className="flex gap-2 items-start">
343145 <LockClosedIcon className="mt-1" />
344146 Coach's Notes
345147 </div>
346148 </TabsTrigger> */ }
347- </ TabsList >
348- < TabsContent value = "notes" >
349- < div className = "flex h-full flex-col space-y-4" >
350- < CoachingNotes
351- value = { note }
352- onChange = { handleInputChange }
353- onKeyDown = { handleKeyDown }
354- > </ CoachingNotes >
355- < p className = "text-sm text-muted-foreground" >
356- { syncStatus }
357- </ p >
358- </ div >
359- </ TabsContent >
360- < TabsContent value = "console" >
361- < div className = "p-4 min-h-[400px] md:min-h-[630px] lg:min-h-[630px] bg-blue-500 text-white" >
362- Console
363- </ div >
364- </ TabsContent >
365- < TabsContent value = "coachs_notes" >
366- < div className = "flex h-full flex-col space-y-4" >
367- < Textarea
368- placeholder = "Coach's notes"
369- className = "p-4 min-h-[400px] md:min-h-[630px] lg:min-h-[630px]"
370- />
371- </ div >
372- </ TabsContent >
373- </ Tabs >
374- </ div >
375- < div className = "flex-col space-y-4 sm:flex md:order-2" >
376- < ModelSelector types = { types } models = { models } />
377- < TemperatureSelector defaultValue = { [ 0.56 ] } />
378- < MaxLengthSelector defaultValue = { [ 256 ] } />
379- < TopPSelector defaultValue = { [ 0.9 ] } />
380- </ div >
149+ </ TabsList >
150+ < TabsContent value = "notes" >
151+ < div className = "flex h-full flex-col space-y-4" >
152+ < CoachingNotes
153+ value = { note }
154+ onChange = { handleInputChange }
155+ onKeyDown = { handleKeyDown }
156+ > </ CoachingNotes >
157+ < p className = "text-sm text-muted-foreground" > { syncStatus } </ p >
158+ </ div >
159+ </ TabsContent >
160+ < TabsContent value = "console" >
161+ < div className = "p-4 min-h-[400px] md:min-h-[630px] lg:min-h-[630px] bg-blue-500 text-white" >
162+ Console
163+ </ div >
164+ </ TabsContent >
165+ < TabsContent value = "coachs_notes" >
166+ < div className = "flex h-full flex-col space-y-4" >
167+ < Textarea
168+ placeholder = "Coach's notes"
169+ className = "p-4 min-h-[400px] md:min-h-[630px] lg:min-h-[630px]"
170+ />
171+ </ div >
172+ </ TabsContent >
173+ </ Tabs >
174+ </ div >
175+ < div className = "flex-col space-y-4 sm:flex md:order-2" >
176+ < ModelSelector types = { types } models = { models } />
177+ < TemperatureSelector defaultValue = { [ 0.56 ] } />
178+ < MaxLengthSelector defaultValue = { [ 256 ] } />
179+ < TopPSelector defaultValue = { [ 0.9 ] } />
381180 </ div >
382181 </ div >
383182 </ div >
0 commit comments