Compare commits
1 commit
main
...
Devlopment
Author | SHA1 | Date | |
---|---|---|---|
![]() |
a42c9f5875 |
71
README.md
71
README.md
|
@ -1,70 +1,3 @@
|
||||||
# Getting Started with Create React App
|
# Assigment4
|
||||||
|
|
||||||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
Random User Directory
|
||||||
|
|
||||||
## Available Scripts
|
|
||||||
|
|
||||||
In the project directory, you can run:
|
|
||||||
|
|
||||||
### `npm start`
|
|
||||||
|
|
||||||
Runs the app in the development mode.\
|
|
||||||
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
|
|
||||||
|
|
||||||
The page will reload when you make changes.\
|
|
||||||
You may also see any lint errors in the console.
|
|
||||||
|
|
||||||
### `npm test`
|
|
||||||
|
|
||||||
Launches the test runner in the interactive watch mode.\
|
|
||||||
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
|
|
||||||
|
|
||||||
### `npm run build`
|
|
||||||
|
|
||||||
Builds the app for production to the `build` folder.\
|
|
||||||
It correctly bundles React in production mode and optimizes the build for the best performance.
|
|
||||||
|
|
||||||
The build is minified and the filenames include the hashes.\
|
|
||||||
Your app is ready to be deployed!
|
|
||||||
|
|
||||||
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
|
||||||
|
|
||||||
### `npm run eject`
|
|
||||||
|
|
||||||
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
|
|
||||||
|
|
||||||
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
|
|
||||||
|
|
||||||
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
|
|
||||||
|
|
||||||
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
|
|
||||||
|
|
||||||
## Learn More
|
|
||||||
|
|
||||||
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
|
|
||||||
|
|
||||||
To learn React, check out the [React documentation](https://reactjs.org/).
|
|
||||||
|
|
||||||
### Code Splitting
|
|
||||||
|
|
||||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
|
|
||||||
|
|
||||||
### Analyzing the Bundle Size
|
|
||||||
|
|
||||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
|
|
||||||
|
|
||||||
### Making a Progressive Web App
|
|
||||||
|
|
||||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
|
|
||||||
|
|
||||||
### Advanced Configuration
|
|
||||||
|
|
||||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
|
|
||||||
|
|
||||||
### Deployment
|
|
||||||
|
|
||||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
|
|
||||||
|
|
||||||
### `npm run build` fails to minify
|
|
||||||
|
|
||||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
|
|
506
src/App.css
506
src/App.css
|
@ -1,256 +1,250 @@
|
||||||
/* Global Styles */
|
/* Global Styles */
|
||||||
body {
|
body {
|
||||||
font-family: 'Arial', sans-serif;
|
font-family: 'Arial', sans-serif;
|
||||||
background-color: #f4f7fc;
|
background-color: #f4f7fc;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
line-height: 1.6;
|
}
|
||||||
}
|
|
||||||
|
.App {
|
||||||
.App {
|
text-align: center;
|
||||||
text-align: center;
|
}
|
||||||
}
|
|
||||||
|
/* Header */
|
||||||
/* Header */
|
.App-header {
|
||||||
.App-header {
|
background-color: #282c34;
|
||||||
background-color: #282c34;
|
padding: 40px 20px;
|
||||||
padding: 40px 20px;
|
color: white;
|
||||||
color: white;
|
border-bottom: 4px solid #0056b3;
|
||||||
border-bottom: 4px solid #0056b3;
|
}
|
||||||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
|
|
||||||
}
|
.App-header h1 {
|
||||||
|
font-size: 2.5rem;
|
||||||
.App-header h1 {
|
letter-spacing: 2px;
|
||||||
font-size: 2.5rem;
|
margin: 0;
|
||||||
letter-spacing: 2px;
|
text-transform: uppercase;
|
||||||
margin: 0;
|
}
|
||||||
text-transform: uppercase;
|
|
||||||
}
|
/* Search and Filter Section */
|
||||||
|
.search-filter-container {
|
||||||
/* Search and Filter Section */
|
display: flex;
|
||||||
.search-filter-container {
|
justify-content: center;
|
||||||
display: flex;
|
align-items: center;
|
||||||
justify-content: center;
|
gap: 15px;
|
||||||
align-items: center;
|
margin: 30px 0;
|
||||||
gap: 15px;
|
flex-wrap: wrap;
|
||||||
margin: 30px 0;
|
padding: 0 20px;
|
||||||
flex-wrap: wrap;
|
}
|
||||||
padding: 0 20px;
|
|
||||||
}
|
.search-filter-container input,
|
||||||
|
.search-filter-container select,
|
||||||
.search-filter-container input,
|
.sort-options select {
|
||||||
.search-filter-container select,
|
padding: 12px;
|
||||||
.sort-options select {
|
font-size: 16px;
|
||||||
padding: 12px;
|
border-radius: 8px;
|
||||||
font-size: 16px;
|
border: 1px solid #ccc;
|
||||||
border-radius: 8px;
|
width: 200px;
|
||||||
border: 1px solid #ccc;
|
box-sizing: border-box;
|
||||||
width: 200px;
|
transition: border-color 0.3s ease, background-color 0.3s ease;
|
||||||
box-sizing: border-box;
|
}
|
||||||
transition: border-color 0.3s ease, background-color 0.3s ease;
|
|
||||||
}
|
.search-filter-container input:focus,
|
||||||
|
.search-filter-container select:focus,
|
||||||
.search-filter-container input:focus,
|
.sort-options select:focus{
|
||||||
.search-filter-container select:focus,
|
border-color: #007bff;
|
||||||
.sort-options select:focus {
|
outline: none;
|
||||||
border-color: #007bff;
|
}
|
||||||
outline: none;
|
|
||||||
background-color: #e9f5ff;
|
/* User Grid Styles */
|
||||||
}
|
.user-grid {
|
||||||
|
display: grid;
|
||||||
/* User Grid Styles */
|
grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
|
||||||
.user-grid {
|
gap: 20px;
|
||||||
display: grid;
|
padding: 0 20px;
|
||||||
grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
|
margin-top: 30px;
|
||||||
gap: 20px;
|
transition: all 0.3s ease;
|
||||||
padding: 0 20px;
|
}
|
||||||
margin-top: 30px;
|
|
||||||
transition: all 0.3s ease;
|
.user-card {
|
||||||
}
|
background-color: #fff;
|
||||||
|
border-radius: 12px;
|
||||||
.user-card {
|
padding: 15px;
|
||||||
background-color: #fff;
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||||
border-radius: 12px;
|
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
||||||
padding: 15px;
|
cursor: pointer;
|
||||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
text-align: center;
|
||||||
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
}
|
||||||
cursor: pointer;
|
|
||||||
text-align: center;
|
.user-card:hover {
|
||||||
}
|
transform: translateY(-5px);
|
||||||
|
box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
|
||||||
.user-card:hover {
|
}
|
||||||
transform: translateY(-5px);
|
|
||||||
box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
|
.user-card img {
|
||||||
}
|
width: 100px;
|
||||||
|
height: 100px;
|
||||||
.user-card img {
|
border-radius: 50%;
|
||||||
width: 100px;
|
margin-bottom: 10px;
|
||||||
height: 100px;
|
object-fit: cover;
|
||||||
border-radius: 50%;
|
}
|
||||||
margin-bottom: 10px;
|
|
||||||
object-fit: cover;
|
.user-info h3 {
|
||||||
}
|
font-size: 1.2rem;
|
||||||
|
color: #333;
|
||||||
.user-info h3 {
|
margin: 10px 0;
|
||||||
font-size: 1.2rem;
|
}
|
||||||
color: #333;
|
|
||||||
margin: 10px 0;
|
.user-info p {
|
||||||
}
|
color: #555;
|
||||||
|
font-size: 14px;
|
||||||
.user-info p {
|
margin-bottom: 15px;
|
||||||
color: #555;
|
}
|
||||||
font-size: 14px;
|
|
||||||
margin-bottom: 15px;
|
/* View Details Button */
|
||||||
}
|
.view-details-btn {
|
||||||
|
background-color: #007bff;
|
||||||
/* View Details Button */
|
color: white;
|
||||||
.view-details-btn {
|
padding: 10px 20px;
|
||||||
background-color: #007bff;
|
text-decoration: none;
|
||||||
color: white;
|
border-radius: 25px;
|
||||||
padding: 10px 20px;
|
font-weight: bold;
|
||||||
text-decoration: none;
|
display: inline-block;
|
||||||
border-radius: 25px;
|
transition: background-color 0.3s ease;
|
||||||
font-weight: bold;
|
}
|
||||||
display: inline-block;
|
|
||||||
transition: background-color 0.3s ease, transform 0.2s ease;
|
.view-details-btn:hover {
|
||||||
}
|
background-color: #0056b3;
|
||||||
|
}
|
||||||
.view-details-btn:hover {
|
|
||||||
background-color: #0056b3;
|
/* Pagination Styles */
|
||||||
transform: translateY(-2px);
|
.pagination {
|
||||||
}
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
/* Pagination Styles */
|
gap: 15px;
|
||||||
.pagination {
|
margin-top: 30px;
|
||||||
display: flex;
|
}
|
||||||
justify-content: center;
|
|
||||||
gap: 15px;
|
.pagination button {
|
||||||
margin-top: 30px;
|
padding: 10px 20px;
|
||||||
}
|
background-color: #fff;
|
||||||
|
border: 1px solid #ddd;
|
||||||
.pagination button {
|
border-radius: 25px;
|
||||||
padding: 10px 20px;
|
cursor: pointer;
|
||||||
background-color: #fff;
|
color: #333;
|
||||||
border: 1px solid #ddd;
|
font-size: 14px;
|
||||||
border-radius: 25px;
|
font-weight: bold;
|
||||||
cursor: pointer;
|
transition: background-color 0.3s ease, transform 0.2s ease;
|
||||||
color: #333;
|
}
|
||||||
font-size: 14px;
|
|
||||||
font-weight: bold;
|
.pagination button:hover {
|
||||||
transition: background-color 0.3s ease, transform 0.2s ease;
|
background-color: #007bff;
|
||||||
}
|
color: white;
|
||||||
|
transform: translateY(-3px);
|
||||||
.pagination button:hover {
|
}
|
||||||
background-color: #007bff;
|
|
||||||
color: white;
|
.pagination button.active {
|
||||||
transform: translateY(-3px);
|
background-color: #4caf50;
|
||||||
}
|
color: white;
|
||||||
|
}
|
||||||
.pagination button.active {
|
|
||||||
background-color: #4caf50;
|
.pagination button:disabled {
|
||||||
color: white;
|
background-color: #ccc;
|
||||||
}
|
cursor: not-allowed;
|
||||||
|
color: #fff;
|
||||||
.pagination button:disabled {
|
}
|
||||||
background-color: #ccc;
|
|
||||||
cursor: not-allowed;
|
/* User Details Page Styles */
|
||||||
color: #fff;
|
.user-details {
|
||||||
}
|
max-width: 900px;
|
||||||
|
margin: 40px auto;
|
||||||
/* User Details Page Styles */
|
padding: 20px;
|
||||||
.user-details {
|
background-color: #fff;
|
||||||
max-width: 900px;
|
border-radius: 12px;
|
||||||
margin: 40px auto;
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||||
padding: 20px;
|
top: 160px;
|
||||||
background-color: #fff;
|
width: 100%;
|
||||||
border-radius: 12px;
|
}
|
||||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
|
||||||
top: 160px;
|
.user-details h2 {
|
||||||
width: 100%;
|
text-align: center;
|
||||||
}
|
color: #333;
|
||||||
|
font-size: 2rem;
|
||||||
.user-details h2 {
|
margin-bottom: 30px;
|
||||||
text-align: center;
|
}
|
||||||
color: #333;
|
|
||||||
font-size: 2rem;
|
.user-image {
|
||||||
margin-bottom: 30px;
|
display: block;
|
||||||
}
|
margin: 0 auto 20px;
|
||||||
|
border-radius: 50%;
|
||||||
.user-image {
|
width: 150px;
|
||||||
display: block;
|
height: 150px;
|
||||||
margin: 0 auto 20px;
|
object-fit: cover;
|
||||||
border-radius: 50%;
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
||||||
width: 150px;
|
}
|
||||||
height: 150px;
|
|
||||||
object-fit: cover;
|
.user-info {
|
||||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
font-size: 16px;
|
||||||
}
|
color: #555;
|
||||||
|
line-height: 1.6;
|
||||||
.user-info {
|
}
|
||||||
font-size: 16px;
|
|
||||||
color: #555;
|
.user-info div {
|
||||||
line-height: 1.6;
|
margin-bottom: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.user-info div {
|
.user-info strong {
|
||||||
margin-bottom: 15px;
|
font-weight: bold;
|
||||||
}
|
color: #333;
|
||||||
|
}
|
||||||
.user-info strong {
|
|
||||||
font-weight: bold;
|
/* Back to User List Button */
|
||||||
color: #333;
|
.back-btn ,.export-btn{
|
||||||
}
|
display: inline-block;
|
||||||
|
|
||||||
/* Back to User List Button */
|
margin-top: 30px;
|
||||||
.back-btn,
|
text-decoration: none;
|
||||||
.export-btn {
|
background-color: #4CAF50;
|
||||||
display: inline-block;
|
color: #fff;
|
||||||
margin-top: 30px;
|
padding: 12px 20px;
|
||||||
text-decoration: none;
|
border-radius: 30px;
|
||||||
background-color: #4CAF50;
|
font-size: 16px;
|
||||||
color: #fff;
|
text-align: center;
|
||||||
padding: 12px 20px;
|
transition: background-color 0.3s ease;
|
||||||
border-radius: 30px;
|
border-width: 0;
|
||||||
font-size: 16px;
|
}
|
||||||
text-align: center;
|
|
||||||
transition: background-color 0.3s ease, transform 0.2s ease;
|
.back-btn:hover,.export-btn:hover {
|
||||||
border-width: 0;
|
background-color: #45a049;
|
||||||
}
|
}
|
||||||
|
|
||||||
.back-btn:hover,
|
|
||||||
.export-btn:hover {
|
.view-detail
|
||||||
background-color: #45a049;
|
{
|
||||||
transform: translateY(-2px);
|
background-color: #007bff;
|
||||||
}
|
width: 120px;
|
||||||
|
margin-left: 50px;
|
||||||
/* Enhanced Buttons */
|
padding: 8px 20px;
|
||||||
.view-detail {
|
border-radius: 40px;
|
||||||
background-color: #007bff;
|
}
|
||||||
width: 120px;
|
.view-detail:hover
|
||||||
margin-left: 50px;
|
{
|
||||||
padding: 8px 20px;
|
color: #fdfbfb;
|
||||||
border-radius: 40px;
|
background-color: #0056b3;
|
||||||
transition: background-color 0.3s ease, transform 0.2s ease;
|
}
|
||||||
}
|
|
||||||
|
.hero-section button{
|
||||||
.view-detail:hover {
|
background-color: #6aabf1;
|
||||||
color: #fdfbfb;
|
width: 120px;
|
||||||
background-color: #0056b3;
|
margin-left: 50px;
|
||||||
transform: translateY(-2px);
|
padding: 8px 20px;
|
||||||
}
|
border-radius: 40px;
|
||||||
|
border-width: 0;
|
||||||
.hero-section button {
|
}
|
||||||
background-color: #6aabf1;
|
.hero-section button:hover
|
||||||
width: 120px;
|
{
|
||||||
margin-left: 50px;
|
color: #fdfbfb;
|
||||||
padding: 8px 20px;
|
background-color: #0056b3;
|
||||||
border-radius: 40px;
|
transform: translateY(-3px);
|
||||||
border-width: 0;
|
}
|
||||||
transition: background-color 0.3s ease, transform 0.2s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hero-section button:hover {
|
|
||||||
color: #fdfbfb;
|
|
||||||
background-color: #0056b3;
|
|
||||||
transform: translateY(-3px);
|
|
||||||
}
|
|
||||||
|
|
67
src/App.js
67
src/App.js
|
@ -1,37 +1,30 @@
|
||||||
// src/App.js
|
// src/App.js
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { BrowserRouter as Router, Routes, Route,useNavigate } from 'react-router-dom';
|
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
|
||||||
import './App.css';
|
import './App.css';
|
||||||
import Home from './Home'; // Import the Home component
|
import Home from './Home'; // Import the Home component
|
||||||
import UserDetails from './UserDetail';
|
import UserDetails from './UserDetail';
|
||||||
|
|
||||||
const Header = () =>{
|
function App() {
|
||||||
const navigate = useNavigate();
|
return (
|
||||||
return (
|
<Router>
|
||||||
<header className="App-header">
|
<div className="App">
|
||||||
<h1>Random Users</h1>
|
<header className="App-header">
|
||||||
<p>Explore a diverse set of random users from all over the world!</p>
|
<h1>Random Users</h1>
|
||||||
<div className="hero-section">
|
<p>Explore a diverse set of random users from all over the world!</p>
|
||||||
<button onClick={() => navigate('/home')}>View Users</button>
|
<div className="hero-section">
|
||||||
</div>
|
<button onClick={() => window.location.href = '/home'}>View Users</button>
|
||||||
</header>
|
</div>
|
||||||
);
|
</header>
|
||||||
}
|
|
||||||
|
<Routes>
|
||||||
function App() {
|
<Route path="/" element={<div>Landing Page</div>} />
|
||||||
return (
|
<Route path="/home" element={<Home />} />
|
||||||
<Router>
|
<Route path="/user-details" element={<UserDetails />} />
|
||||||
<div className="App">
|
</Routes>
|
||||||
<Header/>
|
</div>
|
||||||
|
</Router>
|
||||||
<Routes>
|
);
|
||||||
<Route path="/" element={<div>Landing Page</div>} />
|
}
|
||||||
<Route path="/home" element={<Home />} />
|
|
||||||
<Route path="/user-details/:username" element={<UserDetails />} />
|
export default App;
|
||||||
</Routes>
|
|
||||||
</div>
|
|
||||||
</Router>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default App;
|
|
||||||
|
|
336
src/Home.js
336
src/Home.js
|
@ -1,169 +1,167 @@
|
||||||
// src/Home.js
|
// src/Home.js
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import UserCard from './UserCard';
|
import UserCard from './UserCard';
|
||||||
import SearchFilter from './SearchFilter';
|
import SearchFilter from './SearchFilter';
|
||||||
|
|
||||||
function Home() {
|
function Home() {
|
||||||
const [data, setData] = useState([]);
|
const [data, setData] = useState([]);
|
||||||
const [filteredData, setFilteredData] = useState([]);
|
const [filteredData, setFilteredData] = useState([]);
|
||||||
const [currentPage, setCurrentPage] = useState(1);
|
const [currentPage, setCurrentPage] = useState(1);
|
||||||
const [searchQuery, setSearchQuery] = useState('');
|
const [searchQuery, setSearchQuery] = useState('');
|
||||||
const [selectedGender, setSelectedGender] = useState('');
|
const [selectedGender, setSelectedGender] = useState('');
|
||||||
const [selectedAgeRange, setSelectedAgeRange] = useState('');
|
const [selectedAgeRange, setSelectedAgeRange] = useState('');
|
||||||
const [selectedNationality, setSelectedNationality] = useState('');
|
const [selectedNationality, setSelectedNationality] = useState('');
|
||||||
const [sortBy, setSortBy] = useState('name'); // Default sort by name
|
const [sortBy, setSortBy] = useState('name'); // Default sort by name
|
||||||
const [sortOrder, setSortOrder] = useState('asc'); // Default sort order: ascending
|
const [sortOrder, setSortOrder] = useState('asc'); // Default sort order: ascending
|
||||||
const [error, setError] = useState(null); // State to hold error messages
|
const [setUserDetail] = useState(null);
|
||||||
const usersPerPage = 12;
|
const usersPerPage = 12;
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
// Fetch data from the API
|
// Fetch data from the API
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchData = async () => {
|
fetch('https://randomuser.me/api/?results=200')
|
||||||
try {
|
.then(response => response.json())
|
||||||
const response = await fetch('https://randomuser.me/api/?results=200');
|
.then(data => {
|
||||||
if (!response.ok) {
|
setData(data.results);
|
||||||
throw new Error('Network response was not ok');
|
setFilteredData(data.results); // Set initial filtered data as the full list
|
||||||
}
|
});
|
||||||
const result = await response.json();
|
}, []);
|
||||||
setData(result.results);
|
|
||||||
setFilteredData(result.results); // Set initial filtered data as the full list
|
// Filter users based on search query and selected filters
|
||||||
} catch (error) {
|
useEffect(() => {
|
||||||
setError(error.message); // Set the error message
|
let filtered = data;
|
||||||
}
|
|
||||||
};
|
// Search by name, email, or location
|
||||||
|
if (searchQuery) {
|
||||||
fetchData();
|
filtered = filtered.filter(user =>
|
||||||
}, []);
|
user.name.first.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
||||||
|
user.name.last.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
||||||
// Filter users based on search query and selected filters
|
user.email.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
||||||
useEffect(() => {
|
`${user.location.city} ${user.location.country}`.toLowerCase().includes(searchQuery.toLowerCase())
|
||||||
let filtered = data;
|
);
|
||||||
|
}
|
||||||
// Search by name, email, or location
|
|
||||||
if (searchQuery) {
|
// Filter by gender
|
||||||
filtered = filtered.filter(user =>
|
if (selectedGender) {
|
||||||
user.name?.first?.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
filtered = filtered.filter(user => user.gender === selectedGender);
|
||||||
user.name?.last?.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
}
|
||||||
user.email?.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
|
||||||
`${user.location?.city} ${user.location?.country}`.toLowerCase().includes(searchQuery.toLowerCase())
|
// Filter by age range
|
||||||
);
|
if (selectedAgeRange) {
|
||||||
}
|
const [minAge, maxAge] = selectedAgeRange.split('-').map(Number);
|
||||||
|
filtered = filtered.filter(user => {
|
||||||
// Filter by gender
|
const userAge = new Date().getFullYear() - new Date(user.dob.date).getFullYear();
|
||||||
if (selectedGender) {
|
return userAge >= minAge && userAge <= maxAge;
|
||||||
filtered = filtered.filter(user => user.gender === selectedGender);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter by age range
|
// Filter by nationality
|
||||||
if (selectedAgeRange) {
|
if (selectedNationality) {
|
||||||
const [minAge, maxAge] = selectedAgeRange.split('-').map(Number);
|
filtered = filtered.filter(user => user.nat === selectedNationality);
|
||||||
filtered = filtered.filter(user => {
|
}
|
||||||
const userAge = new Date().getFullYear() - new Date(user.dob?.date).getFullYear();
|
|
||||||
return userAge >= minAge && userAge <= maxAge;
|
// Sorting logic
|
||||||
});
|
if (sortBy === 'name') {
|
||||||
}
|
filtered = filtered.sort((a, b) => {
|
||||||
|
const nameA = `${a.name.first} ${a.name.last}`.toLowerCase();
|
||||||
// Filter by nationality
|
const nameB = `${b.name.first} ${b.name.last}`.toLowerCase();
|
||||||
if (selectedNationality) {
|
if (sortOrder === 'asc') {
|
||||||
filtered = filtered.filter(user => user.nat === selectedNationality);
|
return nameA.localeCompare(nameB);
|
||||||
}
|
} else {
|
||||||
|
return nameB.localeCompare(nameA);
|
||||||
// Sorting logic
|
}
|
||||||
// Sorting logic
|
});
|
||||||
if (sortBy === 'name') {
|
} else if (sortBy === 'age') {
|
||||||
filtered = filtered.sort((personA, personB) => {
|
filtered = filtered.sort((a, b) => {
|
||||||
const fullNameA = `${personA.name?.first} ${personA.name?.last}`.toLowerCase();
|
const ageA = new Date().getFullYear() - new Date(a.dob.date).getFullYear();
|
||||||
const fullNameB = `${personB.name?.first} ${personB.name?.last}`.toLowerCase();
|
const ageB = new Date().getFullYear() - new Date(b.dob.date).getFullYear();
|
||||||
return sortOrder === 'asc' ? fullNameA.localeCompare(fullNameB) : fullNameB.localeCompare(fullNameA);
|
if (sortOrder === 'asc') {
|
||||||
});
|
return ageA - ageB;
|
||||||
} else if (sortBy === 'age') {
|
} else {
|
||||||
filtered = filtered.sort((personA, personB) => {
|
return ageB - ageA;
|
||||||
const currentYear = new Date().getFullYear();
|
}
|
||||||
const ageA = currentYear - new Date(personA.dob?.date).getFullYear();
|
});
|
||||||
const ageB = currentYear - new Date(personB.dob?.date).getFullYear();
|
}
|
||||||
return sortOrder === 'asc' ? ageA - ageB : ageB - ageA;
|
|
||||||
});
|
setFilteredData(filtered);
|
||||||
}
|
setCurrentPage(1); // Reset to first page whenever filters or sorting change
|
||||||
|
}, [searchQuery, selectedGender, selectedAgeRange, selectedNationality, sortBy, sortOrder, data]);
|
||||||
setFilteredData(filtered);
|
|
||||||
setCurrentPage(1); // Reset to first page whenever filters or sorting change
|
// Pagination logic
|
||||||
}, [searchQuery, selectedGender, selectedAgeRange, selectedNationality, sortBy, sortOrder, data]);
|
const indexOfLastUser = currentPage * usersPerPage;
|
||||||
|
const currentUsers = filteredData.slice(indexOfLastUser - usersPerPage, indexOfLastUser);
|
||||||
// Pagination logic
|
const totalPages = Math.ceil(filteredData.length / usersPerPage);
|
||||||
const indexOfLastUser = currentPage * usersPerPage;
|
|
||||||
const currentUsers = filteredData.slice(indexOfLastUser - usersPerPage, indexOfLastUser);
|
const pageNumbers = [];
|
||||||
const totalPages = Math.ceil(filteredData.length / usersPerPage);
|
const maxPageRange = 2;
|
||||||
|
|
||||||
const pageNumbers = [];
|
for (let i = 1; i <= totalPages; i++) {
|
||||||
const maxPageRange = 2;
|
if (i <= 2 || i > totalPages - 2 || (i >= currentPage - maxPageRange && i <= currentPage + maxPageRange)) {
|
||||||
|
pageNumbers.push(i);
|
||||||
for (let i = 1; i <= totalPages; i++) {
|
} else if (pageNumbers[pageNumbers.length - 1] !== '...') {
|
||||||
if (i <= 2 || i > totalPages - 2 || (i >= currentPage - maxPageRange && i <= currentPage + maxPageRange)) {
|
pageNumbers.push('...');
|
||||||
pageNumbers.push(i);
|
}
|
||||||
} else if (pageNumbers[pageNumbers.length - 1] !== '...') {
|
}
|
||||||
pageNumbers.push('...');
|
|
||||||
}
|
// Function to handle clicking on More Info
|
||||||
}
|
const handleMoreInfo = (user) => {
|
||||||
|
setUserDetail(user);
|
||||||
// Function to handle clicking on More Info
|
navigate(`/user-details`);
|
||||||
const handleMoreInfo = (user) => {
|
};
|
||||||
navigate(`/user-details`,{state:{user}});
|
|
||||||
};
|
return (
|
||||||
|
<div className="Home">
|
||||||
return (
|
<SearchFilter
|
||||||
<div className="Home">
|
searchQuery={searchQuery}
|
||||||
{error && <div className="error">Error: {error}</div>} {/* Display error message if exists */}
|
setSearchQuery={setSearchQuery}
|
||||||
<SearchFilter
|
selectedGender={selectedGender}
|
||||||
searchQuery={searchQuery}
|
setSelectedGender={setSelectedGender}
|
||||||
setSearchQuery={setSearchQuery}
|
selectedAgeRange={selectedAgeRange}
|
||||||
selectedGender={selectedGender}
|
setSelectedAgeRange={setSelectedAgeRange}
|
||||||
setSelectedGender={setSelectedGender}
|
selectedNationality={selectedNationality}
|
||||||
selectedAgeRange={selectedAgeRange}
|
setSelectedNationality={setSelectedNationality}
|
||||||
setSelectedAgeRange={setSelectedAgeRange}
|
/>
|
||||||
selectedNationality={selectedNationality}
|
|
||||||
setSelectedNationality={setSelectedNationality}
|
{/* Sort Options UI */}
|
||||||
/>
|
<div className="sort-options">
|
||||||
|
<select onChange={(e) => setSortBy(e.target.value)} value={sortBy}>
|
||||||
{/* Sort Options UI */}
|
<option value="name">Sort by Name</option>
|
||||||
<div className="sort-options">
|
<option value="age">Sort by Age</option>
|
||||||
<select onChange={(e) => setSortBy(e.target.value)} value={sortBy}>
|
</select>
|
||||||
<option value="name">Sort by Name</option>
|
<select onChange={(e) => setSortOrder(e.target.value)} value={sortOrder}>
|
||||||
<option value="age">Sort by Age</option>
|
<option value="asc">Ascending</option>
|
||||||
</select>
|
<option value="desc">Descending</option>
|
||||||
<select onChange={(e) => setSortOrder(e.target.value)} value={sortOrder}>
|
</select>
|
||||||
<option value="asc">Ascending</option>
|
</div>
|
||||||
<option value="desc">Descending</option>
|
|
||||||
</select>
|
{filteredData.length > 0 ? (
|
||||||
</div>
|
<>
|
||||||
|
<div className="user-grid">
|
||||||
{filteredData.length > 0 ? (
|
{currentUsers.map(user => (
|
||||||
<>
|
<UserCard key={user.email} user={user} handleMoreInfo={handleMoreInfo} />
|
||||||
<div className="user-grid">
|
))}
|
||||||
{currentUsers.map(user => (
|
</div>
|
||||||
<UserCard key={user.email} user={user} handleMoreInfo={handleMoreInfo} />
|
<div className="pagination">
|
||||||
))}
|
<button onClick={() => setCurrentPage(prev => Math.max(prev - 1, 1))} disabled={currentPage === 1}>Prev</button>
|
||||||
</div>
|
{pageNumbers.map((number, index) => (
|
||||||
<div className="pagination">
|
<button
|
||||||
<button onClick={() => setCurrentPage(prev => Math.max(prev - 1, 1))} disabled={currentPage === 1}>Prev</button>
|
key={index}
|
||||||
{pageNumbers.map((number, index) => (
|
onClick={() => number !== '...' && setCurrentPage(number)}
|
||||||
<button
|
className={currentPage === number ? 'active' : ''}
|
||||||
key={index}
|
disabled={number === '...'}
|
||||||
onClick={() => number !== '...' && setCurrentPage(number)}
|
>
|
||||||
className={currentPage === number ? 'active' : ''}
|
{number}
|
||||||
disabled={number === '...'}
|
</button>
|
||||||
>
|
))}
|
||||||
{number}
|
<button onClick={() => setCurrentPage(prev => Math.min(prev + 1, totalPages))} disabled={currentPage === totalPages}>Next</button>
|
||||||
</button>
|
</div>
|
||||||
))}
|
</>
|
||||||
<button onClick={() => setCurrentPage(prev => Math.min(prev + 1, totalPages))} disabled={currentPage === totalPages}>Next</button>
|
) : (
|
||||||
</div>
|
<p>Loading...</p>
|
||||||
</>
|
)}
|
||||||
) : (
|
</div>
|
||||||
<p>Loading...</p>
|
);
|
||||||
)}
|
}
|
||||||
</div>
|
|
||||||
);
|
export default Home;
|
||||||
}
|
|
||||||
export default Home;
|
|
||||||
|
|
|
@ -1,37 +1,37 @@
|
||||||
// src/SearchFilter.js
|
// src/SearchFilter.js
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
const SearchFilter = ({ searchQuery, setSearchQuery, selectedGender, setSelectedGender, selectedAgeRange, setSelectedAgeRange, selectedNationality, setSelectedNationality }) => {
|
const SearchFilter = ({ searchQuery, setSearchQuery, selectedGender, setSelectedGender, selectedAgeRange, setSelectedAgeRange, selectedNationality, setSelectedNationality }) => {
|
||||||
return (
|
return (
|
||||||
<div className="search-filter-container">
|
<div className="search-filter-container">
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Search by name, email, or location"
|
placeholder="Search by name, email, or location"
|
||||||
value={searchQuery}
|
value={searchQuery}
|
||||||
onChange={(e) => setSearchQuery(e.target.value)}
|
onChange={(e) => setSearchQuery(e.target.value)}
|
||||||
/>
|
/>
|
||||||
<select value={selectedGender} onChange={(e) => setSelectedGender(e.target.value)}>
|
<select value={selectedGender} onChange={(e) => setSelectedGender(e.target.value)}>
|
||||||
<option value="">All Genders</option>
|
<option value="">All Genders</option>
|
||||||
<option value="male">Male</option>
|
<option value="male">Male</option>
|
||||||
<option value="female">Female</option>
|
<option value="female">Female</option>
|
||||||
</select>
|
</select>
|
||||||
<select value={selectedAgeRange} onChange={(e) => setSelectedAgeRange(e.target.value)}>
|
<select value={selectedAgeRange} onChange={(e) => setSelectedAgeRange(e.target.value)}>
|
||||||
<option value="">All Ages</option>
|
<option value="">All Ages</option>
|
||||||
<option value="18-30">18-30</option>
|
<option value="18-30">18-30</option>
|
||||||
<option value="31-45">31-45</option>
|
<option value="31-45">31-45</option>
|
||||||
<option value="46-60">46-60</option>
|
<option value="46-60">46-60</option>
|
||||||
<option value="61+">61+</option>
|
<option value="61+">61+</option>
|
||||||
</select>
|
</select>
|
||||||
<select value={selectedNationality} onChange={(e) => setSelectedNationality(e.target.value)}>
|
<select value={selectedNationality} onChange={(e) => setSelectedNationality(e.target.value)}>
|
||||||
<option value="">All Nationalities</option>
|
<option value="">All Nationalities</option>
|
||||||
<option value="US">US</option>
|
<option value="US">US</option>
|
||||||
<option value="GB">GB</option>
|
<option value="GB">GB</option>
|
||||||
<option value="IN">IN</option>
|
<option value="IN">IN</option>
|
||||||
<option value="CA">CA</option>
|
<option value="CA">CA</option>
|
||||||
{/* Add more nationality options as needed */}
|
{/* Add more nationality options as needed */}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default SearchFilter;
|
export default SearchFilter;
|
||||||
|
|
|
@ -1,27 +1,28 @@
|
||||||
import React from 'react';
|
// src/UserCard.js
|
||||||
import { useNavigate } from 'react-router-dom';
|
import React from 'react';
|
||||||
|
import { useNavigate } from 'react-router-dom';
|
||||||
const UserCard = ({ user }) => {
|
|
||||||
const navigate = useNavigate();
|
const UserCard = ({ user }) => {
|
||||||
console.log('usersss', user);
|
const navigate = useNavigate();
|
||||||
|
console.log('usersss', user)
|
||||||
const onClickHandler = () => {
|
|
||||||
// Navigate to UserDetails with username in the URL
|
const onClickHandler = () => {
|
||||||
navigate(`/user-details/${user.login.username}`, { state: user });
|
navigate(`/user-details`, { state: user});
|
||||||
};
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="user-card" key={user.email}>
|
<div className="user-card" key={user.email}>
|
||||||
<img src={user.picture.medium} alt={user.name.first} />
|
<img src={user.picture.medium} alt={user.name.first} />
|
||||||
<div className="user-info">
|
<div className="user-info">
|
||||||
<h3>{user.name.first} {user.name.last}</h3>
|
<h3>{user.name.first} {user.name.last}</h3>
|
||||||
<p>{user.email}</p>
|
<p>{user.email}</p>
|
||||||
<p className='view-detail' onClick={onClickHandler}>
|
{/* Link to the UserDetails page, passing the user data via state */}
|
||||||
View Details
|
<p className='view-detail' onClick={() => onClickHandler()}>
|
||||||
</p>
|
View Details
|
||||||
</div>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
);
|
</div>
|
||||||
};
|
);
|
||||||
|
};
|
||||||
export default UserCard;
|
|
||||||
|
export default UserCard;
|
||||||
|
|
|
@ -1,73 +1,84 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { useLocation, Link } from 'react-router-dom';
|
import { useLocation, Link } from 'react-router-dom'; // useLocation to access state passed through the router
|
||||||
import './App.css';
|
import './App.css'; // Import the CSS for styling
|
||||||
|
|
||||||
const UserDetails = () => {
|
const UserDetails = () => {
|
||||||
const location = useLocation();
|
// Use useLocation to access the user data passed from UserCard
|
||||||
if (!location.state) {
|
const location = useLocation();
|
||||||
return <p>No user data available!</p>;
|
if (!location.state) {
|
||||||
}
|
return <p>No user data available!</p>;
|
||||||
|
}
|
||||||
const user = location.state;
|
|
||||||
const userLocation = user.location || {};
|
const user = location.state;
|
||||||
const userName = user.name || {};
|
|
||||||
|
// Function to export user data to CSV
|
||||||
const exportToCSV = () => {
|
const exportToCSV = () => {
|
||||||
const userData = [
|
// Create a CSV string with the user details
|
||||||
['First Name', 'Last Name', 'Email', 'Phone', 'Cell', 'Address', 'Date of Birth', 'Nationality', 'Timezone', 'Coordinates', 'Username'],
|
const userData = [
|
||||||
[
|
['First Name', 'Last Name', 'Email', 'Phone', 'Cell', 'Address', 'Date of Birth', 'Nationality', 'Timezone', 'Coordinates', 'Username'],
|
||||||
userName.first || 'N/A',
|
[
|
||||||
userName.last || 'N/A',
|
user.name.first,
|
||||||
user.email || 'N/A',
|
user.name.last,
|
||||||
user.phone || 'N/A',
|
user.email,
|
||||||
user.cell || 'N/A',
|
user.phone,
|
||||||
`${userLocation.street?.number || ''} ${userLocation.street?.name || ''}, ${userLocation.city || 'N/A'}, ${userLocation.state || 'N/A'}, ${userLocation.country || 'N/A'} - ${userLocation.postcode || 'N/A'}`,
|
user.cell,
|
||||||
new Date(user.dob?.date).toLocaleDateString('en-US') || 'N/A',
|
`${user.location.street.number} ${user.location.street.name}, ${user.location.city}, ${user.location.state}, ${user.location.country} - ${user.location.postcode}`,
|
||||||
user.nat || 'N/A',
|
new Date(user.dob.date).toLocaleDateString(),
|
||||||
userLocation.timezone?.description || 'N/A',
|
user.nat,
|
||||||
`${userLocation.coordinates?.latitude || 'N/A'}, ${userLocation.coordinates?.longitude || 'N/A'}`,
|
user.location.timezone.description,
|
||||||
user.login?.username || 'N/A'
|
`${user.location.coordinates.latitude}, ${user.location.coordinates.longitude}`,
|
||||||
]
|
user.login.username
|
||||||
];
|
]
|
||||||
|
];
|
||||||
const csvContent = userData.map(row => row.join(',')).join('\n');
|
|
||||||
const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
|
// Convert to CSV format
|
||||||
const link = document.createElement('a');
|
const csvContent = userData.map(row => row.join(',')).join('\n');
|
||||||
const url = URL.createObjectURL(blob);
|
|
||||||
link.setAttribute('href', url);
|
// Create a Blob from the CSV data
|
||||||
link.setAttribute('download', `${userName.first || 'User'}_${userName.last || 'Details'}.csv`);
|
const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
|
||||||
link.style.visibility = 'hidden';
|
|
||||||
|
// Create a link to download the CSV file
|
||||||
document.body.appendChild(link);
|
const link = document.createElement('a');
|
||||||
link.click();
|
const url = URL.createObjectURL(blob);
|
||||||
document.body.removeChild(link);
|
link.setAttribute('href', url);
|
||||||
};
|
link.setAttribute('download', `${user.name.first}_${user.name.last}_details.csv`);
|
||||||
|
link.style.visibility = 'hidden';
|
||||||
return (
|
|
||||||
<div className="user-details">
|
// Append the link to the document body and trigger the download
|
||||||
<h2>{userName.first || 'Unknown'} {userName.last || 'User'}</h2>
|
document.body.appendChild(link);
|
||||||
<img src={user.picture?.large} alt={userName.first || 'User'} className="user-image" />
|
link.click();
|
||||||
|
document.body.removeChild(link);
|
||||||
<div className="user-info">
|
};
|
||||||
<div><strong>Email:</strong> {user.email || 'N/A'}</div>
|
|
||||||
<div><strong>Phone:</strong> {user.phone || 'N/A'}</div>
|
return (
|
||||||
<div><strong>Cell:</strong> {user.cell || 'N/A'}</div>
|
<div className="user-details">
|
||||||
<div>
|
<h2>{user.name.first} {user.name.last}</h2>
|
||||||
<strong>Location:</strong> {`${userLocation.street?.number || ''} ${userLocation.street?.name || ''}, ${userLocation.city || 'N/A'}, ${userLocation.state || 'N/A'}, ${userLocation.country || 'N/A'} - ${userLocation.postcode || 'N/A'}`}
|
<img src={user.picture.large} alt={user.name.first} className="user-image" />
|
||||||
</div>
|
|
||||||
<div><strong>Date of Birth:</strong> {new Date(user.dob?.date).toLocaleDateString('en-US') || 'N/A'}</div>
|
{/* Display user details */}
|
||||||
<div><strong>Nationality:</strong> {user.nat || 'N/A'}</div>
|
<div className="user-info">
|
||||||
<div><strong>Timezone:</strong> {userLocation.timezone?.description || 'N/A'}</div>
|
<div><strong>Email:</strong> {user.email}</div>
|
||||||
<div>
|
<div><strong>Phone:</strong> {user.phone}</div>
|
||||||
<strong>Coordinates:</strong> {`${userLocation.coordinates?.latitude || 'N/A'}, ${userLocation.coordinates?.longitude || 'N/A'}`}
|
<div><strong>Cell:</strong> {user.cell}</div>
|
||||||
</div>
|
<div>
|
||||||
<div><strong>Username:</strong> {user.login?.username || 'N/A'}</div>
|
<strong>Location:</strong> {user.location.street.number} {user.location.street.name}, {user.location.city}, {user.location.state}, {user.location.country} - {user.location.postcode}
|
||||||
</div>
|
</div>
|
||||||
|
<div><strong>Date of Birth:</strong> {new Date(user.dob.date).toLocaleDateString()}</div>
|
||||||
<Link to="/home" className="back-btn">Back to User List</Link>
|
<div><strong>Nationality:</strong> {user.nat}</div>
|
||||||
<button onClick={exportToCSV} className="export-btn">Export to CSV</button>
|
<div><strong>Timezone:</strong> {user.location.timezone.description}</div>
|
||||||
</div>
|
<div>
|
||||||
);
|
<strong>Coordinates:</strong> {user.location.coordinates.latitude}, {user.location.coordinates.longitude}
|
||||||
};
|
</div>
|
||||||
|
<div><strong>Username:</strong> {user.login.username}</div>
|
||||||
export default UserDetails;
|
</div>
|
||||||
|
|
||||||
|
{/* Link to go back to the user list */}
|
||||||
|
<Link to="/home" className="back-btn">Back to User List</Link>
|
||||||
|
|
||||||
|
{/* Export Button to download user data as CSV */}
|
||||||
|
<button onClick={exportToCSV} className="export-btn">Export to CSV</button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default UserDetails;
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
||||||
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
||||||
sans-serif;
|
sans-serif;
|
||||||
-webkit-font-smoothing: antialiased;
|
-webkit-font-smoothing: antialiased;
|
||||||
-moz-osx-font-smoothing: grayscale;
|
-moz-osx-font-smoothing: grayscale;
|
||||||
}
|
}
|
||||||
|
|
||||||
code {
|
code {
|
||||||
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
||||||
monospace;
|
monospace;
|
||||||
}
|
}
|
22
src/index.js
22
src/index.js
|
@ -1,12 +1,12 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom/client';
|
import ReactDOM from 'react-dom/client';
|
||||||
import './index.css';
|
import './index.css';
|
||||||
import App from './App';
|
import App from './App';
|
||||||
|
|
||||||
|
|
||||||
const root = ReactDOM.createRoot(document.getElementById('root'));
|
const root = ReactDOM.createRoot(document.getElementById('root'));
|
||||||
root.render(
|
root.render(
|
||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
<App />
|
<App />
|
||||||
</React.StrictMode>
|
</React.StrictMode>
|
||||||
);
|
);
|
Loading…
Reference in a new issue