@@ -8,6 +8,7 @@ import { useCollaborationToken } from "@/lib/api/collaboration-token";
88import { useAuthStore } from "@/lib/providers/auth-store-provider" ;
99import { useCoachingSessionStateStore } from "@/lib/providers/coaching-session-state-store-provider" ;
1010import { Extensions } from "@/components/ui/coaching-sessions/coaching-notes/extensions" ;
11+ import { Progress } from "@/components/ui/progress" ;
1112import { Toolbar } from "@/components/ui/coaching-sessions/coaching-notes/toolbar" ;
1213import { siteConfig } from "@/site.config" ;
1314import "@/styles/styles.scss" ;
@@ -91,15 +92,55 @@ const useCollaborationProvider = (doc: Y.Doc) => {
9192
9293const CoachingNotes = ( ) => {
9394 const [ doc ] = useState ( ( ) => new Y . Doc ( ) ) ;
95+ const [ loadingProgress , setLoadingProgress ] = useState ( 0 ) ;
9496 const { isLoading, isError, extensions } = useCollaborationProvider ( doc ) ;
9597
96- if ( isLoading ) return < div > Loading coaching notes...</ div > ;
97- if ( isError )
98+ // Simulate loading progress
99+ useEffect ( ( ) => {
100+ if ( isLoading ) {
101+ setLoadingProgress ( 0 ) ;
102+ const interval = setInterval ( ( ) => {
103+ setLoadingProgress ( ( prev ) => {
104+ if ( prev >= 90 ) {
105+ clearInterval ( interval ) ;
106+ return 90 ; // Stop at 90% until actually loaded
107+ }
108+ return prev + Math . random ( ) * 15 ;
109+ } ) ;
110+ } , 200 ) ;
111+
112+ return ( ) => clearInterval ( interval ) ;
113+ } else {
114+ // Complete the progress (100%) when loading is done
115+ setLoadingProgress ( 100 ) ;
116+ }
117+ } , [ isLoading ] ) ;
118+
119+ if ( isLoading ) {
120+ return (
121+ < div className = "flex flex-col items-center justify-center space-y-4 p-8 min-h-[440px] lg:min-h-[440px] sm:min-h-[200px] md:min-h-[350px]" >
122+ < div className = "w-full max-w-md" >
123+ < div className = "flex items-center justify-between mb-2" >
124+ < span className = "text-sm font-medium text-gray-700 dark:text-gray-300" >
125+ Loading coaching notes...
126+ </ span >
127+ < span className = "text-sm text-gray-500 dark:text-gray-400" >
128+ { Math . round ( loadingProgress ) } %
129+ </ span >
130+ </ div >
131+ < Progress value = { loadingProgress } className = "h-2" />
132+ </ div >
133+ </ div >
134+ ) ;
135+ }
136+
137+ if ( isError ) {
98138 return (
99139 < div >
100140 We could not retrieve your coaching notes. Please try again later.
101141 </ div >
102142 ) ;
143+ }
103144
104145 return (
105146 < div className = "border rounded" >
0 commit comments