Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7bb32d1a0b |
Generated
+3184
-4197
File diff suppressed because it is too large
Load Diff
+1
-3
@@ -11,11 +11,10 @@
|
|||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"json-server": "^1.0.0-beta.3",
|
|
||||||
"react": "^19.1.0",
|
"react": "^19.1.0",
|
||||||
"react-dom": "^19.1.0",
|
"react-dom": "^19.1.0",
|
||||||
"react-icons": "^5.5.0",
|
"react-icons": "^5.5.0",
|
||||||
"react-router-dom": "^7.7.1"
|
"sass-embedded": "^1.89.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.25.0",
|
"@eslint/js": "^9.25.0",
|
||||||
@@ -26,7 +25,6 @@
|
|||||||
"eslint-plugin-react-hooks": "^5.2.0",
|
"eslint-plugin-react-hooks": "^5.2.0",
|
||||||
"eslint-plugin-react-refresh": "^0.4.19",
|
"eslint-plugin-react-refresh": "^0.4.19",
|
||||||
"globals": "^16.0.0",
|
"globals": "^16.0.0",
|
||||||
"sass-embedded": "^1.100.0",
|
|
||||||
"vite": "^6.3.5"
|
"vite": "^6.3.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
import styles from './App.module.scss'
|
||||||
|
|
||||||
|
import Header from './components/header'
|
||||||
|
import ProductList from './components/list'
|
||||||
|
import Timer from './components/timer'
|
||||||
|
|
||||||
|
const App = () => {
|
||||||
|
return (
|
||||||
|
<div className={styles.container}>
|
||||||
|
<Header />
|
||||||
|
<Timer />
|
||||||
|
<ProductList />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default App
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
@use './assets/styles/variables' as *;
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
max-width: 1170px;
|
max-width: 1170px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
import styles from './OrderDetail.module.scss'
|
|
||||||
|
|
||||||
const OrderDetail = () => {
|
|
||||||
return (
|
|
||||||
<div className={styles.detail}>
|
|
||||||
<h2>Order Summary</h2>
|
|
||||||
<div className={styles.stats}>
|
|
||||||
<div>
|
|
||||||
<p>Subtotal</p>
|
|
||||||
<span>$565</span>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<p>Discount (-20%)</p>
|
|
||||||
<span>-$113</span>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<p>Delivery Fee</p>
|
|
||||||
<span>$15</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className={styles.total}>
|
|
||||||
<p>Total</p>
|
|
||||||
<span>$467</span>
|
|
||||||
</div>
|
|
||||||
<button>Go to Checkout</button>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default OrderDetail
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
@use '../assets/styles/variables' as *;
|
|
||||||
|
|
||||||
.detail {
|
|
||||||
border: 1px solid gainsboro;
|
|
||||||
border-radius: 20px;
|
|
||||||
|
|
||||||
flex-basis: 50%;
|
|
||||||
margin-top: 24px;
|
|
||||||
padding: 20px;
|
|
||||||
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
|
|
||||||
.stats {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 20px;
|
|
||||||
margin-top: 24px;
|
|
||||||
padding-bottom: 20px;
|
|
||||||
|
|
||||||
border-bottom: 1px solid gainsboro;
|
|
||||||
div {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
|
|
||||||
p {
|
|
||||||
color: gray;
|
|
||||||
font-size: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
span {
|
|
||||||
font-size: 20px;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.total {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
|
|
||||||
p {
|
|
||||||
color: gray;
|
|
||||||
font-size: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
span {
|
|
||||||
font-size: 20px;
|
|
||||||
font-weight: bold;
|
|
||||||
margin-top: 20px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
button {
|
|
||||||
outline: 0;
|
|
||||||
border: 0;
|
|
||||||
font-size: 16px;
|
|
||||||
padding: 20px;
|
|
||||||
border-radius: 62px;
|
|
||||||
background-color: $primary-color;
|
|
||||||
color: $white-color;
|
|
||||||
cursor: pointer;
|
|
||||||
margin-top: 24px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
import styles from './index.module.scss'
|
|
||||||
import JacketImage from '../../../assets/images/products/jacket.svg'
|
|
||||||
import TrashIcon from '../../../assets/icons/trash.svg'
|
|
||||||
|
|
||||||
const CartItem = () => {
|
|
||||||
return (
|
|
||||||
<div className={styles.item}>
|
|
||||||
<button className={styles.trash}>
|
|
||||||
<img src={TrashIcon} alt='' />
|
|
||||||
</button>
|
|
||||||
<div className={styles.image}>
|
|
||||||
<img src={JacketImage} alt='' />
|
|
||||||
</div>
|
|
||||||
<div className={styles.content}>
|
|
||||||
<h2>Quilted Satin Jacket</h2>
|
|
||||||
<div className={styles.wrapper}>
|
|
||||||
<span className={styles.price}>$145</span>
|
|
||||||
<div className={styles.buttons}>
|
|
||||||
<button>-</button>
|
|
||||||
<span>1</span>
|
|
||||||
<button>+</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default CartItem
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
.item {
|
|
||||||
border-bottom: 1px solid #dcdcdc;
|
|
||||||
padding: 24px 0;
|
|
||||||
position: relative;
|
|
||||||
|
|
||||||
.trash {
|
|
||||||
outline: 0;
|
|
||||||
border: 0;
|
|
||||||
background-color: white;
|
|
||||||
position: absolute;
|
|
||||||
|
|
||||||
top: 20px;
|
|
||||||
right: 20px;
|
|
||||||
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.image {
|
|
||||||
background-color: #f5f5f5;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
padding: 35px;
|
|
||||||
height: 124px;
|
|
||||||
width: 124px;
|
|
||||||
|
|
||||||
img {
|
|
||||||
width: 90px;
|
|
||||||
object-fit: contain;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.wrapper {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
|
|
||||||
.price {
|
|
||||||
font-size: 24px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.buttons {
|
|
||||||
display: flex;
|
|
||||||
background-color: #f0f0f0;
|
|
||||||
padding: 12px 20px;
|
|
||||||
gap: 20px;
|
|
||||||
border-radius: 62px;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
span {
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
|
|
||||||
button {
|
|
||||||
outline: 0;
|
|
||||||
border: 0;
|
|
||||||
font-size: 16px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
|
|
||||||
import WishIcon from '../../../assets/icons/wish.svg'
|
import WishIcon from '../../assets/icons/wish.svg'
|
||||||
|
|
||||||
const ProductCard = ({ name, price, imageUrl }) => {
|
const ProductCard = ({ name, price, imageUrl }) => {
|
||||||
return (
|
return (
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
@use '../../../assets/styles/variables' as *;
|
@use '../../assets/styles/variables' as *;
|
||||||
|
|
||||||
.product {
|
.product {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -4,7 +4,6 @@ import CartIcon from '../../assets/icons/cart.svg'
|
|||||||
import UserIcon from '../../assets/icons/user.svg'
|
import UserIcon from '../../assets/icons/user.svg'
|
||||||
import WishlistIcon from '../../assets/icons/wishlist.svg'
|
import WishlistIcon from '../../assets/icons/wishlist.svg'
|
||||||
import LoopIcon from '../../assets/icons/loop.svg'
|
import LoopIcon from '../../assets/icons/loop.svg'
|
||||||
import { Link } from 'react-router-dom'
|
|
||||||
|
|
||||||
const Header = () => {
|
const Header = () => {
|
||||||
return (
|
return (
|
||||||
@@ -13,13 +12,13 @@ const Header = () => {
|
|||||||
<nav>
|
<nav>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<Link to={{ pathname: '/' }}>Home</Link>
|
<a href='#'>Home</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<Link to={{ pathname: '/contact' }}>Contact</Link>
|
<a href='#'>Contact</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<Link to={{ pathname: '/about' }}>About</Link>
|
<a href='#'>About</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href='#'>Sign Up</a>
|
<a href='#'>Sign Up</a>
|
||||||
@@ -32,14 +31,10 @@ const Header = () => {
|
|||||||
</div>
|
</div>
|
||||||
<div className={styles.buttons}>
|
<div className={styles.buttons}>
|
||||||
<button>
|
<button>
|
||||||
<Link to={{ pathname: '/wishlist' }}>
|
<img src={WishlistIcon} alt='' />
|
||||||
<img src={WishlistIcon} alt='' />
|
|
||||||
</Link>
|
|
||||||
</button>
|
</button>
|
||||||
<button>
|
<button>
|
||||||
<Link to={{ pathname: '/cart' }}>
|
<img src={CartIcon} alt='' />
|
||||||
<img src={CartIcon} alt='' />
|
|
||||||
</Link>
|
|
||||||
</button>
|
</button>
|
||||||
<button>
|
<button>
|
||||||
<img src={UserIcon} alt='' />
|
<img src={UserIcon} alt='' />
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
import CartItem from '../../card/cart'
|
|
||||||
import styles from './index.module.scss'
|
|
||||||
|
|
||||||
const CartList = () => {
|
|
||||||
return (
|
|
||||||
<ul className={styles.list}>
|
|
||||||
<li>
|
|
||||||
<CartItem />
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<CartItem />
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<CartItem />
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default CartList
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
.list {
|
|
||||||
display: flex;
|
|
||||||
border: 1px solid gainsboro;
|
|
||||||
border-radius: 20px;
|
|
||||||
padding: 20px;
|
|
||||||
margin-top: 24px;
|
|
||||||
list-style: none;
|
|
||||||
|
|
||||||
max-width: 715px;
|
|
||||||
flex-direction: column;
|
|
||||||
|
|
||||||
flex-basis: 80%;
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import styles from './index.module.scss'
|
||||||
|
|
||||||
|
import ProductCard from '../card'
|
||||||
|
|
||||||
|
const ProductList = () => {
|
||||||
|
const [products, setProducts] = React.useState([])
|
||||||
|
const [loading, setLoading] = React.useState(true)
|
||||||
|
const [error, setError] = React.useState(null)
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
let cancelled = false
|
||||||
|
|
||||||
|
const getProducts = async () => {
|
||||||
|
try {
|
||||||
|
setLoading(true)
|
||||||
|
setError(null)
|
||||||
|
|
||||||
|
const response = await fetch('http://localhost:8000/products')
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`HTTP error! status: ${response.status}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await response.json()
|
||||||
|
|
||||||
|
if (!cancelled) {
|
||||||
|
setProducts(data)
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
if (!cancelled) {
|
||||||
|
setError(err.message)
|
||||||
|
setProducts([])
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (!cancelled) {
|
||||||
|
setLoading(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getProducts()
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
cancelled = true
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
if (loading) {
|
||||||
|
return <div className={styles.loading}>Загрузка продуктов...</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
return (
|
||||||
|
<div className={styles.error}>
|
||||||
|
<p>Ошибка при загрузке продуктов: {error}</p>
|
||||||
|
<button onClick={() => window.location.reload()}>
|
||||||
|
Попробовать снова
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ul className={styles.list}>
|
||||||
|
{products.map(product => (
|
||||||
|
<li key={product.id}>
|
||||||
|
<ProductCard {...product} />
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ProductList
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
import styles from './index.module.scss'
|
|
||||||
import ProductCard from '../../card/product'
|
|
||||||
import { useProducts } from '../../../hooks/useProducts'
|
|
||||||
|
|
||||||
const ProductList = () => {
|
|
||||||
const { products, loading, error } = useProducts()
|
|
||||||
|
|
||||||
if (loading) {
|
|
||||||
return <div className={styles.loading}>Загрузка продуктов...</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
if (error) {
|
|
||||||
return (
|
|
||||||
<div className={styles.error}>
|
|
||||||
<p>Ошибка при загрузке продуктов: {error}</p>
|
|
||||||
<button onClick={() => window.location.reload()}>
|
|
||||||
Попробовать снова
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<ul className={styles.list}>
|
|
||||||
{products.map(product => (
|
|
||||||
<li key={product.id}>
|
|
||||||
<ProductCard {...product} />
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
</ul>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ProductList
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import React, { useState, useEffect } from 'react'
|
||||||
|
import styles from './index.module.scss'
|
||||||
|
|
||||||
|
const Timer = () => {
|
||||||
|
const [seconds, setSeconds] = useState(0);
|
||||||
|
useEffect(() => {
|
||||||
|
const interval = setInterval(() => {
|
||||||
|
setSeconds(prev => prev + 1);
|
||||||
|
}, 1000);
|
||||||
|
return () => {
|
||||||
|
clearInterval(interval);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h2>Прошло секунд: {seconds}</h2>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Timer
|
||||||
+5
-16
@@ -1,20 +1,9 @@
|
|||||||
|
import { StrictMode } from 'react'
|
||||||
import { createRoot } from 'react-dom/client'
|
import { createRoot } from 'react-dom/client'
|
||||||
import {
|
import App from './App.jsx'
|
||||||
BrowserRouter as Router,
|
|
||||||
Routes,
|
|
||||||
Route,
|
|
||||||
Navigate,
|
|
||||||
} from 'react-router-dom'
|
|
||||||
|
|
||||||
import Catalog from './pages/catalog'
|
|
||||||
import Cart from './pages/cart'
|
|
||||||
|
|
||||||
createRoot(document.getElementById('root')).render(
|
createRoot(document.getElementById('root')).render(
|
||||||
<Router>
|
<StrictMode>
|
||||||
<Routes>
|
<App />
|
||||||
<Route path='/' element={<Navigate to='/catalog' replace />} />
|
</StrictMode>
|
||||||
<Route path='/catalog' element={<Catalog />} />
|
|
||||||
<Route path='/cart' element={<Cart />} />
|
|
||||||
</Routes>
|
|
||||||
</Router>
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
import styles from './index.module.scss'
|
|
||||||
|
|
||||||
import Header from '../../components/header'
|
|
||||||
import CartList from '../../components/list/cart'
|
|
||||||
import OrderDetail from '../../components/OrderDetail'
|
|
||||||
|
|
||||||
const Cart = () => {
|
|
||||||
return (
|
|
||||||
<div className={styles.container}>
|
|
||||||
<Header />
|
|
||||||
<h1 style={{ marginTop: 24 }}>Your Cart</h1>
|
|
||||||
<div style={{ display: 'flex', gap: 20 }}>
|
|
||||||
<CartList />
|
|
||||||
<OrderDetail />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Cart
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
import styles from './index.module.scss'
|
|
||||||
|
|
||||||
import Header from '../../components/header/index'
|
|
||||||
import ProductList from '../../components/list/product/index'
|
|
||||||
|
|
||||||
const Catalog = () => {
|
|
||||||
return (
|
|
||||||
<div className={styles.container}>
|
|
||||||
<Header />
|
|
||||||
<ProductList />
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Catalog
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
.container {
|
|
||||||
max-width: 1170px;
|
|
||||||
margin: 0 auto;
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user