@@ -60,6 +60,8 @@ import { ActionsList } from "@/components/ui/coaching-sessions/actions-list";
60
60
import { Action } from "@/types/action" ;
61
61
import { createAction , deleteAction , updateAction } from "@/lib/api/actions" ;
62
62
import { DateTime } from "ts-luxon" ;
63
+ import { CoachingSessionTitle } from "@/components/ui/coaching-sessions/coaching-session-title" ;
64
+ import { SessionTitle , SessionTitleStyle } from "@/types/session-title" ;
63
65
64
66
// export const metadata: Metadata = {
65
67
// title: "Coaching Session",
@@ -72,26 +74,28 @@ export default function CoachingSessionsPage() {
72
74
const [ note , setNote ] = useState < string > ( "" ) ;
73
75
const [ syncStatus , setSyncStatus ] = useState < string > ( "" ) ;
74
76
const { userId } = useAuthStore ( ( state ) => state ) ;
75
- const { coachingSessionId } = useAppStateStore ( ( state ) => state ) ;
77
+ const { coachingSession, coachingRelationship } = useAppStateStore (
78
+ ( state ) => state
79
+ ) ;
76
80
77
81
useEffect ( ( ) => {
78
82
async function fetchNote ( ) {
79
- if ( ! coachingSessionId ) {
83
+ if ( ! coachingSession . id ) {
80
84
console . error (
81
- "Failed to fetch Note since coachingSessionId is not set."
85
+ "Failed to fetch Note since coachingSession.id is not set."
82
86
) ;
83
87
return ;
84
88
}
85
89
86
- await fetchNotesByCoachingSessionId ( coachingSessionId )
90
+ await fetchNotesByCoachingSessionId ( coachingSession . id )
87
91
. then ( ( notes ) => {
88
92
const note = notes [ 0 ] ;
89
93
if ( notes . length > 0 ) {
90
94
console . trace ( "note: " + noteToString ( note ) ) ;
91
95
setNoteId ( note . id ) ;
92
96
setNote ( note . body ) ;
93
97
} else {
94
- console . trace ( "No Notes associated with this coachingSessionId " ) ;
98
+ console . trace ( "No Notes associated with this coachingSession.id " ) ;
95
99
}
96
100
} )
97
101
. catch ( ( err ) => {
@@ -101,11 +105,11 @@ export default function CoachingSessionsPage() {
101
105
} ) ;
102
106
}
103
107
fetchNote ( ) ;
104
- } , [ coachingSessionId , noteId ] ) ;
108
+ } , [ coachingSession . id , noteId ] ) ;
105
109
106
110
const handleAgreementAdded = ( body : string ) : Promise < Agreement > => {
107
111
// Calls the backend endpoint that creates and stores a full Agreement entity
108
- return createAgreement ( coachingSessionId , userId , body )
112
+ return createAgreement ( coachingSession . id , userId , body )
109
113
. then ( ( agreement ) => {
110
114
return agreement ;
111
115
} )
@@ -116,7 +120,7 @@ export default function CoachingSessionsPage() {
116
120
} ;
117
121
118
122
const handleAgreementEdited = ( id : Id , body : string ) : Promise < Agreement > => {
119
- return updateAgreement ( id , coachingSessionId , userId , body )
123
+ return updateAgreement ( id , coachingSession . id , userId , body )
120
124
. then ( ( agreement ) => {
121
125
return agreement ;
122
126
} )
@@ -143,7 +147,7 @@ export default function CoachingSessionsPage() {
143
147
dueBy : DateTime
144
148
) : Promise < Action > => {
145
149
// Calls the backend endpoint that creates and stores a full Action entity
146
- return createAction ( coachingSessionId , body , status , dueBy )
150
+ return createAction ( coachingSession . id , body , status , dueBy )
147
151
. then ( ( action ) => {
148
152
return action ;
149
153
} )
@@ -159,7 +163,7 @@ export default function CoachingSessionsPage() {
159
163
status : ActionStatus ,
160
164
dueBy : DateTime
161
165
) : Promise < Action > => {
162
- return updateAction ( id , coachingSessionId , body , status , dueBy )
166
+ return updateAction ( id , coachingSession . id , body , status , dueBy )
163
167
. then ( ( action ) => {
164
168
return action ;
165
169
} )
@@ -183,8 +187,8 @@ export default function CoachingSessionsPage() {
183
187
const handleInputChange = ( value : string ) => {
184
188
setNote ( value ) ;
185
189
186
- if ( noteId && coachingSessionId && userId ) {
187
- updateNote ( noteId , coachingSessionId , userId , value )
190
+ if ( noteId && coachingSession . id && userId ) {
191
+ updateNote ( noteId , coachingSession . id , userId , value )
188
192
. then ( ( note ) => {
189
193
console . trace ( "Updated Note: " + noteToString ( note ) ) ;
190
194
setSyncStatus ( "All changes saved" ) ;
@@ -193,8 +197,8 @@ export default function CoachingSessionsPage() {
193
197
setSyncStatus ( "Failed to save changes" ) ;
194
198
console . error ( "Failed to update Note: " + err ) ;
195
199
} ) ;
196
- } else if ( ! noteId && coachingSessionId && userId ) {
197
- createNote ( coachingSessionId , userId , value )
200
+ } else if ( ! noteId && coachingSession . id && userId ) {
201
+ createNote ( coachingSession . id , userId , value )
198
202
. then ( ( note ) => {
199
203
console . trace ( "Newly created Note: " + noteToString ( note ) ) ;
200
204
setNoteId ( note . id ) ;
@@ -206,7 +210,7 @@ export default function CoachingSessionsPage() {
206
210
} ) ;
207
211
} else {
208
212
console . error (
209
- "Could not update or create a Note since coachingSessionId or userId are not set."
213
+ "Could not update or create a Note since coachingSession.id or userId are not set."
210
214
) ;
211
215
}
212
216
} ;
@@ -215,11 +219,21 @@ export default function CoachingSessionsPage() {
215
219
setSyncStatus ( "" ) ;
216
220
} ;
217
221
222
+ const handleTitleRender = ( sessionTitle : string ) => {
223
+ document . title = sessionTitle ;
224
+ } ;
225
+
218
226
return (
219
227
< >
220
- < div className = "hidden h-full flex-col md:flex" >
228
+ < div className = "h-full flex-col md:flex" >
221
229
< div className = "flex flex-col items-start justify-between space-y-2 py-4 px-4 sm:flex-row sm:items-center sm:space-y-0 md:h-16" >
222
- < h4 className = "w-16 md:w-32 lg:w-48 font-semibold" > Session Title</ h4 >
230
+ < CoachingSessionTitle
231
+ coachingSession = { coachingSession }
232
+ coachingRelationship = { coachingRelationship }
233
+ locale = { siteConfig . locale }
234
+ style = { SessionTitleStyle . CoachFirstCoacheeFirstDate }
235
+ onRender = { handleTitleRender }
236
+ > </ CoachingSessionTitle >
223
237
< div className = "ml-auto flex w-full space-x-2 sm:justify-end" >
224
238
< PresetSelector current = { current } future = { future } past = { past } />
225
239
< PresetActions />
@@ -289,7 +303,7 @@ export default function CoachingSessionsPage() {
289
303
< TabsContent value = "agreements" >
290
304
< div className = "w-full" >
291
305
< AgreementsList
292
- coachingSessionId = { coachingSessionId }
306
+ coachingSessionId = { coachingSession . id }
293
307
userId = { userId }
294
308
locale = { siteConfig . locale }
295
309
onAgreementAdded = { handleAgreementAdded }
@@ -301,7 +315,7 @@ export default function CoachingSessionsPage() {
301
315
< TabsContent value = "actions" >
302
316
< div className = "w-full" >
303
317
< ActionsList
304
- coachingSessionId = { coachingSessionId }
318
+ coachingSessionId = { coachingSession . id }
305
319
userId = { userId }
306
320
locale = { siteConfig . locale }
307
321
onActionAdded = { handleActionAdded }
0 commit comments