|
1 | | -import { useState, useEffect } from 'react' |
2 | | -import { FaAngleDoubleRight } from 'react-icons/fa' |
3 | | -import './index.css' |
4 | | - |
5 | | -const url = 'https://course-api.com/react-tabs-project' |
| 1 | +import App from './App.js'; |
| 2 | +import './index.scss' |
6 | 3 |
|
7 | 4 | function Index() { |
8 | | - const [loading, setLoading] = useState(true) |
9 | | - const [jobs, setJobs] = useState([]) |
10 | | - const [value, setValue] = useState(0) |
11 | | - |
12 | | - const fetchJobs = async() => { |
13 | | - const newJobs = await fetch(url).then(response => response.json()) |
14 | | - setJobs(newJobs) |
15 | | - setLoading(false) |
16 | | - } |
17 | | - useEffect(() => { |
18 | | - fetchJobs() |
19 | | - }, []) |
20 | | - |
21 | | - if(loading){ |
22 | | - return( |
23 | | - <section className='section loading'> |
24 | | - <h1>Loading...</h1> |
25 | | - </section> |
26 | | - ); |
27 | | - } |
28 | | - |
29 | | - const {company, dates, duties, title} = jobs[value] |
30 | 5 | return ( |
31 | | - <section className='section'> |
32 | | - <div className="title"> |
33 | | - <h2>experience</h2> |
34 | | - <div className="underline"></div> |
35 | | - </div> |
36 | | - <div className="jobs-center"> |
37 | | - <div className="btn-container"> |
38 | | - { |
39 | | - jobs.map((job, index) => { |
40 | | - return ( |
41 | | - <button |
42 | | - key={job.id} |
43 | | - onClick={() => setValue(index)} |
44 | | - className={`job-btn ${index === value && 'active-btn'}`} |
45 | | - > |
46 | | - {job.company} |
47 | | - </button> |
48 | | - ) |
49 | | - }) |
50 | | - } |
51 | | - </div> |
52 | | - <article className="job-info"> |
53 | | - <h3>{title}</h3> |
54 | | - <h4>{company}</h4> |
55 | | - <p className="job-date">{dates}</p> |
56 | | - {duties.map((duty, index) => { |
57 | | - return ( |
58 | | - <div className="job-desc" key={index}> |
59 | | - <FaAngleDoubleRight className="job-icon"> |
60 | | - </FaAngleDoubleRight> |
61 | | - <p>{duty}</p> |
62 | | - </div> |
63 | | - ) |
64 | | - }) |
65 | | - } |
66 | | - </article> |
67 | | - </div> |
68 | | - <button type="button" className="btn"> |
69 | | - More info |
70 | | - </button> |
71 | | - |
72 | | - </section> |
| 6 | + <div className="tabs"> |
| 7 | + <App/> |
| 8 | + </div> |
73 | 9 | ) |
74 | 10 | } |
75 | 11 |
|
|
0 commit comments