@@ -20,13 +20,13 @@ export function Course() {
2020
2121 const handleModuleChange = ( e ) => {
2222 const { name, value } = e . target ;
23- setNewModuleName ( { [ name ] : value } ) ;
23+ setNewModuleName ( { [ name ] : value } ) ;
2424 } ;
2525
26- const handleCreateModule = async ( e ) => {
27- if ( newModuleName . title === "" ) {
26+ const handleCreateModule = async ( e ) => {
27+ if ( newModuleName . title === "" ) {
2828 return
29- }
29+ }
3030
3131 const userId = Cookies . get ( 'userId' ) ;
3232 try {
@@ -56,13 +56,13 @@ export function Course() {
5656
5757 const handleContentChange = ( e ) => {
5858 const { name, value } = e . target ;
59- setNewContentName ( { [ name ] : value } ) ;
59+ setNewContentName ( { [ name ] : value } ) ;
6060 } ;
6161
62- const handleCreateContent = ( moduleID ) => async ( e ) => {
63- if ( newContentName . title === "" ) {
62+ const handleCreateContent = ( moduleID ) => async ( e ) => {
63+ if ( newContentName . title === "" ) {
6464 return
65- }
65+ }
6666
6767 const userId = Cookies . get ( 'userId' ) ;
6868 try {
@@ -92,9 +92,9 @@ export function Course() {
9292 }
9393
9494 const handleEditThumbnail = ( courseID ) => async ( e ) => {
95- if ( file === null ) {
95+ if ( file === null ) {
9696 return
97- }
97+ }
9898
9999 const userId = Cookies . get ( 'userId' ) ;
100100 try {
@@ -132,9 +132,9 @@ export function Course() {
132132 method : "POST" ,
133133 headers : {
134134 "Content-Type" : "application/json" ,
135- } ,
136- } ) ;
137- const data = await response . json ( ) ;
135+ } ,
136+ } ) ;
137+ const data = await response . json ( ) ;
138138 if ( response . ok ) {
139139 Notiflix . Notify . success ( "Succesfully enrolled in the course!" ) ;
140140 setTimeout ( ( ) => {
@@ -162,9 +162,9 @@ export function Course() {
162162 method : "DELETE" ,
163163 headers : {
164164 "Content-Type" : "application/json" ,
165- } ,
166- } ) ;
167- const data = await response . json ( ) ;
165+ } ,
166+ } ) ;
167+ const data = await response . json ( ) ;
168168 if ( response . ok ) {
169169 Notiflix . Notify . success ( "Succesfully unenrolled in the course!" ) ;
170170 setTimeout ( ( ) => {
@@ -190,38 +190,38 @@ export function Course() {
190190
191191 async function fetchCourse ( ) {
192192 fetch ( `http://localhost:4000/course/${ courseID } ` )
193- . then ( ( response ) => {
194- if ( ! response . ok ) {
195- throw new Error ( 'Network response was not ok' ) ;
196- }
197- return response . json ( ) ;
198- } )
199- . then ( ( data ) => setCourseInfo ( data . course ) )
200- . catch ( ( error ) => setError ( error . message ) ) ;
193+ . then ( ( response ) => {
194+ if ( ! response . ok ) {
195+ throw new Error ( 'Network response was not ok' ) ;
196+ }
197+ return response . json ( ) ;
198+ } )
199+ . then ( ( data ) => setCourseInfo ( data . course ) )
200+ . catch ( ( error ) => setError ( error . message ) ) ;
201201 }
202202
203203 async function fetchUser ( ) {
204204 await fetch ( `http://localhost:4000/user/${ userId } ` )
205- . then ( ( response ) => {
206- if ( ! response . ok ) {
207- throw new Error ( 'Network response was not ok' ) ;
208- }
209- return response . json ( ) ;
210- } )
211- . then ( ( data ) => setUserInfo ( data . user ) )
212- . catch ( ( error ) => setError ( error . message ) ) ;
205+ . then ( ( response ) => {
206+ if ( ! response . ok ) {
207+ throw new Error ( 'Network response was not ok' ) ;
208+ }
209+ return response . json ( ) ;
210+ } )
211+ . then ( ( data ) => setUserInfo ( data . user ) )
212+ . catch ( ( error ) => setError ( error . message ) ) ;
213213 }
214214
215215 async function fetchIsEnrolled ( ) {
216216 await fetch ( `http://localhost:4000/is-enrolled/${ userId } /${ courseID } ` )
217- . then ( ( response ) => {
218- if ( ! response . ok ) {
219- throw new Error ( 'Network response was not ok' ) ;
220- }
221- return response . json ( ) ;
222- } )
223- . then ( ( data ) => setIsEnrolled ( data . isEnrolled ) )
224- . catch ( ( error ) => setError ( error . message ) ) ;
217+ . then ( ( response ) => {
218+ if ( ! response . ok ) {
219+ throw new Error ( 'Network response was not ok' ) ;
220+ }
221+ return response . json ( ) ;
222+ } )
223+ . then ( ( data ) => setIsEnrolled ( data . isEnrolled ) )
224+ . catch ( ( error ) => setError ( error . message ) ) ;
225225 }
226226
227227 fetchCourse ( ) ;
@@ -245,7 +245,7 @@ export function Course() {
245245 </ a >
246246 )
247247 } )
248- if ( userInfo . role === "educator" ) {
248+ if ( userInfo . role === "educator" ) {
249249 moduleList . push (
250250 < div >
251251 < div className = "flex justify-between flex-wrap bg-slate-400 p-4 rounded shadow" >
@@ -255,12 +255,12 @@ export function Course() {
255255 < Modal
256256 title = { "Add New Content" }
257257 trigger = {
258- < div className = "bg-blue-500 p-2 rounded shadow hover:bg-blue-700 m-auto text-center text-sm text-white font-semibold hover:cursor-pointer" >
259- < div > + Add Content</ div >
258+ < div className = "bg-blue-500 p-2 rounded shadow hover:bg-blue-700 m-auto text-center text-sm text-white font-semibold hover:cursor-pointer" >
259+ < div > + Add Content</ div >
260260 </ div >
261261 }
262262 inputFields = { {
263- title : "Content Name" ,
263+ title : "Content Name" ,
264264 } }
265265 changeHandler = { handleContentChange }
266266 confirmHandler = { handleCreateContent ( module . ID ) }
@@ -286,29 +286,29 @@ export function Course() {
286286 } ) ;
287287
288288 let createButton = null ;
289- if ( userInfo . role === "educator" ) {
289+ if ( userInfo . role === "educator" ) {
290290 createButton = < Modal
291291 title = { "Create New Module" }
292292 trigger = {
293- < div className = "bg-blue-500 p-2 rounded shadow hover:bg-blue-700 m-auto text-center text-sm text-white font-semibold hover:cursor-pointer" >
294- < div > + Add Module</ div >
293+ < div className = "bg-blue-500 p-2 rounded shadow hover:bg-blue-700 m-auto text-center text-sm text-white font-semibold hover:cursor-pointer" >
294+ < div > + Add Module</ div >
295295 </ div >
296296 }
297297 inputFields = { {
298- title : "Module Name" ,
298+ title : "Module Name" ,
299299 } }
300300 changeHandler = { handleModuleChange }
301301 confirmHandler = { handleCreateModule }
302302 />
303303 }
304304
305305 let editThumbnail = null ;
306- if ( userInfo . role === "educator" ) {
306+ if ( userInfo . role === "educator" ) {
307307 editThumbnail = < Modal
308308 title = { "Edit Thumbnail" }
309309 trigger = {
310- < div className = "bg-blue-500 p-2 rounded shadow hover:bg-blue-700 m-auto text-center text-sm text-white font-semibold hover:cursor-pointer" >
311- < div > Edit Thumbnail</ div >
310+ < div className = "bg-blue-500 p-2 rounded shadow hover:bg-blue-700 m-auto text-center text-sm text-white font-semibold hover:cursor-pointer" >
311+ < div > Edit Thumbnail</ div >
312312 </ div >
313313 }
314314 confirmHandler = { handleEditThumbnail ( courseID ) }
@@ -324,13 +324,13 @@ export function Course() {
324324 { editThumbnail }
325325 { createButton }
326326 { userInfo . role === "student" && (
327- < button
328- onClick = { isEnrolled ? handleUnenroll : handleEnroll }
329- className = { `p-2 rounded shadow text-white font-semibold ${ isEnrolled ? 'bg-red-500 hover:bg-red-700' : 'bg-green-500 hover:bg-green-700' } ` }
330- >
331- { isEnrolled ? 'Unenroll from Course' : 'Enroll in Course' }
332- </ button >
333- ) }
327+ < button
328+ onClick = { isEnrolled ? handleUnenroll : handleEnroll }
329+ className = { `p-2 rounded shadow text-white font-semibold ${ isEnrolled ? 'bg-red-500 hover:bg-red-700' : 'bg-green-500 hover:bg-green-700' } ` }
330+ >
331+ { isEnrolled ? 'Unenroll from Course' : 'Enroll in Course' }
332+ </ button >
333+ ) }
334334 </ div >
335335 </ div >
336336 < div className = "grid grid-cols-1 gap-6" >
0 commit comments