11import { useState , useEffect } from 'react' ;
22import { useParams } from "react-router-dom" ;
33import LoadingSpinner from '../components/Utilities/Loaders/LoadingSpinner.js' ;
4-
54import Buttons from "../components/Utilities/Buttons/buttons" ;
6-
75export default function CourseDetails ( ) {
86 const API = 'https://chain-legendary-strawflower.glitch.me/courses/' ;
97 const params = useParams ( ) ;
108 const [ course , setCourse ] = useState ( null ) ;
11- // const navigate = useNavigate();
129 const fetchDetails = ( ) => {
1310 setTimeout ( function ( )
1411 {
15- fetch ( `${ API } ${ params . id } ` )
16- . then ( ( res ) => res . json ( ) )
17- . then ( ( data ) => setCourse ( data ) )
18-
19- . catch ( ( error ) => {
20- console . log ( "Error in fetching:" , error )
21- } ) ;
22- } , 1500 ) ;
12+ fetch ( `${ API } ${ params . id } ` )
13+ . then ( ( res ) => res . json ( ) )
14+ . then ( ( data ) => setCourse ( data ) )
15+ . catch ( ( error ) => { console . log ( "Error in fetching:" , error ) } ) ;
16+ } , 1000 ) ;
2317 }
2418 useEffect ( ( ) => {
2519 fetchDetails ( )
@@ -37,40 +31,39 @@ export default function CourseDetails(){
3731 </ div >
3832 < div className = "w-full md:w-5/12 ml-auto mr-auto flex flex-col" >
3933 < div className = "md:pr-12" >
40- < h3 className = "text-3xl font-semibold text-indigo-500 underline underline-offset-8 hover:text-gray-600 hover:duration-600" > { course . title } </ h3 >
41- < p className = "mt-2 text-lg leading-relaxed text-slate-700 border-b-2 border-gray-500 py-2 antialiased" > { course . description } </ p >
42- < ul className = "list-none flex-wrap grid grid-cols-2 mb-1 " >
34+ < h3 className = "text-3xl font-bold text-indigo-500 underline underline-offset-8 hover:text-gray-600 hover:duration-600" > { course . title } </ h3 >
35+ < p className = "mt-3 mb-3 text-lg leading-relaxed text-slate-700 border-b-2 border-gray-500 py-2 antialiased" > { course . description } </ p >
36+ < ul className = "list-none flex-wrap grid grid-cols-2 mb-3 mt-5 " >
4337 < li className = "py-2 flex flex-col" >
44- < div className = "flex items-center" >
45- < div > < span className = "text-normal font-semibold inline-block py-1 px-2 uppercase rounded-full text-slate-100 bg-indigo-600 mr-3" > < i className = "fa-solid fa-calendar-minus" > </ i > </ span > </ div >
46- < div > < h4 className = "text-slate-600 hover:text-indigo-500 font-semibold hover:underline text-normal" > Start Date:< span > { course . dates . start_date . split ( "-" ) . reverse ( ) . join ( "/" ) } </ span > </ h4 > </ div > </ div > </ li >
38+ < div className = "flex items-center" >
39+ < div > < span className = "text-normal font-normal inline-block py-1 px-2 rounded-full text-slate-100 bg-indigo-600 mr-3" > < i className = "fa-solid fa-calendar-minus" > </ i > </ span > </ div >
40+ < div > < h4 className = "text-slate-600 hover:text-indigo-500 font-normal hover:underline text-normal" > Start Date:< span > { course . dates . start_date . split ( "-" ) . reverse ( ) . join ( "/" ) } </ span > </ h4 > </ div > </ div >
41+ </ li >
4742 < li className = "py-2 flex flex-col" >
4843 < div className = "flex items-center" >
49- < div > < span className = "text-normal font-semibold inline-block py-1 px-2 uppercase rounded-full text-slate-100 bg-indigo-600 mr-3" > < i className = "fa-solid fa-calendar-plus" > </ i > </ span > </ div >
50- < div > < h4 className = "text-slate-600 hover:text-indigo-500 font-semibold hover:underline text-normal" > End Date:< span > { course . dates . end_date . split ( "-" ) . reverse ( ) . join ( "/" ) } </ span > </ h4 > </ div > </ div > </ li >
44+ < div > < span className = "text-normal font-normal inline-block py-1 px-2 rounded-full text-slate-100 bg-indigo-600 mr-3" > < i className = "fa-solid fa-calendar-plus" > </ i > </ span > </ div >
45+ < div > < h4 className = "text-slate-600 hover:text-indigo-500 font-normal hover:underline text-normal" > End Date:< span > { course . dates . end_date . split ( "-" ) . reverse ( ) . join ( "/" ) } </ span > </ h4 > </ div > </ div > </ li >
5146 < li className = "py-2 flex flex-col" >
5247 < div className = "flex items-center" >
53- < div > < span className = "text-normal font-semibold inline-block py-1 px-2 uppercase rounded-full text-slate-100 bg-indigo-600 mr-3" > < i className = "fa-solid fa-clock" > </ i > </ span > </ div >
54- < div > < h4 className = "text-slate-600 hover:text-indigo-500 font-semibold hover:underline text-normal" > Duration:< span > { course . duration } </ span > </ h4 > </ div > </ div > </ li >
48+ < div > < span className = "text-normal font-normal inline-block py-1 px-2 rounded-full text-slate-100 bg-indigo-600 mr-3" > < i className = "fa-solid fa-clock" > </ i > </ span > </ div >
49+ < div > < h4 className = "text-slate-600 hover:text-indigo-500 font-normal hover:underline text-normal" > Duration:< span > { course . duration } </ span > </ h4 > </ div > </ div > </ li >
5550 < li className = "py-2 flex flex-col" >
5651 < div className = "flex items-center" >
57- < div > < span className = "text-normal font-semibold inline-block py-1 px-2 uppercase rounded-full text-gray-100 bg-indigo-600 mr-3" > < i className = "fa-solid fa-globe" > </ i > </ span > </ div >
58- < div > < h4 className = "text-slate-600 hover:text-indigo-500 font-semibold hover:underline text-normal" > Online:< span > { course . online ? "Yes" : " No" } </ span > </ h4 > </ div > </ div > </ li >
52+ < div > < span className = "text-normal font-normal inline-block py-1 px-2 rounded-full text-gray-100 bg-indigo-600 mr-3" > < i className = "fa-solid fa-globe" > </ i > </ span > </ div >
53+ < div > < h4 className = "text-slate-600 hover:text-indigo-500 font-normal hover:underline text-normal" > Online:< span > { course . online ? "Yes" : " No" } </ span > </ h4 > </ div > </ div > </ li >
5954 < li className = "py-2 flex flex-col" >
6055 < div className = "flex items-center" >
61- < div > < span className = "text-normal font-semibold inline-block py-1 px-2 uppercase rounded-full text-slate-100 bg-indigo-600 mr-3" > < i className = "fa-solid fa-coins" > </ i > </ span > </ div >
62- < div > < h4 className = "text-slate-600 hover:text-indigo-500 font-semibold hover:underline text-normal" > Normal Price:< span > { course . price . normal } </ span > </ h4 > </ div > </ div > </ li >
56+ < div > < span className = "text-normal font-normal inline-block py-1 px-2 rounded-full text-slate-100 bg-indigo-600 mr-3" > < i className = "fa-solid fa-coins" > </ i > </ span > </ div >
57+ < div > < h4 className = "text-slate-600 hover:text-indigo-500 font-normal hover:underline text-normal" > Normal Price:< span > { course . price . normal } </ span > </ h4 > </ div > </ div > </ li >
6358 < li className = "py-2 flex flex-col" >
6459 < div className = "flex items-center" >
65- < div > < span className = "text-normal font-semibold inline-block py-1 px-2 uppercase rounded-full text-slate-100 bg-indigo-600 mr-3" > < i className = "fa-solid fa-gift" > </ i > </ span > </ div >
66- < div > < h4 className = "text-slate-600 hover:text-indigo-500 font-semibold hover:underline text-normal" > Early-bird Price:< span > { course . price . early_bird } </ span > </ h4 > </ div > </ div > </ li >
60+ < div > < span className = "text-normal font-normal inline-block py-1 px-2 rounded-full text-slate-100 bg-indigo-600 mr-3" > < i className = "fa-solid fa-gift" > </ i > </ span > </ div >
61+ < div > < h4 className = "text-slate-600 hover:text-indigo-500 font-normal hover:underline text-normal" > Early-bird Price:< span > { course . price . early_bird } </ span > </ h4 > </ div > </ div > </ li >
6762 </ ul >
6863 < Buttons fetchDetails = { fetchDetails ( ) } data = { course } idNumber = { course . id } />
69-
7064 </ div >
7165 </ div >
7266 </ div >
73-
7467 </ >
7568 ) ;
7669 }
0 commit comments