-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
73 lines (65 loc) · 2.07 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import React, { useState, useEffect } from "react";
import { Card, CardContent, Input } from "@mui/joy";
import axios from "axios";
import _ from "lodash";
import Footer from "./Components/Footer";
import Topbar from "./Components/Topbar";
import ControlCard from "./Components/ControlCard";
function App() {
const titleArray = ["banking", "logistic", "e-commerce", "computer"];
const [searchTerm, setSearchTerm] = useState("");
const [starWarPeople, setStarWarPeople] = useState([]);
useEffect(() => {
axios
.get("https://swapi.dev/api/people/")
.then((res) => {
setStarWarPeople(res?.data?.results);
console.log("People ", res?.data?.results);
})
.catch((error) => {
console.error("Error", error?.message);
});
return () => {};
}, []);
return (
<div>
<Topbar appTitle='IARC Devboard' />{" "}
<div className='container'>
<Card>
<CardContent>
<div>Search Box</div>
<Input
placeholder='Input Some Search Word'
onChange={(e) => setSearchTerm(e.target.value)}
/>
<div>
You Search <span className='text-blue-500'>{searchTerm}</span>
</div>
</CardContent>
</Card>
<div className='text-xl mx-4 my-2'>People in Starwar</div>
<div className='mx-4'>
{_.map(starWarPeople, (eachPeople, index) => (
<Card key={index} className='my-2'>
<CardContent>
<div className='flex'>
<div className='w-1/3'></div>
<div className='w-2/3'>
<li>Name: {eachPeople?.name}</li>
<li>Height: {eachPeople?.height}</li>
<li>Mass: {eachPeople?.mass}</li>
</div>
</div>
</CardContent>
</Card>
))}
</div>
{titleArray.map((titleElement) => (
<ControlCard title={titleElement} />
))}
</div>
<Footer />
</div>
);
}
export default App;