@@ -2,7 +2,7 @@ import { useEffect, useRef, useState } from 'react'
22import render from '../../src/render.jsx' ;
33import Layout from '../components/Layout.jsx' ;
44import EnrollmentForm from '../components/EnrollmentForm.jsx' ;
5- import { Box , Button , Card , Chip , Container , Dialog , Grid , Link , List , ListItem , ListItemIcon , ListItemText , Stack , Typography } from '@mui/material' ;
5+ import { Alert , Box , Button , Card , Chip , Container , Dialog , Grid , Link , List , ListItem , ListItemIcon , ListItemText , Stack , Typography } from '@mui/material' ;
66import CheckCircleIcon from '@mui/icons-material/CheckCircle' ;
77import { alpha , ThemeProvider } from '@mui/material/styles' ;
88import { useAppContext } from '../../src/render.jsx' ;
@@ -14,6 +14,7 @@ function Course() {
1414 const [ displayModal , setDisplayModal ] = useState ( false ) ;
1515 const [ modalContent , setModalContent ] = useState ( null ) ;
1616 const [ enrolled , setEnrolled ] = useState ( false ) ;
17+ const [ showEnrollmentAlert , setShowEnrollmentAlert ] = useState ( false ) ;
1718 const [ showFixedEnrollBar , setShowFixedEnrollBar ] = useState ( false ) ;
1819 const topEnrollButtonRef = useRef ( null ) ;
1920
@@ -61,6 +62,8 @@ function Course() {
6162 setDisplayModal ( false ) ;
6263 setModalContent ( null ) ;
6364 setEnrolled ( true ) ;
65+ setShowEnrollmentAlert ( true ) ;
66+ scrollTo ( { top : 0 , behavior : 'smooth' } ) ;
6467 }
6568
6669 return < ThemeProvider theme = { lightTheme } > < Layout >
@@ -143,17 +146,7 @@ function Course() {
143146 mx : { xs : 'auto' , md : 0 } ,
144147 } }
145148 >
146- { enrolled ? (
147- < Chip
148- label = { localeMessages [ 'enrollment_success' ] }
149- sx = { ( theme ) => ( {
150- backgroundColor : alpha ( theme . palette . success . main , 0.18 ) ,
151- color : theme . palette . common . white ,
152- fontWeight : 600 ,
153- backdropFilter : 'blur(8px)' ,
154- } ) }
155- />
156- ) : (
149+ { ! enrolled && (
157150 < Button
158151 variant = "contained"
159152 color = "primary"
@@ -173,6 +166,15 @@ function Course() {
173166 </ Stack >
174167 </ Box >
175168 </ Box >
169+ { enrolled && showEnrollmentAlert && (
170+ < Alert
171+ severity = "success"
172+ onClose = { ( ) => setShowEnrollmentAlert ( false ) }
173+ sx = { { mb : 4 , direction : courseDirection } }
174+ >
175+ { localeMessages [ 'enrollment_success' ] }
176+ </ Alert >
177+ ) }
176178
177179 { /* Course Info Section */ }
178180 < Box
@@ -186,7 +188,7 @@ function Course() {
186188 direction : courseDirection ,
187189 } }
188190 >
189- < Stack spacing = { 2 } >
191+ < Stack spacing = { { xs : 2 , md : 5 } } >
190192
191193 { course . description && (
192194 < Typography
@@ -196,27 +198,12 @@ function Course() {
196198 />
197199 ) }
198200
199- { course . target_audience && (
200- < Box sx = { { py : 1 } } >
201- < Typography variant = "h2" sx = { { mb : 1 , direction : courseDirection , fontSize : '1.25rem' , fontWeight : 600 } } >
202- { localeMessages [ 'target_audience_title' ] }
203- </ Typography >
204- < Typography
205- variant = "body2"
206- sx = { { color : 'text.secondary' , direction : courseDirection } }
207- dangerouslySetInnerHTML = { { __html : course . target_audience } }
208- />
209- </ Box >
210- ) }
211-
212201 { /* Organization Info */ }
213202 < Box
214203 sx = { {
215204 p : 2 ,
216- borderRadius : 1.5 ,
205+ borderRadius : 2 ,
217206 backgroundColor : "white" ,
218- mt : 2 ,
219- direction : courseDirection ,
220207 } }
221208 >
222209 < Grid container spacing = { 2 } >
@@ -251,6 +238,20 @@ function Course() {
251238 </ Grid >
252239 </ Grid >
253240 </ Box >
241+
242+ { course . target_audience && (
243+ < Box sx = { { py : 1 } } >
244+ < Typography variant = "h2" sx = { { mb : 1 , direction : courseDirection , fontSize : '1.25rem' , fontWeight : 600 } } >
245+ { localeMessages [ 'target_audience_title' ] }
246+ </ Typography >
247+ < Typography
248+ variant = "body2"
249+ sx = { { color : 'text.secondary' , direction : courseDirection } }
250+ dangerouslySetInnerHTML = { { __html : course . target_audience } }
251+ />
252+ </ Box >
253+ ) }
254+
254255 </ Stack >
255256 </ Box >
256257
@@ -312,7 +313,7 @@ function Course() {
312313
313314 { course . external_references && course . external_references . length > 0 && (
314315 < Box my = { 4 } >
315- < Typography variant = "h2" sx = { { mb : 2 , direction : courseDirection } } >
316+ < Typography variant = "h2" sx = { { direction : courseDirection } } >
316317 { localeMessages [ 'external_references_title' ] }
317318 </ Typography >
318319 < Card
@@ -401,15 +402,7 @@ function Course() {
401402 { course . title }
402403 </ Typography >
403404 < Box >
404- { enrolled ? (
405- < Chip
406- label = { localeMessages [ 'enrollment_success' ] }
407- sx = { ( theme ) => ( {
408- backgroundColor : alpha ( theme . palette . success . main , 0.15 ) ,
409- color : theme . palette . success . main ,
410- } ) }
411- />
412- ) : (
405+ { ! enrolled && (
413406 < Button
414407 variant = "contained"
415408 color = "primary"
0 commit comments