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