This commit is contained in:
AnnaLioness 2023-12-22 11:16:01 +04:00
parent 6f064ff66e
commit 79cbd657d4
100 changed files with 8468 additions and 0 deletions

View File

@ -0,0 +1,25 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'airbnb-base',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parserOptions: { ecmaVersion: 12, sourceType: 'module' },
settings: { react: { version: '18.2' } },
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
'indent': 'off',
'no-console': 'off',
'arrow-body-style': 'off',
'implicit-arrow-linebreak': 'off',
'linebreak-style': 'off',
},
}

View File

@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

View File

@ -0,0 +1,32 @@
#### Окружение:
- nodejs 18;
- VSCode;
- ESLint плагин для VSCode;
- для отладки необходимы бразузеры Chrome или Edge.
#### Создание пустого проекта:
```commandline
npm create vite@latest ./ -- --template react
```
#### Установка зависимостей:
```commandline
npm install
```
#### Запуск проекта:
```commandline
npm run dev
```
#### Сборка проекта:
```commandline
npm run build
```
npm install
npm run dev
npm run build

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,15 @@
<html lang="ru">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/gem.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Рарити шоп</title>
</head>
<body>
<div id="root" class="h-100 d-flex flex-column"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>

View File

@ -0,0 +1,15 @@
{
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "Node",
"target": "ES2020",
"jsx": "react",
"strictNullChecks": true,
"strictFunctionTypes": true,
"sourceMap": true
},
"exclude": [
"node_modules",
"**/node_modules/*"
]
}

View File

@ -0,0 +1,5 @@
{
"static": "./node_modules/json-server/public",
"port": 8081,
"watch": "true"
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,38 @@
{
"name": "lec4",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
"rest": "json-server data.json",
"vite": "vite",
"dev": "npm-run-all --parallel rest vite",
"prod": "npm-run-all lint 'vite build' --parallel rest 'vite preview'"
},
"dependencies": {
"axios": "^1.6.1",
"bootstrap": "^5.3.2",
"prop-types": "^15.8.1",
"react": "^18.2.0",
"react-bootstrap": "^2.9.1",
"react-bootstrap-icons": "^1.10.3",
"react-dom": "^18.2.0",
"react-hot-toast": "^2.4.1",
"react-router-dom": "^6.18.0"
},
"devDependencies": {
"@types/react": "^18.2.15",
"@types/react-dom": "^18.2.15",
"@vitejs/plugin-react": "^4.0.3",
"eslint": "^8.45.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"json-server": "^0.17.4",
"npm-run-all": "^4.1.5",
"vite": "^4.4.5"
}
}

View File

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-cart2" viewBox="0 0 16 16">
<path d="M0 2.5A.5.5 0 0 1 .5 2H2a.5.5 0 0 1 .485.379L2.89 4H14.5a.5.5 0 0 1 .485.621l-1.5 6A.5.5 0 0 1 13 11H4a.5.5 0 0 1-.485-.379L1.61 3H.5a.5.5 0 0 1-.5-.5zM3.14 5l1.25 5h8.22l1.25-5H3.14zM5 13a1 1 0 1 0 0 2 1 1 0 0 0 0-2zm-2 1a2 2 0 1 1 4 0 2 2 0 0 1-4 0zm9-1a1 1 0 1 0 0 2 1 1 0 0 0 0-2zm-2 1a2 2 0 1 1 4 0 2 2 0 0 1-4 0z"/>
</svg>

After

Width:  |  Height:  |  Size: 463 B

View File

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-gem" viewBox="0 0 16 16">
<path d="M3.1.7a.5.5 0 0 1 .4-.2h9a.5.5 0 0 1 .4.2l2.976 3.974c.149.185.156.45.01.644L8.4 15.3a.5.5 0 0 1-.8 0L.1 5.3a.5.5 0 0 1 0-.6l3-4zm11.386 3.785-1.806-2.41-.776 2.413 2.582-.003zm-3.633.004.961-2.989H4.186l.963 2.995zM5.47 5.495 8 13.366l2.532-7.876-5.062.005zm-1.371-.999-.78-2.422-1.818 2.425zM1.499 5.5l5.113 6.817-2.192-6.82L1.5 5.5zm7.889 6.817 5.123-6.83-2.928.002-2.195 6.828z"/>
</svg>

After

Width:  |  Height:  |  Size: 524 B

View File

@ -0,0 +1,27 @@
import PropTypes from 'prop-types';
import { Container } from 'react-bootstrap';
import { Outlet } from 'react-router-dom';
import './App.css';
import Footer from './components/footer/Footer.jsx';
import Navigation from './components/navigation/Navigation.jsx';
import { CartProvider } from './components/cart/CartContext.jsx';
const App = ({ routes }) => {
return (
<>
<CartProvider>
<Navigation routes={routes}></Navigation>
<Container className='p-2' as="main" fluid>
<Outlet />
</Container>
<Footer />
</CartProvider>
</>
);
};
App.propTypes = {
routes: PropTypes.array,
};
export default App;

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 640 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 812 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 767 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 274 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 995 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 402 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 705 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 757 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 601 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 789 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 KiB

View File

@ -0,0 +1,40 @@
import axios from 'axios';
import toast from 'react-hot-toast';
export class HttpError extends Error {
constructor(message = '') {
super(message);
this.name = 'HttpError';
Object.setPrototypeOf(this, new.target.prototype);
toast.error(message, { id: 'HttpError' });
}
}
function responseHandler(response) {
if (response.status === 200 || response.status === 201) {
const data = response?.data;
if (!data) {
throw new HttpError('API Error. No data!');
}
return data;
}
throw new HttpError(`API Error! Invalid status code ${response.status}!`);
}
function responseErrorHandler(error) {
if (error === null) {
throw new Error('Unrecoverable error!! Error is null!');
}
toast.error(error.message, { id: 'AxiosError' });
return Promise.reject(error.message);
}
export const ApiClient = axios.create({
baseURL: 'http://localhost:8081/',
timeout: '3000',
headers: {
Accept: 'application/json',
},
});
ApiClient.interceptors.response.use(responseHandler, responseErrorHandler);

View File

@ -0,0 +1,29 @@
import { ApiClient } from './ApiClient';
class ApiService {
constructor(url) {
this.url = url;
}
async getAll(expand) {
return ApiClient.get(`${this.url}${expand || ''}`);
}
async get(id, expand) {
return ApiClient.get(`${this.url}/${id}${expand || ''}`);
}
async create(body) {
return ApiClient.post(this.url, body);
}
async update(id, body) {
return ApiClient.put(`${this.url}/${id}`, body);
}
async delete(id) {
return ApiClient.delete(`${this.url}/${id}`);
}
}
export default ApiService;

View File

@ -0,0 +1,25 @@
#banner {
margin: 2px;
display: flex;
align-items: center;
flex-direction: column;
}
#banner img {
border: 1px solid #3c3c3f;
border-radius: 5px;
}
#banner img.banner-show {
width: 100%;
opacity: 1;
transition: opacity 1s, visibility 0s;
}
#banner img.banner-hide {
height: 0;
width: 0;
opacity: 0;
visibility: hidden;
transition: opacity 1s, visibility 0s 1s;
}

View File

@ -0,0 +1,40 @@
import { useEffect, useState } from 'react';
import banner1 from '../../assets/banner1.png';
import banner2 from '../../assets/banner2.png';
import banner3 from '../../assets/banner3.png';
import './Banner.css';
const Banner = () => {
const [currentBanner, setCurrentBanner] = useState(0);
const banners = [banner1, banner2, banner3];
const getBannerClass = (index) => {
return currentBanner === index ? 'banner-show' : 'banner-hide';
};
useEffect(() => {
const bannerInterval = setInterval(
() => {
console.info('Banner changed');
let current = currentBanner + 1;
if (current === banners.length) {
current = 0;
}
setCurrentBanner(current);
},
5000,
);
return () => clearInterval(bannerInterval);
});
return (
<div id="banner" >
{
banners.map((banner, index) =>
<img key={index} className={getBannerClass(index)} src={banner} alt={`banner${index}`} />)
}
</div >
);
};
export default Banner;

View File

@ -0,0 +1,29 @@
import PropTypes from 'prop-types';
const BuscketCard = ({ line, removeFromCart }) => {
return (
<div className="card mydress mb-3" style={{ maxWidth: '100%' }}>
<div className="row g-0">
<div className="col-md-4 pict">
<img src={line.image} className="img-fluid rounded-start" alt="..." />
</div>
<div className="col-md-8">
<div className="card-body">
<h5 className="card-title">Название: {line.nameItem}</h5>
<h5 className="card-title">Размер: {line.size}</h5>
<p className="card-text">Цена: {line.price} руб.</p>
<button className="btn btn-primary w-50" type="button" onClick={() => removeFromCart(line)}>
Удалить
</button>
</div>
</div>
</div>
</div>
);
};
BuscketCard.propTypes = {
line: PropTypes.object,
removeFromCart: PropTypes.func,
};
export default BuscketCard;

View File

@ -0,0 +1,28 @@
import PropTypes from 'prop-types';
import { useNavigate } from 'react-router-dom';
const CardDress = ({ line }) => {
const navigate = useNavigate();
return (
<>
<div className="col m-0">
<div className="card" style={{
color: 'white', backgroundColor: '#1C7AAF', textDecoration: 'underline', fontSize: 'large',
}}>
<img src= {line.image} className="cards card-img-top img-fluid" alt="..." />
<div className="card-body">
<a href="#" onClick={ () => { navigate(`/ProductPage/${line.id}`); }} style={{
color: 'white', backgroundColor: '#1C7AAF', textDecoration: 'underline', fontSize: 'large',
}}> {line.nameItem}</a>
<p className="card-text">цена: {parseFloat(line.price).toFixed(2)} р.</p>
</div>
</div>
</div>
</>
);
};
CardDress.propTypes = {
line: PropTypes.object,
};
export default CardDress;

View File

@ -0,0 +1,8 @@
.cart-image {
width: 3.1rem;
padding: .25rem;
}
.cart-item {
height: auto;
}

View File

@ -0,0 +1,59 @@
import { Button, ButtonGroup, Card } from 'react-bootstrap';
import { DashLg, PlusLg, XLg } from 'react-bootstrap-icons';
import imgPlaceholder from '../../assets/200.png';
import './Cart.css';
import useCart from './CartHook';
const Cart = () => {
const {
cart,
getCartSum,
addToCart,
removeFromCart,
clearCart,
} = useCart();
return (
<div className='d-flex flex-column align-items-center'>
<div className='mb-2 col-12 col-md-8 col-lg-6 d-flex align-items-center'>
<strong className='flex-fill'>Корзина</strong>
<Button variant='danger' onClick={() => clearCart()}>
<XLg /> Очистить
</Button>
</div>
{
cart.map((cartItem) =>
<Card key={cartItem.id} className='mb-2 col-12 col-md-8 col-lg-6'>
<Card.Body className='p-2 d-flex flex-column flex-sm-row align-items-center'>
<div className='cart-item flex-fill'>
<img className='cart-image' src={cartItem.image || imgPlaceholder} alt="Cart Image" />
{cartItem.type.name}
</div>
<div className='cart-item mt-2 mt-sm-0 d-flex flex-column align-items-center align-items-sm-end'>
<div>
{cartItem.price}
{' * '}
{cartItem.count}
{' = '}
{parseFloat(cartItem.price * cartItem.count).toFixed(2)}
</div>
<ButtonGroup className='mt-2 mt-sm-1' aria-label="Cart counter">
<Button variant="primary" onClick={() => addToCart(cartItem)}>
<PlusLg />
</Button>
<Button variant="danger" onClick={() => removeFromCart(cartItem)}>
<DashLg />
</Button>
</ButtonGroup>
</div>
</Card.Body>
</Card>)
}
<div className='mb-2 col-12 col-md-8 col-lg-6 d-flex justify-content-end'>
<strong>Итого: {getCartSum()} &#8381;</strong>
</div>
</div>
);
};
export default Cart;

View File

@ -0,0 +1,29 @@
import PropTypes from 'prop-types';
import {
createContext,
useEffect,
useReducer,
} from 'react';
import { cartReducer, loadCart, saveCart } from './CartReducer';
const CartContext = createContext(null);
export const CartProvider = ({ children }) => {
const [cart, dispatch] = useReducer(cartReducer, [], loadCart);
useEffect(() => {
saveCart(cart || []);
}, [cart]);
return (
<CartContext.Provider value={{ cart, dispatch }}>
{children}
</CartContext.Provider>
);
};
CartProvider.propTypes = {
children: PropTypes.node,
};
export default CartContext;

View File

@ -0,0 +1,26 @@
import { useContext } from 'react';
import CartContext from './CartContext.jsx';
import { cartAdd, cartClear, cartRemove } from './CartReducer';
const useCart = () => {
const { cart, dispatch } = useContext(CartContext);
const cartSum = () => {
return parseFloat(
cart?.reduce((sum, cartItem) => {
return sum + (cartItem.price * cartItem.count);
}, 0)
?? 0,
).toFixed(2);
};
return {
cart,
getCartSum: () => cartSum(),
addToCart: (item) => dispatch(cartAdd(item)),
removeFromCart: (item) => dispatch(cartRemove(item)),
clearCart: () => dispatch(cartClear()),
};
};
export default useCart;

View File

@ -0,0 +1,71 @@
const setCartCount = (cart, item, value) => {
return cart.map((cartItem) => {
if (cartItem.id === item.id) {
return { ...cartItem, count: cartItem.count + value };
}
return cartItem;
});
};
const addToCart = (cart, item) => {
const existsItem = cart.find((cartItem) => cartItem.id === item.id);
if (existsItem !== undefined) {
return setCartCount(cart, item, 1);
}
return [...cart, { ...item, count: 1 }];
};
const removeFromCart = (cart, item) => {
const existsItem = cart.find((cartItem) => cartItem.id === item.id);
if (existsItem !== undefined && existsItem.count > 1) {
return setCartCount(cart, item, -1);
}
return cart.filter((cartItem) => cartItem.id !== item.id);
};
const CART_KEY = 'localCart';
const CART_ADD = 'cart/add';
const CART_REMOVE = 'cart/remove';
const CART_CLEAR = 'cart/clear';
export const saveCart = (cart) => {
localStorage.setItem(CART_KEY, JSON.stringify(cart));
};
export const loadCart = (initialValue = []) => {
const cartData = localStorage.getItem(CART_KEY);
if (cartData) {
return JSON.parse(cartData);
}
return initialValue;
};
export const cartReducer = (cart, action) => {
const { item } = action;
switch (action.type) {
case CART_ADD: {
return addToCart(cart, item);
}
case CART_REMOVE: {
return removeFromCart(cart, item);
}
case CART_CLEAR: {
return [];
}
default: {
throw Error(`Unknown action: ${action.type}`);
}
}
};
export const cartAdd = (item) => ({
type: CART_ADD, item,
});
export const cartRemove = (item) => ({
type: CART_REMOVE, item,
});
export const cartClear = () => ({
type: CART_CLEAR,
});

View File

@ -0,0 +1,5 @@
.my-footer {
background-color: #5C00A4;
height: 32px;
color: #ffffff;
}

View File

@ -0,0 +1,11 @@
import './Footer.css';
const Footer = () => {
return (
<footer className ="footer mt-auto d-flex flex-shrink-0 justify-content-left align-items-left">
Рарити Шоп.ру Лёвушкина Анна ПИбд-21
</footer>
);
};
export default Footer;

View File

@ -0,0 +1,23 @@
import PropTypes from 'prop-types';
import { Form } from 'react-bootstrap';
const Input = ({
name, label, value, onChange, className, ...rest
}) => {
return (
<Form.Group className={`mb-2 ${className || ''}`} controlId={name}>
<Form.Label>{label}</Form.Label>
<Form.Control name={name || ''} value={value || ''} onChange={onChange} {...rest} />
</Form.Group>
);
};
Input.propTypes = {
name: PropTypes.string,
label: PropTypes.string,
value: PropTypes.string,
onChange: PropTypes.func,
className: PropTypes.string,
};
export default Input;

View File

@ -0,0 +1,29 @@
import PropTypes from 'prop-types';
import { Form } from 'react-bootstrap';
const Select = ({
values, name, label, value, onChange, className, ...rest
}) => {
return (
<Form.Group className={`mb-2 ${className || ''}`} controlId={name}>
<Form.Label className='form-label'>{label}</Form.Label>
<Form.Select name={name || ''} value={value || ''} onChange={onChange} {...rest}>
<option value=''>Выберите значение</option>
{
values.map((type) => <option key={type.id} value={type.id}>{type.name}</option>)
}
</Form.Select>
</Form.Group>
);
};
Select.propTypes = {
values: PropTypes.array,
name: PropTypes.string,
label: PropTypes.string,
value: PropTypes.string,
onChange: PropTypes.func,
className: PropTypes.string,
};
export default Select;

View File

@ -0,0 +1,29 @@
import PropTypes from 'prop-types';
import { Form } from 'react-bootstrap';
const SelectSize = ({
values, name, label, value, onChange, className, ...rest
}) => {
return (
<Form.Group className={`mb-2 ${className || ''}`} controlId={name}>
<Form.Label className='form-label'>{label}</Form.Label>
<Form.Select name={name || ''} value={value || ''} onChange={onChange} {...rest}>
<option value=''>Выберите размер</option>
{
values.map((size) => <option key={size.id} value={size.id}>{size.name}</option>)
}
</Form.Select>
</Form.Group>
);
};
SelectSize.propTypes = {
values: PropTypes.array,
name: PropTypes.string,
label: PropTypes.string,
value: PropTypes.string,
onChange: PropTypes.func,
className: PropTypes.string,
};
export default SelectSize;

View File

@ -0,0 +1,48 @@
import PropTypes from 'prop-types';
import { Button, Form } from 'react-bootstrap';
import { useNavigate } from 'react-router-dom';
import useLinesItemForm from '../hooks/LinesItemFormHook';
import LinesItemForm from './LinesItemForm.jsx';
const LinesForm = ({ id }) => {
const navigate = useNavigate();
const {
item,
validated,
handleSubmit,
handleChange,
} = useLinesItemForm(id);
const onBack = () => {
navigate(-1);
};
const onSubmit = async (event) => {
if (await handleSubmit(event)) {
onBack();
}
};
return (
<>
<Form className='m-0 p-2' noValidate validated={validated} onSubmit={onSubmit}>
<LinesItemForm item={item} handleChange={handleChange} />
<Form.Group className='row justify-content-center m-0 mt-3'>
<Button className='col-5 col-lg-2 m-0 me-2' variant='secondary' onClick={() => onBack()}>
Назад
</Button>
<Button className='col-5 col-lg-2 m-0 ms-2' type='submit' variant='primary'>
Сохранить
</Button>
</Form.Group>
</Form>
</>
);
};
LinesForm.propTypes = {
id: PropTypes.string,
};
export default LinesForm;

View File

@ -0,0 +1,3 @@
#image-preview {
width: 200px;
}

View File

@ -0,0 +1,34 @@
import PropTypes from 'prop-types';
import imgPlaceholder from '../../../assets/200.png';
import Input from '../../input/Input.jsx';
import Select from '../../input/Select.jsx';
import useTypes from '../../types/hooks/TypesHook';
import './LinesItemForm.css';
const LinesItemForm = ({ item, handleChange }) => {
const { types } = useTypes();
return (
<>
<div className='text-center'>
<img id='image-preview' className='rounded' alt='placeholder'
src={item.image || imgPlaceholder} />
</div>
<Select values={types} name='typeId' label='Категории' value={item.typeId} onChange={handleChange}
required />
<Input name='price' label='Цена' value={item.price} onChange={handleChange}
type='number' min='1000.0' step='0.50' required />
<Input name='nameItem' label='Название' value={item.nameItem} onChange={handleChange}
type='text' required />
<Input name='image' label='Изображение' onChange={handleChange}
type='file' accept='image/*' />
</>
);
};
LinesItemForm.propTypes = {
item: PropTypes.object,
handleChange: PropTypes.func,
};
export default LinesItemForm;

View File

@ -0,0 +1,34 @@
import { useState } from 'react';
import toast from 'react-hot-toast';
import useModal from '../../modal/ModalHook';
import LinesApiService from '../service/LinesApiService';
const useLinesDeleteModal = (linesChangeHandle) => {
const { isModalShow, showModal, hideModal } = useModal();
const [currentId, setCurrentId] = useState(0);
const showModalDialog = (id) => {
showModal();
setCurrentId(id);
};
const onClose = () => {
hideModal();
};
const onDelete = async () => {
await LinesApiService.delete(currentId);
linesChangeHandle();
toast.success('Элемент успешно удален', { id: 'LinesTable' });
onClose();
};
return {
isDeleteModalShow: isModalShow,
showDeleteModal: showModalDialog,
handleDeleteConfirm: onDelete,
handleDeleteCancel: onClose,
};
};
export default useLinesDeleteModal;

View File

@ -0,0 +1,28 @@
import { useSearchParams } from 'react-router-dom';
import useTypes from '../../types/hooks/TypesHook';
const useTypeFilter = () => {
const filterName = 'type';
const [searchParams, setSearchParams] = useSearchParams();
const { types } = useTypes();
const handleFilterChange = (event) => {
const type = event.target.value;
if (type) {
searchParams.set(filterName, event.target.value);
} else {
searchParams.delete(filterName);
}
setSearchParams(searchParams);
};
return {
types,
currentFilter: searchParams.get(filterName) || '',
handleFilterChange,
};
};
export default useTypeFilter;

View File

@ -0,0 +1,45 @@
import { useState } from 'react';
import useModal from '../../modal/ModalHook';
import useLinesItemForm from './LinesItemFormHook';
const useLinesFormModal = (linesChangeHandle) => {
const { isModalShow, showModal, hideModal } = useModal();
const [currentId, setCurrentId] = useState(0);
const {
item,
validated,
handleSubmit,
handleChange,
resetValidity,
} = useLinesItemForm(currentId, linesChangeHandle);
const showModalDialog = (id) => {
setCurrentId(id);
resetValidity();
showModal();
};
const onClose = () => {
setCurrentId(-1);
hideModal();
};
const onSubmit = async (event) => {
if (await handleSubmit(event)) {
onClose();
}
};
return {
isFormModalShow: isModalShow,
isFormValidated: validated,
showFormModal: showModalDialog,
currentItem: item,
handleItemChange: handleChange,
handleFormSubmit: onSubmit,
handleFormClose: onClose,
};
};
export default useLinesFormModal;

View File

@ -0,0 +1,29 @@
import { useEffect, useState } from 'react';
import LinesApiService from '../service/LinesApiService';
const useLines = (typeFilter) => {
const [linesRefresh, setLinesRefresh] = useState(false);
const [lines, setLines] = useState([]);
const handleLinesChange = () => setLinesRefresh(!linesRefresh);
const getLines = async () => {
let expand = '?_expand=type';
if (typeFilter) {
expand = `${expand}&typeId=${typeFilter}`;
}
const data = await LinesApiService.getAll(expand);
setLines(data ?? []);
};
useEffect(() => {
getLines();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [linesRefresh, typeFilter]);
return {
lines,
handleLinesChange,
};
};
export default useLines;

View File

@ -0,0 +1,79 @@
import { useState } from 'react';
import toast from 'react-hot-toast';
import getBase64FromFile from '../../utils/Base64';
import LinesApiService from '../service/LinesApiService';
import useLinesItem from './LinesItemHook';
const useLinesItemForm = (id, linesChangeHandle) => {
const { item, setItem } = useLinesItem(id);
const [validated, setValidated] = useState(false);
const resetValidity = () => {
setValidated(false);
};
const getLineObject = (formData) => {
const typeId = parseInt(formData.typeId, 10);
const price = parseFloat(formData.price).toFixed(2);
const { nameItem } = formData;
const image = formData.image.startsWith('data:image') ? formData.image : '';
return {
typeId: typeId.toString(),
price: price.toString(),
nameItem: nameItem.toString(),
image,
};
};
const handleImageChange = async (event) => {
const { files } = event.target;
const file = await getBase64FromFile(files.item(0));
setItem({
...item,
image: file,
});
};
const handleChange = (event) => {
if (event.target.type === 'file') {
handleImageChange(event);
return;
}
const inputName = event.target.name;
const inputValue = event.target.type === 'checkbox' ? event.target.checked : event.target.value;
setItem({
...item,
[inputName]: inputValue,
});
};
const handleSubmit = async (event) => {
const form = event.currentTarget;
event.preventDefault();
event.stopPropagation();
const body = getLineObject(item);
if (form.checkValidity()) {
if (id === undefined) {
await LinesApiService.create(body);
} else {
await LinesApiService.update(id, body);
}
if (linesChangeHandle) linesChangeHandle();
toast.success('Элемент успешно сохранен', { id: 'LinesTable' });
return true;
}
setValidated(true);
return false;
};
return {
item,
validated,
handleSubmit,
handleChange,
resetValidity,
};
};
export default useLinesItemForm;

View File

@ -0,0 +1,35 @@
import { useEffect, useState } from 'react';
import LinesApiService from '../service/LinesApiService';
const useLinesItem = (id) => {
const emptyItem = {
id: '',
typeId: '',
size: '',
price: '0',
nameItem: '',
image: '',
};
const [item, setItem] = useState({ ...emptyItem });
const getItem = async (itemId = undefined) => {
if (itemId && itemId > 0) {
const data = await LinesApiService.get(itemId);
setItem(data);
} else {
setItem({ ...emptyItem });
}
};
useEffect(() => {
getItem(id);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [id]);
return {
item,
setItem,
};
};
export default useLinesItem;

View File

@ -0,0 +1,5 @@
import ApiService from '../../api/ApiService';
const LinesApiService = new ApiService('lines');
export default LinesApiService;

View File

@ -0,0 +1,70 @@
import { Button, ButtonGroup } from 'react-bootstrap';
import { Link } from 'react-router-dom';
import Select from '../../input/Select.jsx';
import ModalConfirm from '../../modal/ModalConfirm.jsx';
import ModalForm from '../../modal/ModalForm.jsx';
import LinesItemForm from '../form/LinesItemForm.jsx';
import useLinesDeleteModal from '../hooks/LinesDeleteModalHook';
import useTypeFilter from '../hooks/LinesFilterHook';
import useLinesFormModal from '../hooks/LinesFormModalHook';
import useLines from '../hooks/LinesHook';
import LinesTable from './LinesTable.jsx';
import LinesTableRow from './LinesTableRow.jsx';
const Lines = () => {
const { types, currentFilter, handleFilterChange } = useTypeFilter();
const { lines, handleLinesChange } = useLines(currentFilter);
const {
isDeleteModalShow,
showDeleteModal,
handleDeleteConfirm,
handleDeleteCancel,
} = useLinesDeleteModal(handleLinesChange);
const {
isFormModalShow,
isFormValidated,
showFormModal,
currentItem,
handleItemChange,
handleFormSubmit,
handleFormClose,
} = useLinesFormModal(handleLinesChange);
return (
<>
<ButtonGroup>
<Button variant='info' onClick={() => showFormModal()}>
Добавить товар (диалог)
</Button>
<Button variant='info'>
<Link className="nav-link active" to="/Autorization">Выход</Link>
</Button>
</ButtonGroup>
<Select className='mt-2' values={types} label='Фильтр по товарам'
value={currentFilter} onChange={handleFilterChange} />
<LinesTable>
{
lines.map((line, index) =>
<LinesTableRow key={line.id}
index={index} line={line}
onDelete={() => showDeleteModal(line.id)}
onEdit={() => showFormModal(line.id)}
/>)
}
</LinesTable>
<ModalConfirm show={isDeleteModalShow}
onConfirm={handleDeleteConfirm} onClose={handleDeleteCancel}
title='Удаление' message='Удалить элемент?' />
<ModalForm show={isFormModalShow} validated={isFormValidated}
onSubmit={handleFormSubmit} onClose={handleFormClose}
title='Редактирование'>
<LinesItemForm item={currentItem} handleChange={handleItemChange} />
</ModalForm>
</>
);
};
export default Lines;

View File

@ -0,0 +1,28 @@
import PropTypes from 'prop-types';
import './ln.css';
const LinesTable = ({ children }) => {
return (
<table className="mt-2 table-primary table-bordered w-100 t1">
<thead className = "table hat">
<tr>
<th scope='col'></th>
<th scope='col' className='w-25'>Категория</th>
<th scope='col' className='w-25'>Цена</th>
<th scope='col' className='w-25'>Название</th>
<th scope='col'></th>
<th scope='col'></th>
</tr>
</thead>
<tbody>
{children}
</tbody >
</table >
);
};
LinesTable.propTypes = {
children: PropTypes.node,
};
export default LinesTable;

View File

@ -0,0 +1,31 @@
import PropTypes from 'prop-types';
import { PencilFill, Trash3 } from 'react-bootstrap-icons';
const LinesTableRow = ({
index, line, onDelete, onEdit,
}) => {
const handleAnchorClick = (event, action) => {
event.preventDefault();
action();
};
return (
<tr>
<th scope="row">{index + 1}</th>
<td>{line.type.name}</td>
<td>{parseFloat(line.price).toFixed(2)}</td>
<td>{line.nameItem}</td>
<td><a href="#" onClick={(event) => handleAnchorClick(event, onEdit)}><PencilFill /></a></td>
<td><a href="#" onClick={(event) => handleAnchorClick(event, onDelete)}><Trash3 /></a></td>
</tr>
);
};
LinesTableRow.propTypes = {
index: PropTypes.number,
line: PropTypes.object,
onDelete: PropTypes.func,
onEdit: PropTypes.func,
};
export default LinesTableRow;

View File

@ -0,0 +1,8 @@
.t1{
background-color: #5C00A4 !important;
color: white !important;
}
.hat{
background-color: #1C7AAF !important;
}

View File

@ -0,0 +1,3 @@
.modal-title {
font-size: 1.2rem;
}

View File

@ -0,0 +1,42 @@
import PropTypes from 'prop-types';
import { Button, Modal } from 'react-bootstrap';
import { createPortal } from 'react-dom';
import './Modal.css';
const ModalConfirm = ({
show, title, message, onConfirm, onClose,
}) => {
return createPortal(
<Modal show={show} backdrop='static' onHide={() => onClose()}>
<Modal.Header className='pt-2 pb-2 ps-3 pe-3' closeButton>
<Modal.Title>{title}</Modal.Title>
</Modal.Header>
<Modal.Body>
{message}
</Modal.Body>
<Modal.Footer className='m-0 pt-2 pb-2 ps-3 pe-3 row justify-content-center'>
<Button variant='secondary' className='col-5 m-0 me-2'
onClick={() => onClose()}>
Нет
</Button>
<Button variant='primary' className='col-5 m-0 ms-2'
onClick={() => onConfirm()}>
Да
</Button>
</Modal.Footer>
</Modal>,
document.body,
);
};
ModalConfirm.propTypes = {
show: PropTypes.bool,
title: PropTypes.string,
message: PropTypes.string,
onConfirm: PropTypes.func,
onClose: PropTypes.func,
};
export default ModalConfirm;

View File

@ -0,0 +1,43 @@
import PropTypes from 'prop-types';
import { Button, Form, Modal } from 'react-bootstrap';
import { createPortal } from 'react-dom';
import './Modal.css';
const ModalForm = ({
show, title, validated, onSubmit, onClose, children,
}) => {
return createPortal(
<Modal show={show} backdrop='static' onHide={() => onClose()}>
<Modal.Header className='pt-2 pb-2 ps-3 pe-3' closeButton>
<Modal.Title>{title}</Modal.Title>
</Modal.Header>
<Form className='m-0' noValidate validated={validated} onSubmit={onSubmit}>
<Modal.Body>
{children}
</Modal.Body>
<Modal.Footer className='m-0 pt-2 pb-2 ps-3 pe-3 row justify-content-center'>
<Button variant='secondary' className='col-5 m-0 me-2'
onClick={() => onClose()}>
Отмена
</Button>
<Button variant='primary' className='col-5 m-0 ms-2' type='submit'>
Сохранить
</Button>
</Modal.Footer>
</Form>
</Modal>,
document.body,
);
};
ModalForm.propTypes = {
show: PropTypes.bool,
title: PropTypes.string,
validated: PropTypes.bool,
onSubmit: PropTypes.func,
onClose: PropTypes.func,
children: PropTypes.node,
};
export default ModalForm;

View File

@ -0,0 +1,21 @@
import { useState } from 'react';
const useModal = () => {
const [showModal, setShowModal] = useState(false);
const showModalDialog = () => {
setShowModal(true);
};
const hideModalDialog = () => {
setShowModal(false);
};
return {
isModalShow: showModal,
showModal: showModalDialog,
hideModal: hideModalDialog,
};
};
export default useModal;

View File

@ -0,0 +1,19 @@
.my-navbar {
background-color: #5C00A4 !important;
}
.my-navbar .link a:hover {
text-decoration: underline !important;
font-size: large !important;
}
.logo {
width: 94px;
height: 74px;
}
header nav {
background-color: #5C00A4;
}

View File

@ -0,0 +1,59 @@
import PropTypes from 'prop-types';
import { Link, useNavigate } from 'react-router-dom';
import Image from 'react-bootstrap/Image';
import diamond from '../../assets/logo.png';
import './Navigation.css';
import { useUser } from '../types/hooks/UsersHook';
const Navigation = () => {
const user = useUser(JSON.parse(localStorage.getItem('yohoho'))).user.id;
const navigate = useNavigate();
const handlerLK = () => {
if (user !== '') {
navigate('/Account');
} else {
navigate('/Autorization');
}
};
const showBuscket = () => {
if (user !== '') {
return (
<Link className="nav-link active" to="./Buscket">Корзина</Link>
);
}
return null;
};
return (
<header>
<nav className="navbar navbar-expand-md navbar-dark">
<div className="container-fluid">
<Link className="navbar-brand" to="/">
<div>
<Image src = {diamond} className=" logo img-fluid" alt = {'...'}/>
Рарити шоп
</div>
</Link>
<button className="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span className="navbar-toggler-icon"></span>
</button>
<div className="navbar-collapse collapse justify-content-end" id="navbarNav">
<div className="navbar-nav">
<Link className="nav-link active" to="/">Главная</Link>
<Link className="nav-link active" to="./Catalog">Каталог</Link>
<Link className="nav-link active" to="./Contacts">Контакты</Link>
<div className="nav-link active" onClick={handlerLK}>Личный кабинет</div>
<div>{showBuscket()}</div>
</div>
</div>
</div>
</nav>
</header>
);
};
Navigation.propTypes = {
routes: PropTypes.array,
};
export default Navigation;

View File

@ -0,0 +1,40 @@
import { useEffect, useState } from 'react';
import { useSearchParams } from 'react-router-dom';
import SizesApiService from '../service/SizesApiService';
const useSizes = () => {
const filterName = 'type';
const [sizes, setSizes] = useState([]);
const [searchParams, setSearchParams] = useSearchParams();
const getSizes = async () => {
const data = await SizesApiService.getAll();
setSizes(data ?? []);
};
useEffect(() => {
getSizes();
}, []);
const handleFilterChange = (event, item) => {
const type = event.target.value;
if (type) {
searchParams.set(filterName, event.target.value);
// eslint-disable-next-line no-param-reassign
item.size = sizes[type - 1].name;
} else {
searchParams.delete(filterName);
}
setSearchParams(searchParams);
};
return {
sizes,
currentFilter: searchParams.get(filterName) || '',
handleFilterChange,
};
};
export default useSizes;

View File

@ -0,0 +1,21 @@
import { useEffect, useState } from 'react';
import TypesApiService from '../service/TypesApiService';
const useTypes = () => {
const [types, setTypes] = useState([]);
const getTypes = async () => {
const data = await TypesApiService.getAll();
setTypes(data ?? []);
};
useEffect(() => {
getTypes();
}, []);
return {
types,
};
};
export default useTypes;

View File

@ -0,0 +1,75 @@
import { useEffect, useState } from 'react';
import UsersApiService from '../service/UsersApiService';
export const useUsers = () => {
const [users, setUsers] = useState([]);
const getUsers = async () => {
const data = await UsersApiService.getAll();
setUsers(data ?? []);
};
useEffect(() => {
getUsers();
}, []);
return {
users,
};
};
export const useUserL = (loginEnter) => {
let login = loginEnter;
const [users, setUser] = useState(null);
const getUser = async () => {
const data = await UsersApiService.getAll(`?login=${login}`);
if (data && data.length > 0) {
setUser(data[0]);
} else {
setUser(null);
}
};
useEffect(() => {
getUser(login);
}, []);
const handlerLoginChanged = (newLogin) => {
login = newLogin;
getUser();
};
return {
users,
handlerLoginChanged,
};
};
export const useUser = (id) => {
const emptyUser = {
id: '',
login: '',
password: '',
};
const [user, setUser] = useState({ ...emptyUser });
const getUser = async (userId = undefined) => {
if (userId && userId > 0) {
const data = await UsersApiService.get(userId);
setUser(data);
} else {
setUser({ ...emptyUser });
}
};
useEffect(() => {
getUser(id);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [id]);
return {
user,
setUser,
};
};

View File

@ -0,0 +1,5 @@
import ApiService from '../../api/ApiService';
const SizesApiService = new ApiService('sizes');
export default SizesApiService;

View File

@ -0,0 +1,5 @@
import ApiService from '../../api/ApiService';
const TypesApiService = new ApiService('types');
export default TypesApiService;

View File

@ -0,0 +1,5 @@
import ApiService from '../../api/ApiService';
const UsersApiService = new ApiService('users');
export default UsersApiService;

View File

@ -0,0 +1,15 @@
const getBase64FromFile = async (file) => {
const reader = new FileReader();
return new Promise((resolve, reject) => {
reader.onloadend = () => {
const fileContent = reader.result;
resolve(fileContent);
};
reader.onerror = () => {
reject(new Error('Oops, something went wrong with the file reader.'));
};
reader.readAsDataURL(file);
});
};
export default getBase64FromFile;

View File

@ -0,0 +1,38 @@
h1 {
font-size: 1.5em;
}
h2 {
font-size: 1.25em;
}
h3 {
font-size: 1.1em;
}
.btn-mw {
width: 100%;
}
@media (min-width: 768px) {
.btn-mw {
width: 30%;
}
}
@media (min-width: 1200px) {
.btn-mw {
width: 20%;
}
}
body{
background-image: url(assets/фон.jpg);
}
@font-face{
font-family: 'cursive';
src: url("assets/monotypecorsiva.ttf");
}
*{
font-family: 'cursive';
}

View File

@ -0,0 +1,97 @@
import 'bootstrap/dist/css/bootstrap.min.css';
import React from 'react';
import ReactDOM from 'react-dom/client';
import { RouterProvider, createBrowserRouter } from 'react-router-dom';
import App from './App.jsx';
import './index.css';
import ErrorPage from './pages/ErrorPage.jsx';
import AdminPage from './pages/AdminPage.jsx';
import MainPage from './pages/MainPage.jsx';
import Contacts from './pages/Contacts.jsx';
import PageEdit from './pages/PageEdit.jsx';
import Autorization from './pages/Autorization.jsx';
import Registration from './pages/Registration.jsx';
import Catalog from './pages/Catalog.jsx';
import Category from './pages/Category.jsx';
import ProductPage from './pages/ProductPage.jsx';
import OrderPage from './pages/OrderPage.jsx';
import Buscket from './pages/Buscket.jsx';
import Account from './pages/Account.jsx';
const routes = [
{
index: true,
path: '/',
element: <MainPage />,
title: 'Главная',
},
{
path: '/AdminPage',
element: <AdminPage />,
title: 'Четвертая страница',
},
{
path: '/Contacts',
element: <Contacts />,
title: 'контакты',
},
{
path: '/Autorization',
element: <Autorization />,
title: 'авторизация',
},
{
path: '/Registration',
element: <Registration />,
title: 'регистрация',
},
{
path: '/Catalog',
element: <Catalog />,
title: 'каталог',
},
{
path: '/Category/:id?',
element: <Category />,
title: 'категория',
},
{
path: '/ProductPage/:id?',
element: <ProductPage />,
title: 'страница товара',
},
{
path: '/OrderPage',
element: <OrderPage />,
title: 'оформление',
},
{
path: '/Buscket',
element: <Buscket />,
title: 'корзина',
},
{
path: '/Account',
element: <Account />,
title: 'кабинет',
},
{
path: '/page-edit',
element: <PageEdit />,
},
];
const router = createBrowserRouter([
{
path: '/',
element: <App routes={routes} />,
children: routes,
errorElement: <ErrorPage />,
},
]);
ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
<RouterProvider router={router} />
</React.StrictMode>,
);

View File

@ -0,0 +1,50 @@
import { useNavigate } from 'react-router-dom';
import './account.css';
import { useUser } from '../components/types/hooks/UsersHook';
const Account = () => {
const user = useUser(JSON.parse(localStorage.getItem('yohoho')));
const navigate = useNavigate();
const handlerLogOut = () => {
localStorage.setItem('yohoho', null);
navigate('/Autorization');
};
return (
<>
<div className = "container-fluid m-0">
<div className = "row">
<div className="col col-12 col-sm-3 col-md-3 col-lg-3 col-xl-3" style={{ backgroundColor: '#5C00A4', fontSize: 'x-large' }}>
<div style={{ color: 'white' }}>
{
user.user.login
}
</div>
<div>
<button type="button" className="btn btn-primary btn-lg" onClick={handlerLogOut}>
Выйти
</button>
</div>
</div>
<div className="col col-12 col-sm-9 col-md-9 col-lg-9 col-xl-9">
<h1 className = "text-center title h1" style={{ color: 'white' }}>
Мои заказы
</h1>
<table className="table-primary table-bordered t1">
<thead className="table hat">
<tr>
<th scope="col">Изображение</th>
<th scope="col">Название</th>
<th scope="col">Цена</th>
</tr>
</thead>
</table>
</div>
</div>
</div>
</>
);
};
export default Account;

View File

@ -0,0 +1,13 @@
import Lines from '../components/lines/table/Lines.jsx';
import './admin.css';
const AdminPage = () => {
return (
<>
<Lines />
</>
);
};
export default AdminPage;

View File

@ -0,0 +1,73 @@
import { useState } from 'react';
import { Button, Form, Container } from 'react-bootstrap';
import { Link, useNavigate } from 'react-router-dom';
import { useUserL } from '../components/types/hooks/UsersHook';
const Autorization = () => {
const [validated, setValidated] = useState(false);
const navigate = useNavigate();
const [formData, setFormData] = useState({
login: '',
password: '',
});
const { users, handlerLoginChanged } = useUserL(formData.login);
const handleSubmit = (event) => {
const form = event.currentTarget;
event.preventDefault();
event.stopPropagation();
if (form.checkValidity() !== false) {
console.log(formData);
}
if (formData.login === 'admin' && formData.password === '25072004') {
navigate('/AdminPage');
}
if (users.password === formData.password) {
localStorage.setItem('yohoho', JSON.stringify(users.id));
navigate('/Account');
}
setValidated(false);
};
const handleChange = (event) => {
const inputName = event.target.name;
const inputValue = event.target.type === 'checkbox' ? event.target.checked : event.target.value;
setFormData({
...formData,
[inputName]: inputValue,
});
if (inputName === 'login') {
handlerLoginChanged(inputValue);
}
};
return (
<>
<Container fluid className="container-fluid p-2" style = {{ color: 'white' }}>
<div className="row justify-content-center">
<Form className="col-md-6 m-0" noValidate validated={validated} onSubmit={handleSubmit}>
<div className="text-center">
Введите данные пользователя
</div>
<Form.Group className="mb-2" controlId="login" >
<Form.Label>Логин</Form.Label>
<Form.Control type="text" name="login" required
value={formData.login} onChange={handleChange}/>
</Form.Group>
<Form.Group className="mb-2" controlId="password" >
<Form.Label>Пароль</Form.Label>
<Form.Control type="password" name="password" required
value={formData.password} onChange={handleChange}/>
</Form.Group>
<div className="text-center">
<Button className="w-50" variant="primary" type="submit">Войти</Button>
</div>
<div className="text-center">
<Link className="nav-link active" to="/Registration">Зарегистрироваться</Link>
</div>
</Form>
</div>
</Container>
</>
);
};
export default Autorization;

View File

@ -0,0 +1,31 @@
import { Link } from 'react-router-dom';
import './buscket.css';
import BuscketCard from '../components/buscket/BuscketCard.jsx';
import useCart from '../components/cart/CartHook';
const Buscket = () => {
const {
cart,
removeFromCart,
} = useCart();
return (
<>
<form className="col-md-8 mx-auto mt-8" action="./Buscket" method="get">
<div className="busket text-center" style = {{ color: 'white' }}>
Корзина
</div>
{
cart.map((cartItem) => <BuscketCard key={cartItem.id} line={cartItem}
removeFromCart={removeFromCart} />)
}
<div className="text-center">
<button type="button" className="btn btn-primary btn-lg">
<Link className="nav-link active" to="/OrderPage">Переидти к оформлению</Link>
</button>
</div>
</form>
</>
);
};
export default Buscket;

View File

@ -0,0 +1,136 @@
// import Image from 'react-bootstrap/Image';
import { useNavigate } from 'react-router-dom';
import './catalog.css';
const Catalog = () => {
const navigate = useNavigate();
return (
<>
<div className="row">
<div className="col-4 h-100 w-25">
<div id="list-dresses" className="list-group">
<a className="list-group-item list-group-item-action" style={{ color: 'white', backgroundColor: '#50028C' }} href="#list-item-1" >Вечернее платье пышное</a>
<a className="list-group-item list-group-item-action" style={{ color: 'white', backgroundColor: '#50028C' }} href="#list-item-2">Вечернее платье прямое</a>
<a className="list-group-item list-group-item-action" style={{ color: 'white', backgroundColor: '#50028C' }} href="#list-item-3">Вечернее платье русалка</a>
<a className="list-group-item list-group-item-action" style={{ color: 'white', backgroundColor: '#50028C' }} href="#list-item-4">Вечернее платье ампир</a>
<a className="list-group-item list-group-item-action" style={{ color: 'white', backgroundColor: '#50028C' }} href="#list-item-5">Вечернее платье принцесса</a>
<a className="list-group-item list-group-item-action" style={{ color: 'white', backgroundColor: '#50028C' }} href="#list-item-6">Свадебное платье пышное</a>
<a className="list-group-item list-group-item-action" style={{ color: 'white', backgroundColor: '#50028C' }} href="#list-item-7">Свадебное платье прямое</a>
<a className="list-group-item list-group-item-action" style={{ color: 'white', backgroundColor: '#50028C' }} href="#list-item-8">Свадебное платье русалка</a>
<a className="list-group-item list-group-item-action" style={{ color: 'white', backgroundColor: '#50028C' }} href="#list-item-9">Свадебное платье ампир</a>
<a className="list-group-item list-group-item-action" style={{ color: 'white', backgroundColor: '#50028C' }} href="#list-item-10">Свадебное платье принцесса</a>
</div>
</div>
<div className="col-8">
<div data-bs-spy="scroll" data-bs-target="#list-dresses" data-bs-smooth-scroll="true" className="scrollspy-example" tabIndex={0}>
<div className="row row-cols-1 row-cols-md-3 g-4">
<div className="col">
<div id = "list-item-1" className="card h-100" style={{ color: 'white', backgroundColor: '#1C7AAF', textDecoration: 'underline' }} >
<img src="src/assets/платье вечернее пышное.png" className="cards card-img-top img-fluid" alt="..." />
<div className="card-body">
<a href="#" onClick={ () => { navigate(`/Category/${1}`); }} style={{
color: 'white', backgroundColor: '#1C7AAF', textDecoration: 'underline', fontSize: 'large',
}} > Вечернее платье пышное</a>
</div>
</div>
</div>
<div className="col">
<div id = "list-item-2" className="card h-100" style={{ color: 'white', backgroundColor: '#1C7AAF', textDecoration: 'underline' }} >
<img src="src/assets/платье вечернее прямое.png" className="cards card-img-top img-fluid" alt="..." />
<div className="card-body">
<a href="#" onClick={ () => { navigate(`/Category/${2}`); }} style={{
color: 'white', backgroundColor: '#1C7AAF', textDecoration: 'underline', fontSize: 'large',
}} > Вечернее платье прямое</a>
</div>
</div>
</div>
<div className="col">
<div id = "list-item-3" className="card h-100" style={{ color: 'white', backgroundColor: '#1C7AAF', textDecoration: 'underline' }} >
<img src="src/assets/вечернее платье русалка.png" className="cards card-img-top img-fluid" alt="..." />
<div className="card-body">
<a href="#" onClick={ () => { navigate(`/Category/${3}`); }} style={{
color: 'white', backgroundColor: '#1C7AAF', textDecoration: 'underline', fontSize: 'large',
}} > Вечернее платье русалка</a>
</div>
</div>
</div>
<div className="col">
<div id = "list-item-4" className="card h-100" style={{ color: 'white', backgroundColor: '#1C7AAF', textDecoration: 'underline' }} >
<img src="src/assets/вечернее платье ампир.png" className="cards card-img-top img-fluid" alt="..." />
<div className="card-body">
<a href="#" onClick={ () => { navigate(`/Category/${4}`); }} style={{
color: 'white', backgroundColor: '#1C7AAF', textDecoration: 'underline', fontSize: 'large',
}} > Вечернее платье ампир</a>
</div>
</div>
</div>
<div className="col">
<div id = "list-item-5" className="card h-100" style={{ color: 'white', backgroundColor: '#1C7AAF', textDecoration: 'underline' }} >
<img src="src/assets/платье вечернее принцесса.png" className="cards card-img-top img-fluid" alt="..." />
<div className="card-body">
<a href="#" onClick={ () => { navigate(`/Category/${5}`); }} style={{
color: 'white', backgroundColor: '#1C7AAF', textDecoration: 'underline', fontSize: 'large',
}} >Вечернее платье принцесса</a>
</div>
</div>
</div>
<div className="col">
<div id = "list-item-6" className="card h-100" style={{ color: 'white', backgroundColor: '#1C7AAF', textDecoration: 'underline' }} >
<img src="src/assets/платье свадебное пышное.png" className="cards card-img-top img-fluid" alt="..." />
<div className="card-body">
<a href="#" onClick={ () => { navigate(`/Category/${6}`); }} style={{
color: 'white', backgroundColor: '#1C7AAF', textDecoration: 'underline', fontSize: 'large',
}} >Свадебное платье пышное</a>
</div>
</div>
</div>
<div className="col">
<div id = "list-item-7" className="card h-100" style={{ color: 'white', backgroundColor: '#1C7AAF', textDecoration: 'underline' }} >
<img src="src/assets/свадебное платье.png" className="cards card-img-top img-fluid" alt="..." />
<div className="card-body">
<a href="#" onClick={ () => { navigate(`/Category/${7}`); }} style={{
color: 'white', backgroundColor: '#1C7AAF', textDecoration: 'underline', fontSize: 'large',
}} >Свадебное платье прямое</a>
</div>
</div>
</div>
<div className="col">
<div id = "list-item-8" className="card h-100" style={{ color: 'white', backgroundColor: '#1C7AAF', textDecoration: 'underline' }} >
<img src="src/assets/свадебное платье русалка.png" className="cards card-img-top img-fluid" alt="..." />
<div className="card-body">
<a href="#" onClick={ () => { navigate(`/Category/${8}`); }} style={{
color: 'white', backgroundColor: '#1C7AAF', textDecoration: 'underline', fontSize: 'large',
}} >Свадебное платье русалка</a>
</div>
</div>
</div>
<div className="col">
<div id = "list-item-9" className="card h-100" style={{ color: 'white', backgroundColor: '#1C7AAF', textDecoration: 'underline' }} >
<img src="src/assets/свадебное платье ампир.png" className="cards card-img-top img-fluid" alt="..." />
<div className="card-body">
<a href="#" onClick={ () => { navigate(`/Category/${9}`); }} style={{
color: 'white', backgroundColor: '#1C7AAF', textDecoration: 'underline', fontSize: 'large',
}} >Свадебное платье ампир</a>
</div>
</div>
</div>
<div className="col">
<div id = "list-item-10" className="card h-100" style={{ color: 'white', backgroundColor: '#1C7AAF', textDecoration: 'underline' }} >
<img src="src/assets/свадебное платье принцесса.png" className="cards card-img-top img-fluid" alt="..." />
<div className="card-body">
<a href="#" onClick={ () => { navigate(`/Category/${10}`); }} style={{
color: 'white', backgroundColor: '#1C7AAF', textDecoration: 'underline', fontSize: 'large',
}} >Свадебное платье принцесса</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</>
);
};
export default Catalog;

View File

@ -0,0 +1,20 @@
import { useParams } from 'react-router-dom';
import useLines from '../components/lines/hooks/LinesHook.js';
import CardDress from '../components/cards/CardDress.jsx';
const Category = () => {
const { id } = useParams();
const { lines } = useLines(id);
return (
<>
<div className="row row-cols-1 row-cols-md-3 g-4 m-0">
{
lines.map((line) => <CardDress key={line.id} line={line} />)
}
</div>
</>
);
};
export default Category;

View File

@ -0,0 +1,40 @@
import { Row, Container, Col } from 'react-bootstrap';
import Image from 'react-bootstrap/Image';
import map from '../assets/карта.jpg';
import './contacts.css';
const Contacts = () => {
return (
<>
<Container fluid className="container-fluid row p-2 h-100 m-0">
<Container className = "container-fluid m-0">
<Row>
<Col className = "col col-12 col-sm-12 col-md-4 col-lg-4 col-xl-4 map h-75" style={{ height: '75%' }}>
<div className = "h-75 d-flex flex-column justify-content-left align-items-left" style={{ height: '75%' }}>
<Image src ={map} alt="свадебное платье" style = {{ width: '75%' }} className= "img-fluid" />
</div>
</Col>
<Col className = "col col-12 col-sm-12 col-md-4 col-lg-4 col-xl-4 adress" style={{ height: '75%' }}>
<Row>Мы находимся:
г.Ульяновск,</Row>
<Row> ул.Оренбургская, 36 </Row>
<Row>Режим работы:</Row>
<Row>пн.-пт.:
10.00-19.00</Row>
<Row>сб.-вс.:
10.00-17.00</Row>
</Col>
<Col className = "col col-12 col-sm-12 col-md-4 col-lg-4 col-xl-4 contacts" style={{ height: '75%' }}>
<Row>По любым вопросам о товарах звоните:
55-15-10</Row>
<Row>или пишите:
rariryShop@yandex.ru</Row>
</Col>
</Row>
</Container>
</Container>
</>
);
};
export default Contacts;

View File

@ -0,0 +1,19 @@
import { Alert, Button, Container } from 'react-bootstrap';
import { useNavigate } from 'react-router-dom';
const ErrorPage = () => {
const navigate = useNavigate();
return (
<Container fluid className="p-2 row justify-content-center">
<Container className='col-md-6'>
<Alert variant="danger">
Страница не найдена
</Alert>
<Button className="w-25 mt-2" variant="primary" onClick={() => navigate(-1)}>Назад</Button>
</Container>
</Container>
);
};
export default ErrorPage;

View File

@ -0,0 +1,59 @@
import { Row, Container, Col } from 'react-bootstrap';
import Image from 'react-bootstrap/Image';
import eveningDress from '../assets/вечернееплатье.png';
import weddingDress from '../assets/свадебное платье.png';
import threadsNeedle from '../assets/нити и игла.png';
import './mainPage.css';
const MainPage = () => {
return (
<>
<Container fluid className = "container-fluid p-2 , m-0" style={{ display: 'flex', flexDirection: 'column' }}>
<Container fluid className = "container-fluid m-0">
<Row className = "m-0">
<Col className = "col-12">
<h1 className = "text-center title h1" style = {{ color: 'white' }}>
Платья на любую фигуру и торжество от популярного дизайнера!
</h1>
</Col>
</Row>
</Container>
<Container fluid className = "container-fluid m-0" >
<Row className ="row rowAdd, height: '100%', m-0 " style={{ display: 'flex', flexDirection: 'row', height: '100%' }}>
<Col className ="col col-12 col-sm-12 col-md-4 col-lg-4 col-xl-4 add1" style={{ display: 'flex', flexDirection: 'column' }}>
<div className = "text-center" style = {{ color: 'white' }}>
Вечерние платья со скидкой20%
</div>
<div className = "h-100 d-flex flex-column justify-content-center align-items-center" style={{ height: '100%' }}>
<Image src={eveningDress} alt="вечернееплатье" style = {{ width: '25%' }} className = "img-fluid" />
</div>
</Col>
<Col className ="col col-12 col-sm-12 col-md-4 col-lg-4 col-xl-4 add2 " style={{ display: 'flex', flexDirection: 'column' }}>
<div className = "text-center" style = {{ color: 'white' }}>
Бесплатное снятие мерок на свадебное платье каждый вторник
</div>
<div className = "h-100 d-flex flex-column justify-content-center align-items-center" style={{ height: '100%' }}>
<Image src={weddingDress} alt="свадебное платье" style = {{ width: '25%' }} className = "img-fluid" />
</div>
</Col>
<Col className ="col col-12 col-sm-12 col-md-4 col-lg-4 col-xl-4 add3 " style={{ display: 'flex', flexDirection: 'column' }}>
<div className = "text-center" style = {{ color: 'white' }}>
Предоставляем услуги по ремонту платьев
</div>
<div className = "h-100 d-flex flex-column justify-content-center align-items-center" style={{ height: '100%' }}>
<Image src={threadsNeedle} alt="нити и игла" style = {{ width: '75%' }} className = "img-fluid" />
</div>
</Col>
</Row>
</Container>
</Container>
</>
);
};
export default MainPage;

View File

@ -0,0 +1,47 @@
import { useState } from 'react';
import { Button, Form, Container } from 'react-bootstrap';
const OrderPage = () => {
const [validated, setValidated] = useState(false);
const handleSubmit = (event) => {
const form = event.currentTarget;
if (form.checkValidity() === false) {
event.preventDefault();
event.stopPropagation();
}
setValidated(true);
};
return (
<>
<Container fluid className="container-fluid p-2" style = {{ color: 'white' }}>
<div className="row justify-content-center">
<Form className="col-md-6 m-0" noValidate validated={validated} onSubmit={handleSubmit}>
<Form.Group className="mb-2" controlId="firstname" >
<Form.Label>Имя</Form.Label>
<Form.Control type="text" name="firstname" required />
</Form.Group>
<Form.Group className="mb-2" controlId="email">
<Form.Label>Отчество</Form.Label>
<Form.Control type="email" name="email" required />
</Form.Group>
<Form.Group className="mb-2" controlId="password" >
<Form.Label>Номер карты</Form.Label>
<Form.Control type="password" name="password" required />
</Form.Group>
<Form.Group className="mb-2" controlId="password" >
<Form.Label>CVC</Form.Label>
<Form.Control type="password" name="passwordAgain" required />
</Form.Group>
<div className="text-center">
<Button className="w-50" variant="primary" type="submit">Купить</Button>
</div>
</Form>
</div>
</Container>
</>
);
};
export default OrderPage;

View File

@ -0,0 +1,53 @@
import { useState } from 'react';
import { Button, Form } from 'react-bootstrap';
import { Link } from 'react-router-dom';
const PageEdit = () => {
const [validated, setValidated] = useState(false);
const handleSubmit = (event) => {
const form = event.currentTarget;
if (form.checkValidity() === false) {
event.preventDefault();
event.stopPropagation();
}
setValidated(true);
};
return (
<>
<div className="text-center">
<img id="image-preview" src="https://via.placeholder.com/200" className="rounded rounded-circle"
alt="placeholder" />
</div>
<Form id="items-form" noValidate validated={validated} onSubmit={handleSubmit}>
<Form.Group className="mb-2" controlId="item">
<Form.Label htmlFor="item" className="form-label">Товары</Form.Label>
<Form.Select name='selected' required>
</Form.Select>
</Form.Group>
<Form.Group className="mb-2" controlId="price">
<Form.Label>Цена</Form.Label>
<Form.Control type="number" name="price"
value="0.00" min="1000.00" step="0.50" required />
</Form.Group>
<Form.Group className="mb-2" controlId="count">
<Form.Label>Количество</Form.Label>
<Form.Control type="number" name="count"
value="0" min="1" step="1" required />
</Form.Group>
<Form.Group className="mb-2" controlId="file">
<Form.Label>Изображение</Form.Label>
<Form.Control type="file" name="image" accept="image/*" />
</Form.Group>
<Form.Group className="d-flex flex-md-row flex-column justify-content-center">
<Button className="btn-mw me-md-3 mb-md-0 mb-2" as={Link} to="/Category" variant="secondary">Назад</Button>
<Button className="btn-mw me-md-3" type="submit" variant="primary">Сохранить</Button>
</Form.Group>
</Form>
</>
);
};
export default PageEdit;

View File

@ -0,0 +1,48 @@
import { useParams } from 'react-router-dom';
import PropTypes from 'prop-types';
import useLinesItem from '../components/lines/hooks/LinesItemHook';
import SelectSize from '../components/input/SelectSize.jsx';
import useSizes from '../components/types/hooks/SizesHook';
import useCart from '../components/cart/CartHook';
const ProductPage = () => {
const { sizes, currentFilter, handleFilterChange } = useSizes();
const { id } = useParams();
const { item } = useLinesItem(id);
const { addToCart } = useCart();
const change = (event) => {
handleFilterChange(event, item);
};
return (
<>
<div className = "row m-0">
<div className = "col col-12 col-sm-12 col-md-6 col-lg-6 col-xl-6 map h-75">
<div className = "h-75 d-flex flex-column justify-content-left align-items-left">
<img src = {item.image} className="w-75 img-fluid" alt = "..." />
</div>
</div>
<div className = "col col-12 col-sm-12 col-md-6 col-lg-6 col-xl-6 adress h-75">
<div className="text-center nameline">
{item.nameItem}
</div>
<div className="cable-config">Выберите размер
<SelectSize values={sizes} name='typeId' value={currentFilter} onChange={change}
required />
</div>
<div className="product-price">{item.price} руб.
<button type="button" className="btn btn-primary btn-lg">
{/* <Link className="nav-link active" to="/Buscket">В корзину</Link> */}
<a href="#" onClick={() => { addToCart(item); } }> В корзину </a>
</button>
</div>
</div>
</div>
</>
);
};
ProductPage.propTypes = {
item: PropTypes.object,
handleChange: PropTypes.func,
};
export default ProductPage;

View File

@ -0,0 +1,47 @@
import { useState } from 'react';
import { Button, Form, Container } from 'react-bootstrap';
const Registration = () => {
const [validated, setValidated] = useState(false);
const handleSubmit = (event) => {
const form = event.currentTarget;
if (form.checkValidity() === false) {
event.preventDefault();
event.stopPropagation();
}
setValidated(true);
};
return (
<>
<Container fluid className="container-fluid p-2" style = {{ color: 'white' }}>
<div className="row justify-content-center">
<Form className="col-md-6 m-0" noValidate validated={validated} onSubmit={handleSubmit}>
<Form.Group className="mb-2" controlId="firstname" >
<Form.Label>Логин</Form.Label>
<Form.Control type="text" name="firstname" required />
</Form.Group>
<Form.Group className="mb-2" controlId="email">
<Form.Label>E-mail</Form.Label>
<Form.Control type="email" name="email" required />
</Form.Group>
<Form.Group className="mb-2" controlId="password" >
<Form.Label>Пароль</Form.Label>
<Form.Control type="password" name="password" required />
</Form.Group>
<Form.Group className="mb-2" controlId="password" >
<Form.Label>Повторите пароль</Form.Label>
<Form.Control type="password" name="passwordAgain" required />
</Form.Group>
<div className="text-center">
<Button className="w-50" variant="primary" type="submit">Зарегистрироваться</Button>
</div>
</Form>
</div>
</Container>
</>
);
};
export default Registration;

View File

@ -0,0 +1,9 @@
.t1{
background-color: #5C00A4 !important;
color: white !important;
}
.hat{
background-color: #1C7AAF !important;
}

View File

@ -0,0 +1,9 @@
.t1{
background-color: #5C00A4 !important;
color: white !important;
}
.hat{
background-color: #1C7AAF !important;
}

View File

@ -0,0 +1,9 @@
.pict{
padding-top: 5%;
padding-left: 5%;
padding-bottom: 5%;
}
.mydress{
background-color: #5C00A4;
color:#ffffff;
}

View File

@ -0,0 +1,6 @@
.cards{
height: 400px;
width: auto;
object-fit: cover;
}

View File

@ -0,0 +1,14 @@
.adress{
color:#ffffff;
font-size: x-large;
}
.contacts{
color:#ffffff;
font-size: x-large;
}
.row{
margin-top: 5%;
}
.p{
margin-bottom: 20%;
}

View File

@ -0,0 +1,69 @@
.body{
background-image: url(assets/фон.jpg);
}
@font-face{
font-family: 'cursive';
src: url("assets/monotypecorsiva.ttf");
}
*{
font-family: 'cursive';
}
.header nav {
background-color: #5C00A4;
}
.img{
width: 94px;
height: 74px;
}
@media (min-width: 768px) {
header nav {
height: 100px;
}
}
.header nav a:hover {
text-decoration: underline;
font-size: large;
}
.footer {
background-color: #5C00A4;
height: 32px;
color: #ffffff;
}
.h1 {
/* font-size: 64em; */
background-color: #1C7AAF;
color: #ffffff;
}
.add1{
background-color: #50028C;
font-size: large;
}
.add2{
background-color: #8354A8;
font-size: large;
}
.add3{
background-color: #50028C;
font-size: large;
}

View File

@ -0,0 +1,19 @@
import { Button, ButtonGroup } from 'react-bootstrap';
import { Link } from 'react-router-dom';
<ButtonGroup>
<Button id="items-add" variant="info">Добавить товар (диалог)</Button>
<Button variant="info"><Link className="nav-link active" to="/Autorization">Выйти</Link> </Button>
</ButtonGroup>
<table className="mt-2 table-primary table-bordered w-100 t1">
<thead className = "table hat">
<tr>
<th scope="col"></th>
<th scope="col" className="w-25">Категория</th>
<th scope="col" className="w-25">Цена</th>
<th scope="col" className="w-25">Название</th>
<th scope="col"></th>
<th scope="col"></th>
</tr>
</thead>
<tbody></tbody>
</table>

View File

@ -0,0 +1,13 @@
/* eslint-disable import/no-extraneous-dependencies */
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
build: {
sourcemap: true,
chunkSizeWarningLimit: 1024,
emptyOutDir: true,
},
});