ЛР5
30
Лаб5/.eslintrc.cjs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
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: {
|
||||||
|
"import/extensions": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"js": "ignorePackages"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'react-refresh/only-export-components': [
|
||||||
|
'warn',
|
||||||
|
{ allowConstantExport: true },
|
||||||
|
],
|
||||||
|
'indent': 'off',
|
||||||
|
'no-console': 'off',
|
||||||
|
'arrow-body-style': 'off',
|
||||||
|
'implicit-arrow-linebreak': 'off',
|
||||||
|
},
|
||||||
|
}
|
24
Лаб5/.gitignore
vendored
Normal 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?
|
47
Лаб5/README.md
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
### Окружение:
|
||||||
|
- [nodejs 20 LTS latest](https://nodejs.org/en/download/);
|
||||||
|
- [VSCode](https://code.visualstudio.com/download);
|
||||||
|
- [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) плагин для VSCode;
|
||||||
|
- [CSS Class Intellisense](https://marketplace.visualstudio.com/items?itemName=Tarrow.css-class-intellisense) плагин для автодополнения CSS-классов в HTML;
|
||||||
|
- для отладки необходимы бразузеры Chrome или Edge.
|
||||||
|
|
||||||
|
Настройки плагина CSS Class Intellisense находятся в файле ./vscode/cssconfig.json
|
||||||
|
|
||||||
|
### Команды
|
||||||
|
|
||||||
|
#### Создание пустого проекта:
|
||||||
|
|
||||||
|
```commandline
|
||||||
|
npm create vite@latest ./ -- --template react
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Установка зависимостей:
|
||||||
|
|
||||||
|
```commandline
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Запуск проекта в режиме разработки (development):
|
||||||
|
|
||||||
|
```commandline
|
||||||
|
npm run dev
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Запуск проекта в продуктовом режиме (production):
|
||||||
|
|
||||||
|
```commandline
|
||||||
|
npm run prod
|
||||||
|
```
|
||||||
|
|
||||||
|
### Полезные ссылки
|
||||||
|
|
||||||
|
1. Updating Objects in State - https://react.dev/learn/updating-objects-in-state
|
||||||
|
2. Sharing State Between Components - https://react.dev/learn/sharing-state-between-components
|
||||||
|
3. React Hot Toast - https://react-hot-toast.com
|
||||||
|
4. Axios - https://axios-http.com
|
||||||
|
5. Axios & Error handling like a boss - https://dev.to/mperon/axios-error-handling-like-a-boss-333d
|
||||||
|
6. Separation of Concerns in React –How to Use Container and Presentational Components - https://www.freecodecamp.org/news/separation-of-concerns-react-container-and-presentational-components/
|
||||||
|
7. Separation of concerns in React and React Native - https://dev.to/sathishskdev/separation-of-concerns-in-react-and-react-native-45b7
|
||||||
|
8. React Bootstrap - https://react-bootstrap.netlify.app
|
||||||
|
9. React Bootstrap Icons - https://github.com/ismamz/react-bootstrap-icons
|
||||||
|
10. JSON Server - https://www.npmjs.com/package/json-server
|
198
Лаб5/data.json
Normal file
15
Лаб5/index.html
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<html lang="ru">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<link rel="icon" type="image/svg+xml" href="./src/assets/logo.png" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>Wash Me</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div id="root" class="h-100 d-flex flex-column"></div>
|
||||||
|
<script type="module" src="/src/main.jsx"></script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
15
Лаб5/jsconfig.json
Normal 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/*"
|
||||||
|
]
|
||||||
|
}
|
5
Лаб5/json-server.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"static": "./node_modules/json-server/public",
|
||||||
|
"port": 8081,
|
||||||
|
"watch": "true"
|
||||||
|
}
|
5936
Лаб5/package-lock.json
generated
Normal file
38
Лаб5/package.json
Normal 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": {
|
||||||
|
"react": "^18.2.0",
|
||||||
|
"react-dom": "^18.2.0",
|
||||||
|
"react-router-dom": "^6.18.0",
|
||||||
|
"react-hot-toast": "^2.4.1",
|
||||||
|
"axios": "^1.6.1",
|
||||||
|
"bootstrap": "^5.3.2",
|
||||||
|
"react-bootstrap": "^2.9.1",
|
||||||
|
"react-bootstrap-icons": "^1.10.3",
|
||||||
|
"prop-types": "^15.8.1"
|
||||||
|
},
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
3
Лаб5/public/favicon.svg
Normal 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 |
25
Лаб5/src/App.jsx
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import { Container } from 'react-bootstrap';
|
||||||
|
import { Toaster } from 'react-hot-toast';
|
||||||
|
import { Outlet } from 'react-router-dom';
|
||||||
|
import Footer from './components/footer/Footer.jsx';
|
||||||
|
import Navigation from './components/navigation/Navigation.jsx';
|
||||||
|
|
||||||
|
const App = ({ routes }) => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Navigation routes={routes}></Navigation>
|
||||||
|
<Container className='p-2 pageBackground' as='main' fluid>
|
||||||
|
<Outlet />
|
||||||
|
</Container>
|
||||||
|
<Footer />
|
||||||
|
<Toaster position='top-center' reverseOrder={true} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
App.propTypes = {
|
||||||
|
routes: PropTypes.array,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default App;
|
BIN
Лаб5/src/assets/1.jpg
Normal file
After Width: | Height: | Size: 102 KiB |
BIN
Лаб5/src/assets/2.jpg
Normal file
After Width: | Height: | Size: 89 KiB |
BIN
Лаб5/src/assets/200.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
Лаб5/src/assets/3.jpg
Normal file
After Width: | Height: | Size: 115 KiB |
BIN
Лаб5/src/assets/4.jpg
Normal file
After Width: | Height: | Size: 115 KiB |
BIN
Лаб5/src/assets/5.jpg
Normal file
After Width: | Height: | Size: 116 KiB |
BIN
Лаб5/src/assets/AccountIcon.jpg
Normal file
After Width: | Height: | Size: 5.3 KiB |
BIN
Лаб5/src/assets/Label.jpg
Normal file
After Width: | Height: | Size: 84 KiB |
BIN
Лаб5/src/assets/Main1.jpg
Normal file
After Width: | Height: | Size: 3.2 MiB |
BIN
Лаб5/src/assets/Map.png
Normal file
After Width: | Height: | Size: 100 KiB |
BIN
Лаб5/src/assets/TogglerIcon.jpg
Normal file
After Width: | Height: | Size: 7.6 KiB |
BIN
Лаб5/src/assets/logo.png
Normal file
After Width: | Height: | Size: 85 KiB |
BIN
Лаб5/src/assets/placeHolder.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
Лаб5/src/assets/trash.png
Normal file
After Width: | Height: | Size: 577 B |
40
Лаб5/src/components/Galerey/Galerey.jsx
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
import useTypeFilter from '../lines/hooks/LinesFilterHook.js';
|
||||||
|
import useLines from '../lines/hooks/LinesHook.js';
|
||||||
|
import GalereyForm from './GalereyForm.jsx';
|
||||||
|
import GalereyCard from './GalereyCard.jsx';
|
||||||
|
import useLinesFormModal from '../lines/hooks/LinesFormModalHook';
|
||||||
|
import ModalFormGalerey from '../modal/ModalFormGalerey.jsx';
|
||||||
|
import GalereyImageForm from './GalereyImageForm.jsx';
|
||||||
|
|
||||||
|
const Galerey = () => {
|
||||||
|
const { currentFilter } = useTypeFilter();
|
||||||
|
const { lines, handleLinesChange } = useLines(currentFilter);
|
||||||
|
const {
|
||||||
|
isFormModalShow,
|
||||||
|
isFormValidated,
|
||||||
|
showFormModal,
|
||||||
|
currentItem,
|
||||||
|
handleItemChange,
|
||||||
|
handleFormSubmit,
|
||||||
|
handleFormClose,
|
||||||
|
} = useLinesFormModal(handleLinesChange);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='container mx-auto rounded-8 fw-bold Galerey scrollableContainer'>
|
||||||
|
<GalereyForm>
|
||||||
|
{
|
||||||
|
lines.map((line) =>
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
<GalereyCard key={line.id} line={line} onClick={() => showFormModal(line.id)}/>)
|
||||||
|
}
|
||||||
|
</GalereyForm>
|
||||||
|
<ModalFormGalerey show={isFormModalShow} validated={isFormValidated}
|
||||||
|
onSubmit={handleFormSubmit} onClose={handleFormClose}
|
||||||
|
title='Изображение'>
|
||||||
|
<GalereyImageForm item={currentItem} handleChange={handleItemChange} />
|
||||||
|
</ModalFormGalerey>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Galerey;
|
31
Лаб5/src/components/Galerey/GalereyCard.jsx
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import { Button } from 'react-bootstrap';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import placeHolder from '../../assets/placeHolder.png';
|
||||||
|
|
||||||
|
const GalereyCard = ({ line, onClick }) => {
|
||||||
|
const handleButtonClick = (event, action) => {
|
||||||
|
event.preventDefault();
|
||||||
|
action();
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="height-420">
|
||||||
|
<div className="my-3 fs-5 fw-bold GalereyCard">
|
||||||
|
<img src={line.image || placeHolder} className="my-3 rounded-8" alt="image" height="200" /><br/>
|
||||||
|
<Button className="rounded-pill btn-lg text-light mt-2 fs-10" onClick={(event) => handleButtonClick(event, onClick)}>
|
||||||
|
Посмотреть
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GalereyCard.propTypes = {
|
||||||
|
line: PropTypes.object,
|
||||||
|
sum: PropTypes.string,
|
||||||
|
count: PropTypes.string,
|
||||||
|
image: PropTypes.string,
|
||||||
|
onClick: PropTypes.func,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default GalereyCard;
|
19
Лаб5/src/components/Galerey/GalereyForm.jsx
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import { Container } from 'react-bootstrap';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
|
const GalereyForm = ({ children }) => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Container className='width-90 mx-auto my-5'>
|
||||||
|
<div className='row row-cols-xl-3 row-cols-md-2 row-cols-1 pd-3 text-center text-secondary-emphasis'>
|
||||||
|
{ children }
|
||||||
|
</div>
|
||||||
|
</Container>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
GalereyForm.propTypes = {
|
||||||
|
children: PropTypes.node,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default GalereyForm;
|
3
Лаб5/src/components/Galerey/GalereyImageForm.css
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#image {
|
||||||
|
width: 1000px;
|
||||||
|
}
|
21
Лаб5/src/components/Galerey/GalereyImageForm.jsx
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import imgPlaceholder from '../../assets/200.png';
|
||||||
|
import './GalereyImageForm.css';
|
||||||
|
|
||||||
|
const LinesItemForm = ({ item }) => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className='text-center'>
|
||||||
|
<img id='image' className='rounded hystmodal img' alt='placeholder' sizes='300%'
|
||||||
|
src={item.image || imgPlaceholder} />
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
LinesItemForm.propTypes = {
|
||||||
|
item: PropTypes.object,
|
||||||
|
handleChange: PropTypes.func,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default LinesItemForm;
|
45
Лаб5/src/components/Galerey/hooks/GalereyFormModalHook.js
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import { useState } from 'react';
|
||||||
|
import useModal from '../../modal/ModalHook.js';
|
||||||
|
import useCoursesItemForm from './GalereyItemFormHook.js';
|
||||||
|
|
||||||
|
const useCoursesFormModal = (reviewsChangeHandle) => {
|
||||||
|
const { isModalShow, showModal, hideModal } = useModal();
|
||||||
|
const [currentId, setCurrentId] = useState(0);
|
||||||
|
|
||||||
|
const {
|
||||||
|
item,
|
||||||
|
validated,
|
||||||
|
handleSubmit,
|
||||||
|
handleChange,
|
||||||
|
resetValidity,
|
||||||
|
} = useCoursesItemForm(currentId, reviewsChangeHandle);
|
||||||
|
|
||||||
|
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 useCoursesFormModal;
|
61
Лаб5/src/components/Galerey/hooks/GalereyItemFormHook.js
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
import { useState } from 'react';
|
||||||
|
import toast from 'react-hot-toast';
|
||||||
|
import LinesApiService from '../../lines/service/LinesApiService.js';
|
||||||
|
import useReviewsItem from './GalereyItemHook.js';
|
||||||
|
|
||||||
|
const useReviewsItemForm = (id, linesChangeHandle) => {
|
||||||
|
const { item, setItem } = useReviewsItem(id);
|
||||||
|
|
||||||
|
const [validated, setValidated] = useState(false);
|
||||||
|
|
||||||
|
const resetValidity = () => {
|
||||||
|
setValidated(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const getReviewObject = (formData) => {
|
||||||
|
const { name } = formData;
|
||||||
|
const { text } = formData;
|
||||||
|
return {
|
||||||
|
name: name.toString(),
|
||||||
|
text: text.toString(),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleChange = (event) => {
|
||||||
|
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 = getReviewObject(item);
|
||||||
|
if (form.checkValidity()) {
|
||||||
|
if (id === undefined) {
|
||||||
|
await LinesApiService.create(body);
|
||||||
|
} else {
|
||||||
|
await LinesApiService.update(id, body);
|
||||||
|
}
|
||||||
|
if (linesChangeHandle) linesChangeHandle();
|
||||||
|
toast.success('Отзыв успешно сохранен', { id: 'Reviews' });
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
setValidated(true);
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
item,
|
||||||
|
validated,
|
||||||
|
handleSubmit,
|
||||||
|
handleChange,
|
||||||
|
resetValidity,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default useReviewsItemForm;
|
34
Лаб5/src/components/Galerey/hooks/GalereyItemHook.js
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import LinesApiService from '../../lines/service/LinesApiService';
|
||||||
|
|
||||||
|
const useLinesItem = (id) => {
|
||||||
|
const emptyItem = {
|
||||||
|
id: '',
|
||||||
|
typeId: '',
|
||||||
|
price: '0',
|
||||||
|
count: '0',
|
||||||
|
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;
|
15
Лаб5/src/components/Galerey/hooks/InputComponent.jsx
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import useInputValue from './InputValueHook.js';
|
||||||
|
|
||||||
|
const InputComponent = () => {
|
||||||
|
const input = useInputValue('');
|
||||||
|
|
||||||
|
return (
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
value={input.value}
|
||||||
|
onChange={input.onChange}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default InputComponent;
|
34
Лаб5/src/components/Galerey/hooks/InputValueHook.js
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import { useState } from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
|
const useInputValue = () => {
|
||||||
|
const emptyReqvest = {
|
||||||
|
name: '',
|
||||||
|
tel: '',
|
||||||
|
};
|
||||||
|
const [reqvest, setReqvest] = useState({ ...emptyReqvest });
|
||||||
|
const handleChange = (event) => {
|
||||||
|
const inputName = event.target.name;
|
||||||
|
const inputValue = event.target.type === 'checkbox' ? event.target.checked : event.target.value;
|
||||||
|
setReqvest({
|
||||||
|
...reqvest,
|
||||||
|
[inputName]: inputValue,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const onClick = () => {
|
||||||
|
if (reqvest) { localStorage.setItem('inputValue', `Имя: ${reqvest.name} || Номер телефона: ${reqvest.tel}`); }
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
reqvest,
|
||||||
|
onChange: handleChange,
|
||||||
|
onClick,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
useInputValue.propType = {
|
||||||
|
name: PropTypes.string,
|
||||||
|
tel: PropTypes.string,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default useInputValue;
|
40
Лаб5/src/components/api/ApiClient.js
Normal 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);
|
29
Лаб5/src/components/api/ApiService.js
Normal 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;
|
22
Лаб5/src/components/footer/Footer.jsx
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import './footer.css';
|
||||||
|
|
||||||
|
const Footer = () => {
|
||||||
|
const year = new Date().getFullYear();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<footer className='footer-style mt-auto d-flex flex-shrink-0 justify-content-center align-items-center'>
|
||||||
|
<div className="container">
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-sm text-center text-sm-start text-light fw-bold fs-6">
|
||||||
|
Контакты: <br/>
|
||||||
|
8-800-535-3535 <br/>
|
||||||
|
avtomoyka73@mail.ru<br/>
|
||||||
|
<div className='f'>Авторское право © {year} Нияз Юнусов. Все права защищены.</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Footer;
|
10
Лаб5/src/components/footer/footer.css
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
.footer-style{
|
||||||
|
position: sticky !important;
|
||||||
|
top: 90px !important;
|
||||||
|
background-color: #184fbd !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
f{
|
||||||
|
font-size: 8px;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
23
Лаб5/src/components/input/Input.jsx
Normal 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;
|
29
Лаб5/src/components/input/Select.jsx
Normal 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;
|
48
Лаб5/src/components/lines/form/LinesForm.jsx
Normal 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;
|
3
Лаб5/src/components/lines/form/LinesItemForm.css
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#image-preview {
|
||||||
|
width: 200px;
|
||||||
|
}
|
34
Лаб5/src/components/lines/form/LinesItemForm.jsx
Normal 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='200.0' step='0.50' required />
|
||||||
|
<Input name='count' label='Скидка' value={item.count} onChange={handleChange}
|
||||||
|
type='number' min='0' max='100' step='1' required />
|
||||||
|
<Input name='image' label='Изображение' onChange={handleChange}
|
||||||
|
type='file' accept='image/*' />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
LinesItemForm.propTypes = {
|
||||||
|
item: PropTypes.object,
|
||||||
|
handleChange: PropTypes.func,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default LinesItemForm;
|
34
Лаб5/src/components/lines/hooks/LinesDeleteModalHook.js
Normal 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;
|
28
Лаб5/src/components/lines/hooks/LinesFilterHook.js
Normal 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;
|
45
Лаб5/src/components/lines/hooks/LinesFormModalHook.js
Normal 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;
|
29
Лаб5/src/components/lines/hooks/LinesHook.js
Normal 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;
|
81
Лаб5/src/components/lines/hooks/LinesItemFormHook.js
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
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 count = parseInt(formData.count, 10);
|
||||||
|
const sum = parseFloat(((100 - count) * price) / 100).toFixed(2);
|
||||||
|
const image = formData.image.startsWith('data:image') ? formData.image : '';
|
||||||
|
return {
|
||||||
|
typeId: typeId.toString(),
|
||||||
|
price: price.toString(),
|
||||||
|
count: count.toString(),
|
||||||
|
sum: sum.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;
|
34
Лаб5/src/components/lines/hooks/LinesItemHook.js
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import LinesApiService from '../service/LinesApiService';
|
||||||
|
|
||||||
|
const useLinesItem = (id) => {
|
||||||
|
const emptyItem = {
|
||||||
|
id: '',
|
||||||
|
typeId: '',
|
||||||
|
price: '0',
|
||||||
|
count: '0',
|
||||||
|
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;
|
5
Лаб5/src/components/lines/service/LinesApiService.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import ApiService from '../../api/ApiService';
|
||||||
|
|
||||||
|
const LinesApiService = new ApiService('lines');
|
||||||
|
|
||||||
|
export default LinesApiService;
|
66
Лаб5/src/components/lines/table/Lines.jsx
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
import { Button, ButtonGroup } from 'react-bootstrap';
|
||||||
|
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>
|
||||||
|
</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;
|
29
Лаб5/src/components/lines/table/LinesTable.jsx
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import { Table } from 'react-bootstrap';
|
||||||
|
|
||||||
|
const LinesTable = ({ children }) => {
|
||||||
|
return (
|
||||||
|
<Table className='mt-2' striped responsive>
|
||||||
|
<thead>
|
||||||
|
<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' 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;
|
33
Лаб5/src/components/lines/table/LinesTableRow.jsx
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
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.count}</td>
|
||||||
|
<td>{parseFloat(line.sum).toFixed(2)}</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,
|
||||||
|
onEditInPage: PropTypes.func,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default LinesTableRow;
|
48
Лаб5/src/components/linesPrice/form/LinesForm.jsx
Normal 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 formStyle formSizeStyle rounded-8 mx-auto' 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 dark-grey rounded-pill text-light' onClick={() => onBack()}>
|
||||||
|
Назад
|
||||||
|
</Button>
|
||||||
|
<Button className='col-5 col-lg-2 m-0 ms-2 purple rounded-pill text-light' type='submit'>
|
||||||
|
Сохранить
|
||||||
|
</Button>
|
||||||
|
</Form.Group>
|
||||||
|
</Form>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
LinesForm.propTypes = {
|
||||||
|
id: PropTypes.string,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default LinesForm;
|
3
Лаб5/src/components/linesPrice/form/LinesItemForm.css
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#image-preview {
|
||||||
|
width: 200px;
|
||||||
|
}
|
35
Лаб5/src/components/linesPrice/form/LinesItemForm.jsx
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import imgPlaceholder from '../../../assets/placeHolder.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 className='rounded-8' alt='placeholder'
|
||||||
|
src={item.image || imgPlaceholder} height={200} />
|
||||||
|
</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='200.0' step='0.50' required />
|
||||||
|
<Input name='count' label='Скидка' value={item.count} onChange={handleChange}
|
||||||
|
type='number' min='0' max='100' step='1' required />
|
||||||
|
<Input name='image' label='Изображение' onChange={handleChange}
|
||||||
|
type='file' accept='image/*' />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
LinesItemForm.propTypes = {
|
||||||
|
item: PropTypes.object,
|
||||||
|
handleChange: PropTypes.func,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default LinesItemForm;
|
13
Лаб5/src/components/linesPrice/form/LogIn.jsx
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import Input from '../../input/Input.jsx';
|
||||||
|
import PropTypes from "prop-types";
|
||||||
|
|
||||||
|
const LogIn = () => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Input label="Имя" name='name' className='light-grey' type='string' required/>
|
||||||
|
<Input label='Пароль' name='password' className='light-grey' type='string' required/>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default LogIn;
|
15
Лаб5/src/components/linesPrice/form/NewReview.jsx
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import PropTypes from "prop-types";
|
||||||
|
import {Textarea} from "react-bootstrap-icons";
|
||||||
|
|
||||||
|
const NewReview = ({handleChange}) => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Textarea label='Текст Отзыва' name='review' className='light-grey' type='text' onChange={handleChange} required/>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
NewReview.propTypes ={
|
||||||
|
handleChange: PropTypes.func,
|
||||||
|
}
|
||||||
|
export default NewReview;
|
14
Лаб5/src/components/linesPrice/form/Register.jsx
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import Input from '../../input/Input.jsx';
|
||||||
|
import PropTypes from "prop-types";
|
||||||
|
|
||||||
|
const Register = () => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Input label="Имя" name='name' className='light-grey' type='string' required/>
|
||||||
|
<Input label="Адрес электронной почты" name='mail' className='light-grey' type='string' required/>
|
||||||
|
<Input label='Пароль' name='password' className='light-grey' type='string' required/>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Register;
|
34
Лаб5/src/components/linesPrice/hooks/LinesDeleteModalHook.js
Normal 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;
|
28
Лаб5/src/components/linesPrice/hooks/LinesFilterHook.js
Normal 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;
|
45
Лаб5/src/components/linesPrice/hooks/LinesFormModalHook.js
Normal 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;
|
29
Лаб5/src/components/linesPrice/hooks/LinesHook.js
Normal 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;
|
85
Лаб5/src/components/linesPrice/hooks/LinesItemFormHook.js
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
import { useState } from 'react';
|
||||||
|
import toast from 'react-hot-toast';
|
||||||
|
import getBase64FromFile from '../../utils/Base64';
|
||||||
|
import LinesApiService from '../service/LinesApiService';
|
||||||
|
import useLinesItem from './LinesItemHook';
|
||||||
|
import useTypes from '../../types/hooks/TypesHook.js';
|
||||||
|
|
||||||
|
const useLinesItemForm = (id, linesChangeHandle) => {
|
||||||
|
const { item, setItem } = useLinesItem(id);
|
||||||
|
const { types } = useTypes();
|
||||||
|
|
||||||
|
const [validated, setValidated] = useState(false);
|
||||||
|
|
||||||
|
const resetValidity = () => {
|
||||||
|
setValidated(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const getLineObject = (formData) => {
|
||||||
|
const typeId = parseInt(formData.typeId, 10);
|
||||||
|
const price = parseFloat(formData.price);
|
||||||
|
const count = parseInt(formData.count, 10);
|
||||||
|
const sum = parseFloat(((100 - count) * price) / 100);
|
||||||
|
const benefit = parseFloat((types.at(formData.typeId - 1).basePrice - price) * count);
|
||||||
|
const image = formData.image.startsWith('data:image') ? formData.image : '';
|
||||||
|
return {
|
||||||
|
typeId: typeId.toString(),
|
||||||
|
price: price.toString(),
|
||||||
|
count: count.toString(),
|
||||||
|
sum: sum.toString(),
|
||||||
|
benefit: benefit.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;
|
34
Лаб5/src/components/linesPrice/hooks/LinesItemHook.js
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import LinesApiService from '../service/LinesApiService';
|
||||||
|
|
||||||
|
const useLinesItem = (id) => {
|
||||||
|
const emptyItem = {
|
||||||
|
id: '',
|
||||||
|
typeId: '',
|
||||||
|
price: '0',
|
||||||
|
count: '0',
|
||||||
|
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;
|
@ -0,0 +1,5 @@
|
|||||||
|
import ApiService from '../../api/ApiService';
|
||||||
|
|
||||||
|
const LinesApiService = new ApiService('lines');
|
||||||
|
|
||||||
|
export default LinesApiService;
|
48
Лаб5/src/components/linesPrice/table/Lines.jsx
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
import Select from '../../input/Select.jsx';
|
||||||
|
import ModalForm from '../../modal/ModalForm.jsx';
|
||||||
|
import useLinesDeleteModal from '../hooks/LinesDeleteModalHook';
|
||||||
|
import useLinesFormModal from '../hooks/LinesFormModalHook';
|
||||||
|
import useTypeFilter from '../hooks/LinesFilterHook';
|
||||||
|
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 {
|
||||||
|
showDeleteModal,
|
||||||
|
} = useLinesDeleteModal(handleLinesChange);
|
||||||
|
|
||||||
|
const {
|
||||||
|
isFormModalShow,
|
||||||
|
isFormValidated,
|
||||||
|
showFormModal,
|
||||||
|
handleFormSubmit,
|
||||||
|
handleFormClose,
|
||||||
|
} = useLinesFormModal(handleLinesChange);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='rounded-8 mx-auto p-2'>
|
||||||
|
<Select className='mt-2' values={types} label='Фильтр по услугам'
|
||||||
|
value={currentFilter} onChange={handleFilterChange} />
|
||||||
|
<LinesTable>
|
||||||
|
{
|
||||||
|
lines.map((line, index) =>
|
||||||
|
<LinesTableRow key={line.id}
|
||||||
|
index={index} line={line}
|
||||||
|
onEdit={() => showFormModal(line.id)}
|
||||||
|
onDelete={() => showDeleteModal(line.id)}
|
||||||
|
/>)
|
||||||
|
}
|
||||||
|
</LinesTable>
|
||||||
|
<ModalForm show={isFormModalShow} validated={isFormValidated}
|
||||||
|
onSubmit={handleFormSubmit} onClose={handleFormClose}
|
||||||
|
title='Скидка'>
|
||||||
|
</ModalForm>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Lines;
|
27
Лаб5/src/components/linesPrice/table/LinesTable.jsx
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import { Table } from 'react-bootstrap';
|
||||||
|
|
||||||
|
const LinesTable = ({ children }) => {
|
||||||
|
return (
|
||||||
|
<div className='overflow-x-auto hfitcon maxh-400 p-0 mx-auto PricePage'>
|
||||||
|
<Table className="table" striped responsive>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col" className="fw-bold text-center no-color">№</th>
|
||||||
|
<th scope="col" className="w-25 fw-bold text-center no-color">Услуга</th>
|
||||||
|
<th scope="col" className="w-25 fw-bold text-center no-color">Сумма</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody className="fw-bold overflow-y-scroll">
|
||||||
|
{children}
|
||||||
|
</tbody>
|
||||||
|
</Table>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
LinesTable.propTypes = {
|
||||||
|
children: PropTypes.node,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default LinesTable;
|
22
Лаб5/src/components/linesPrice/table/LinesTableRow.jsx
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
|
const LinesTableRow = ({
|
||||||
|
index, line,
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
|
<tr className='no-color'>
|
||||||
|
<th className='no-color text-center' scope="row">{index + 1}</th>
|
||||||
|
<td className='no-color text-center'> {line.type.name}</td>
|
||||||
|
<td className='no-color text-center'>{parseFloat(line.sum).toFixed(2)}</td>
|
||||||
|
</tr>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
LinesTableRow.propTypes = {
|
||||||
|
index: PropTypes.number,
|
||||||
|
line: PropTypes.object,
|
||||||
|
onDelete: PropTypes.func,
|
||||||
|
onEditInPage: PropTypes.func,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default LinesTableRow;
|
6
Лаб5/src/components/modal/Modal.css
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
.modal-title {
|
||||||
|
font-size: 1.2rem;
|
||||||
|
}
|
||||||
|
#image-previe{
|
||||||
|
width: 1100px;
|
||||||
|
}
|
42
Лаб5/src/components/modal/ModalConfirm.jsx
Normal 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;
|
43
Лаб5/src/components/modal/ModalForm.jsx
Normal 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;
|
34
Лаб5/src/components/modal/ModalFormGalerey.jsx
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import { Form, Modal } from 'react-bootstrap';
|
||||||
|
import { createPortal } from 'react-dom';
|
||||||
|
import './Modal.css';
|
||||||
|
|
||||||
|
const ModalFormGalerey = ({
|
||||||
|
show, title, validated, onSubmit, onClose, children,
|
||||||
|
}) => {
|
||||||
|
return createPortal(
|
||||||
|
<Modal show={show} className='modal-xl'
|
||||||
|
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>
|
||||||
|
</Form>
|
||||||
|
</Modal>,
|
||||||
|
document.body,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
ModalFormGalerey.propTypes = {
|
||||||
|
show: PropTypes.bool,
|
||||||
|
title: PropTypes.string,
|
||||||
|
validated: PropTypes.bool,
|
||||||
|
onSubmit: PropTypes.func,
|
||||||
|
onClose: PropTypes.func,
|
||||||
|
children: PropTypes.node,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ModalFormGalerey;
|
21
Лаб5/src/components/modal/ModalGalerey.jsx
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import './Modal.css';
|
||||||
|
import placeHolder from '../../assets/placeHolder.png';
|
||||||
|
|
||||||
|
const ModalGalerey = ({ line }) => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className="my-3 mx-auto fs-5 fw-bold GalereyCardModal">
|
||||||
|
<img src={line?.image || placeHolder} className="my-3 rounded-8" alt="image" height="500" />
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
ModalGalerey.propTypes = {
|
||||||
|
line: PropTypes.object,
|
||||||
|
sum: PropTypes.string,
|
||||||
|
image: PropTypes.string,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ModalGalerey;
|
21
Лаб5/src/components/modal/ModalHook.js
Normal 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;
|
33
Лаб5/src/components/modal/ModalImage.jsx
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import { 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>
|
||||||
|
</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;
|
22
Лаб5/src/components/navigation/Navigation.css
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
.my-navbar {
|
||||||
|
background-color: #3c3c3c !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.my-navbar .link a:hover {
|
||||||
|
text-decoration: underline !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.my-navbar .logo {
|
||||||
|
width: 26px;
|
||||||
|
height: 26px;
|
||||||
|
}
|
||||||
|
.navbar-brand{
|
||||||
|
background-color: #F0F1F3 !important;
|
||||||
|
font-weight: bolder;
|
||||||
|
font-size: 22px;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
}
|
||||||
|
.Navbar{
|
||||||
|
color: #184fbd !important;
|
||||||
|
}
|
||||||
|
|
39
Лаб5/src/components/navigation/Navigation.jsx
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import { Container, Nav, Navbar } from 'react-bootstrap';
|
||||||
|
import { Link, useLocation } from 'react-router-dom';
|
||||||
|
import './Navigation.css';
|
||||||
|
|
||||||
|
const Navigation = ({ routes }) => {
|
||||||
|
const location = useLocation();
|
||||||
|
const indexPageLink = routes.filter((route) => route.index === false).shift();
|
||||||
|
const pages = routes.filter((route) => Object.prototype.hasOwnProperty.call(route, 'title'));
|
||||||
|
|
||||||
|
return (
|
||||||
|
<header>
|
||||||
|
<Navbar expand='md' data-bs-theme='dark' className='navbar-brand'>
|
||||||
|
<Container fluid>
|
||||||
|
<Navbar.Brand as={Link} to={indexPageLink?.path ?? '/'}>
|
||||||
|
<img src='src/assets/Label.jpg' height="150"></img>
|
||||||
|
</Navbar.Brand>
|
||||||
|
<Navbar.Toggle aria-controls='main-navbar' />
|
||||||
|
<Navbar.Collapse id='main-navbar'>
|
||||||
|
<Nav className='me-auto link' activeKey={location.pathname}>
|
||||||
|
{
|
||||||
|
pages.map((page) =>
|
||||||
|
<Nav.Link as={Link} key={page.path} eventKey={page.path} to={page.path ?? '/'} className='nav-link me-3 ms-3 fs-4 fw-bold Navbar'>
|
||||||
|
{page.title}
|
||||||
|
</Nav.Link>)
|
||||||
|
}
|
||||||
|
</Nav>
|
||||||
|
</Navbar.Collapse>
|
||||||
|
</Container>
|
||||||
|
</Navbar >
|
||||||
|
</header>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
Navigation.propTypes = {
|
||||||
|
routes: PropTypes.array,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Navigation;
|
27
Лаб5/src/components/reviews/Reviews/ReviewCard.jsx
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import { Trash3 } from 'react-bootstrap-icons';
|
||||||
|
|
||||||
|
const ReviewCard = ({ item, onDelete }) => {
|
||||||
|
const handleAnchorClick = (event, action) => {
|
||||||
|
event.preventDefault();
|
||||||
|
action();
|
||||||
|
};
|
||||||
|
const day = new Date().toLocaleDateString();
|
||||||
|
return (
|
||||||
|
<div className="text-start p-2 rounded-8 my-2 light-grey razdel4reviews">
|
||||||
|
<div className='row'>
|
||||||
|
<h2 className="fw-normal text-start text-dark col">{item.name}</h2>
|
||||||
|
<h2 href="#" className='col text-end me-2' onClick={(event) => handleAnchorClick(event, onDelete)}><Trash3 /></h2>
|
||||||
|
</div>
|
||||||
|
<h1>{item.text}</h1>
|
||||||
|
<h7 className="fw-normal text-start text-dark col">{day}</h7>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
ReviewCard.propTypes = {
|
||||||
|
item: PropTypes.object,
|
||||||
|
onDelete: PropTypes.func,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ReviewCard;
|
54
Лаб5/src/components/reviews/Reviews/Reviews.jsx
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
import { Button } from 'react-bootstrap';
|
||||||
|
import ModalConfirm from '../../modal/ModalConfirm.jsx';
|
||||||
|
import ModalForm from '../../modal/ModalForm.jsx';
|
||||||
|
import useReviews from '../hooks/RevievsHook.js';
|
||||||
|
import useReviewsFormModal from '../hooks/ReviewsFormModalHook.js';
|
||||||
|
import ReviewsItemForm from './ReviewsItemForm.jsx';
|
||||||
|
import ReviewCard from './ReviewCard.jsx';
|
||||||
|
import useReviewsDeleteModal from '../hooks/ReviewsDeleteModalHook.js';
|
||||||
|
|
||||||
|
const Reviews = () => {
|
||||||
|
const { reviews, handleReviewsChange } = useReviews();
|
||||||
|
|
||||||
|
const {
|
||||||
|
isDeleteModalShow,
|
||||||
|
showDeleteModal,
|
||||||
|
handleDeleteConfirm,
|
||||||
|
handleDeleteCancel,
|
||||||
|
} = useReviewsDeleteModal(handleReviewsChange);
|
||||||
|
|
||||||
|
const {
|
||||||
|
isFormModalShow,
|
||||||
|
isFormValidated,
|
||||||
|
showFormModal,
|
||||||
|
currentItem,
|
||||||
|
handleItemChange,
|
||||||
|
handleFormSubmit,
|
||||||
|
handleFormClose,
|
||||||
|
} = useReviewsFormModal(handleReviewsChange);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='razdel4contain rounded-8 p-2 mx-auto scrollableContainer'>
|
||||||
|
<Button variant='info' className='rounded-pill ms-3 mb-3 text-light' onClick={() => showFormModal()}>
|
||||||
|
Написать отзыв
|
||||||
|
</Button>
|
||||||
|
<div className='container overflow-y-auto height-500'>
|
||||||
|
{
|
||||||
|
reviews.slice().reverse().map((item) =>
|
||||||
|
<ReviewCard key={item} item={item}
|
||||||
|
onDelete={() => showDeleteModal(item.id)}/>)
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
<ModalConfirm show={isDeleteModalShow}
|
||||||
|
onConfirm={handleDeleteConfirm} onClose={handleDeleteCancel}
|
||||||
|
title='Удаление' message='Удалить отзыв?' />
|
||||||
|
<ModalForm show={isFormModalShow} validated={isFormValidated}
|
||||||
|
onSubmit={handleFormSubmit} onClose={handleFormClose}
|
||||||
|
title='Новый отзыв'>
|
||||||
|
<ReviewsItemForm item={currentItem} handleChange={handleItemChange} />
|
||||||
|
</ModalForm>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Reviews;
|
20
Лаб5/src/components/reviews/Reviews/ReviewsItemForm.jsx
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import Input from '../../input/Input.jsx';
|
||||||
|
|
||||||
|
const ReviewsItemForm = ({ item, handleChange }) => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Input name='name' label='Имя' value={item.name} onChange={handleChange}
|
||||||
|
type='text' required />
|
||||||
|
<Input name='text' label='Текст отзыва' value={item.text} onChange={handleChange}
|
||||||
|
type='text' required/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
ReviewsItemForm.propTypes = {
|
||||||
|
item: PropTypes.object,
|
||||||
|
handleChange: PropTypes.func,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ReviewsItemForm;
|
24
Лаб5/src/components/reviews/hooks/RevievsHook.js
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import ReviewApiService from '../service/ReviewApiService.js';
|
||||||
|
|
||||||
|
const useReviews = () => {
|
||||||
|
const [reviewsRefresh, setReviewsRefresh] = useState(false);
|
||||||
|
const [reviews, setReviews] = useState([]);
|
||||||
|
const handleReviewsChange = () => setReviewsRefresh(!reviewsRefresh);
|
||||||
|
|
||||||
|
const getReviews = async () => {
|
||||||
|
const data = await ReviewApiService.getAll();
|
||||||
|
setReviews(data ?? []);
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
getReviews();
|
||||||
|
}, [reviewsRefresh]);
|
||||||
|
|
||||||
|
return {
|
||||||
|
reviews,
|
||||||
|
handleReviewsChange,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default useReviews;
|
34
Лаб5/src/components/reviews/hooks/ReviewsDeleteModalHook.js
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import { useState } from 'react';
|
||||||
|
import toast from 'react-hot-toast';
|
||||||
|
import useModal from '../../modal/ModalHook';
|
||||||
|
import ReviewsApiService from "../service/ReviewApiService.js";
|
||||||
|
|
||||||
|
const useReviewsDeleteModal = (linesChangeHandle, admin) => {
|
||||||
|
const { isModalShow, showModal, hideModal } = useModal();
|
||||||
|
const [currentId, setCurrentId] = useState(0);
|
||||||
|
|
||||||
|
const showModalDialog = (id) => {
|
||||||
|
showModal();
|
||||||
|
setCurrentId(id);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onClose = () => {
|
||||||
|
hideModal();
|
||||||
|
};
|
||||||
|
|
||||||
|
const onDelete = async () => {
|
||||||
|
await ReviewsApiService.delete(currentId);
|
||||||
|
linesChangeHandle();
|
||||||
|
toast.success('Элемент успешно удален', { id: 'LinesTable' });
|
||||||
|
onClose();
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
isDeleteModalShow: isModalShow,
|
||||||
|
showDeleteModal: showModalDialog,
|
||||||
|
handleDeleteConfirm: onDelete,
|
||||||
|
handleDeleteCancel: onClose,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default useReviewsDeleteModal;
|
45
Лаб5/src/components/reviews/hooks/ReviewsFormModalHook.js
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import { useState } from 'react';
|
||||||
|
import useModal from '../../modal/ModalHook';
|
||||||
|
import useReviewsItemForm from './ReviewsItemFormHook.js';
|
||||||
|
|
||||||
|
const useReviewsFormModal = (reviewsChangeHandle) => {
|
||||||
|
const { isModalShow, showModal, hideModal } = useModal();
|
||||||
|
const [currentId, setCurrentId] = useState(0);
|
||||||
|
|
||||||
|
const {
|
||||||
|
item,
|
||||||
|
validated,
|
||||||
|
handleSubmit,
|
||||||
|
handleChange,
|
||||||
|
resetValidity,
|
||||||
|
} = useReviewsItemForm(currentId, reviewsChangeHandle);
|
||||||
|
|
||||||
|
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 useReviewsFormModal;
|
65
Лаб5/src/components/reviews/hooks/ReviewsItemFormHook.js
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
import { useState } from 'react';
|
||||||
|
import toast from 'react-hot-toast';
|
||||||
|
import ReviewApiService from '../service/ReviewApiService.js';
|
||||||
|
import useReviewsItem from './ReviewsItemHook.js';
|
||||||
|
|
||||||
|
const useReviewsItemForm = (id, linesChangeHandle) => {
|
||||||
|
const { item, setItem } = useReviewsItem(id);
|
||||||
|
|
||||||
|
const [validated, setValidated] = useState(false);
|
||||||
|
|
||||||
|
const resetValidity = () => {
|
||||||
|
setValidated(false);
|
||||||
|
};
|
||||||
|
const year = new Date().getFullYear();
|
||||||
|
const month = new Date().getMonth();
|
||||||
|
const day = new Date().getDay();
|
||||||
|
const getReviewObject = (formData) => {
|
||||||
|
const { name } = formData;
|
||||||
|
const { text } = formData;
|
||||||
|
const date = `${day}/${month}/${year}`;
|
||||||
|
return {
|
||||||
|
name: name.toString(),
|
||||||
|
text: text.toString(),
|
||||||
|
date: date.toString(),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleChange = (event) => {
|
||||||
|
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 = getReviewObject(item);
|
||||||
|
if (form.checkValidity()) {
|
||||||
|
if (id === undefined) {
|
||||||
|
await ReviewApiService.create(body);
|
||||||
|
} else {
|
||||||
|
await ReviewApiService.update(id, body);
|
||||||
|
}
|
||||||
|
if (linesChangeHandle) linesChangeHandle();
|
||||||
|
toast.success('Отзыв успешно сохранен', { id: 'Reviews' });
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
setValidated(true);
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
item,
|
||||||
|
validated,
|
||||||
|
handleSubmit,
|
||||||
|
handleChange,
|
||||||
|
resetValidity,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default useReviewsItemForm;
|
32
Лаб5/src/components/reviews/hooks/ReviewsItemHook.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import ReviewApiService from '../service/ReviewApiService.js';
|
||||||
|
|
||||||
|
const useReviewsItem = (id) => {
|
||||||
|
const emptyItem = {
|
||||||
|
id: '',
|
||||||
|
name: '',
|
||||||
|
text: '',
|
||||||
|
date: '',
|
||||||
|
};
|
||||||
|
const [item, setItem] = useState({ ...emptyItem });
|
||||||
|
|
||||||
|
const getItem = async (itemId = undefined) => {
|
||||||
|
if (itemId && itemId > 0) {
|
||||||
|
const data = await ReviewApiService.get(itemId);
|
||||||
|
setItem(data);
|
||||||
|
} else {
|
||||||
|
setItem({ ...emptyItem });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
getItem(id);
|
||||||
|
}, [id]);
|
||||||
|
|
||||||
|
return {
|
||||||
|
item,
|
||||||
|
setItem,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default useReviewsItem;
|
5
Лаб5/src/components/reviews/service/ReviewApiService.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import ApiService from '../../api/ApiService';
|
||||||
|
|
||||||
|
const ReviewsApiService = new ApiService('reviews');
|
||||||
|
|
||||||
|
export default ReviewsApiService;
|
21
Лаб5/src/components/types/hooks/TypesHook.js
Normal 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;
|
5
Лаб5/src/components/types/service/TypesApiService.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import ApiService from '../../api/ApiService';
|
||||||
|
|
||||||
|
const TypesApiService = new ApiService('types');
|
||||||
|
|
||||||
|
export default TypesApiService;
|
15
Лаб5/src/components/utils/Base64.js
Normal 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;
|
204
Лаб5/src/main.css
Normal file
@ -0,0 +1,204 @@
|
|||||||
|
.imageButton{
|
||||||
|
background-image: url('./src/assets/Main1.jpg');
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
}
|
||||||
|
.pageBackground{
|
||||||
|
background-image: url('./src/assets/Main1.jpg');
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
}
|
||||||
|
.back{
|
||||||
|
background-color: #eff0f2 !important;
|
||||||
|
}
|
||||||
|
.razdel1{
|
||||||
|
width: 45%; min-width: 320px ;height: fit-content; background-color: rgba(236,247,230,0.8); padding:2%; border-radius: 20px;
|
||||||
|
}
|
||||||
|
.razdel2{
|
||||||
|
width: 40%; min-width: 320px ;height: fit-content; background-color: rgba(236,247,230,0.8); padding:2%; border-radius: 20px;
|
||||||
|
}
|
||||||
|
.razdel3{
|
||||||
|
width: 70%; min-width: 320px ;height: fit-content; background-color: rgba(236,247,230,0.8); padding:2%; border-radius: 20px;
|
||||||
|
}
|
||||||
|
.razdel4contain{width: 70%; min-width: 320px; height: 500px; background-color: rgba(236,247,230,0.8); border-radius: 20px;}
|
||||||
|
.razdel4reviews{height: fit-content; width: 100%; background-color: #d9d9d9; border-radius: 20px;}
|
||||||
|
.razdel5{
|
||||||
|
width: 100%; min-width: 320px ;height: fit-content; background-color: rgba(236,247,230,0.8); padding:2%; border-radius: 20px;
|
||||||
|
}
|
||||||
|
h3{
|
||||||
|
font-weight: bolder !important;
|
||||||
|
font-size: 20px !important;
|
||||||
|
color: #000000 !important;
|
||||||
|
}
|
||||||
|
h1{
|
||||||
|
font-weight: 600 !important;
|
||||||
|
font-size: 18px !important;
|
||||||
|
color: #000000 !important;
|
||||||
|
}
|
||||||
|
h7{
|
||||||
|
font-weight: 600 !important;
|
||||||
|
font-size: 8px !important;
|
||||||
|
color: #000000 !important;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
|
h2,h4,h5,h6 {
|
||||||
|
font-weight: 600 !important;
|
||||||
|
font-size: 20px !important;
|
||||||
|
color: #000000 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
p{
|
||||||
|
font-size: 14px !important;
|
||||||
|
line-height: 28px;
|
||||||
|
margin-bottom: 25px;
|
||||||
|
word-spacing: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.centered{
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover, a:focus{
|
||||||
|
color: #7b7b7b;
|
||||||
|
text-decoration: none;
|
||||||
|
outline: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr{
|
||||||
|
display: block;
|
||||||
|
height: 1px;
|
||||||
|
border: 0;
|
||||||
|
border-top: 1px solid #ccc;
|
||||||
|
margin: 1em 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar{
|
||||||
|
font-weight: 800;
|
||||||
|
font-size: 14px;
|
||||||
|
padding-top: 15px;
|
||||||
|
padding-bottom: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar-inverse{
|
||||||
|
background: #2d2d2d;
|
||||||
|
border-color: #2d2d2d;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar-inverse .navbar-nav > .active > a{
|
||||||
|
background-color: #ff7878;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar-inverse .navbar-brand{
|
||||||
|
color: #999;
|
||||||
|
font-weight: bolder;
|
||||||
|
font-size: 22px;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Navbar{
|
||||||
|
color: #184fbd !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Backgr{
|
||||||
|
background-color: #184fbd !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.navbar-style{
|
||||||
|
position: sticky !important;
|
||||||
|
top: 0px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer-style{
|
||||||
|
position: sticky !important;
|
||||||
|
top: 80px !important;
|
||||||
|
background-color: #184fbd !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.f{
|
||||||
|
font-size: 8px;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
.map{
|
||||||
|
display: flex !important;
|
||||||
|
align-items: center !important;
|
||||||
|
justify-content: center !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Otzyv{
|
||||||
|
height: 100px; width: 290px; background-color: #d9d9d9; border-radius: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ContainerOtzyv{
|
||||||
|
height: 300px !important;
|
||||||
|
}
|
||||||
|
.AdminPage{
|
||||||
|
width: 100% !important;height: fit-content !important; background-color: rgba(236,247,230,0.8) !important; border-radius: 20px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.PricePage{
|
||||||
|
width: 50% !important;height: fit-content !important;
|
||||||
|
}
|
||||||
|
.Galerey{
|
||||||
|
width: fit-content !important; height: 500px; min-height: 80% !important; background-color: rgba(236,247,230,0.8) !important; border-radius: 20px !important;
|
||||||
|
}
|
||||||
|
.GalereyCard{
|
||||||
|
min-width: 320px !important;height: fit-content !important; min-height: 80% !important; background-color: rgba(55, 59, 53, 0.8) !important; border-radius: 20px !important;
|
||||||
|
}
|
||||||
|
.GalereyCardModal{
|
||||||
|
width: fit-content !important; height: 250px !important;
|
||||||
|
}
|
||||||
|
.Galerey1{
|
||||||
|
background-image: url('./src/assets/1.jpg')!important; height: 200px !important; width: 300px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Galerey2{
|
||||||
|
background-image: url('./src/assets/2.jpg'); height: 200px !important; width: 300px !important;
|
||||||
|
}
|
||||||
|
.Galerey3{
|
||||||
|
background-image: url('./src/assets/3.jpg'); height: 200px !important; width: 300px !important;
|
||||||
|
}
|
||||||
|
.Galerey4{
|
||||||
|
background-image: url('./src/assets/4.jpg'); height: 200px !important; width: 300px !important;
|
||||||
|
}
|
||||||
|
.Galerey5{
|
||||||
|
background-image: url('./src/assets/5.jpg'); height: 200px !important; width: 300px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.GalereyNew{
|
||||||
|
height: 200px !important; width: 300px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.GalereyModal{
|
||||||
|
height: fit-content !important; width: 80% !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.GalereyModal1{
|
||||||
|
height: fit-content !important; width: 100% !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.GalereyModal2{
|
||||||
|
width: 100% !important;
|
||||||
|
}
|
||||||
|
.Map{
|
||||||
|
width: 100% !important;
|
||||||
|
}
|
||||||
|
.scrollableContainer {
|
||||||
|
position: relative;
|
||||||
|
overflow-y: auto;
|
||||||
|
list-style: none;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
.hystmodal {
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
right: 0;
|
||||||
|
left: 0;
|
||||||
|
overflow-x: auto;
|
||||||
|
overflow-y: auto;
|
||||||
|
padding:30px 0;
|
||||||
|
}
|
62
Лаб5/src/main.jsx
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
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 './main.css';
|
||||||
|
import ErrorPage from './pages/ErrorPage.jsx';
|
||||||
|
import Page1 from './pages/Page1.jsx';
|
||||||
|
import Page2 from './pages/Page2.jsx';
|
||||||
|
import Page3 from './pages/Page3.jsx';
|
||||||
|
import Page4 from './pages/Page4.jsx';
|
||||||
|
import Page5 from './pages/Page5.jsx';
|
||||||
|
import Admin from './pages/Admin.jsx';
|
||||||
|
|
||||||
|
const routes = [
|
||||||
|
{
|
||||||
|
index: true,
|
||||||
|
path: '/',
|
||||||
|
element: <Page1 />,
|
||||||
|
title: 'Главная',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/page2',
|
||||||
|
element: <Page2 />,
|
||||||
|
title: 'Адреса',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/page3',
|
||||||
|
element: <Page3 />,
|
||||||
|
title: 'Прейскурант',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/page4',
|
||||||
|
element: <Page4 />,
|
||||||
|
title: 'Отзывы',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/page5',
|
||||||
|
element: <Page5 />,
|
||||||
|
title: 'Галерея',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/Admin',
|
||||||
|
element: <Admin />,
|
||||||
|
title: 'Админ',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
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>,
|
||||||
|
);
|
9
Лаб5/src/pages/Admin.jsx
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import Lines from '../components/lines/table/Lines.jsx';
|
||||||
|
|
||||||
|
const Page4 = () => {
|
||||||
|
return (
|
||||||
|
<Lines />
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Page4;
|
20
Лаб5/src/pages/ErrorPage.jsx
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import { Alert, Button, Container } from 'react-bootstrap';
|
||||||
|
import { useNavigate, useRouteError } from 'react-router-dom';
|
||||||
|
|
||||||
|
const ErrorPage = () => {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const error = useRouteError();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Container fluid className='m-0 p-3 row justify-content-center'>
|
||||||
|
<Alert className='col-12 col-lg-6' variant='danger'>
|
||||||
|
{error?.message ?? 'Страница не найдена'}
|
||||||
|
</Alert>
|
||||||
|
<div className='w-100'></div>
|
||||||
|
<Button className='col-12 col-lg-6' variant='primary'
|
||||||
|
onClick={() => navigate(-1)}>Назад</Button>
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ErrorPage;
|
17
Лаб5/src/pages/Page1.jsx
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
const Page1 = () => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className="text-light mx-auto mt-5 mb-5 fw-bold rounded-8 p-4 razdel1">
|
||||||
|
<h3>Car Wash! – это чистый результат и экономия средств.</h3>
|
||||||
|
<h3> DS - Detailing Service, удовольствие от самостоятельного</h3>
|
||||||
|
<h3>ухода за автомобилем, сервис в деталях.</h3>
|
||||||
|
<h4 className="mt-4">Мы рады обеспечивать автомобилистам полный комплекс технологий и средств для качественного самостоятельного ухода за автомобилем.</h4>
|
||||||
|
<h4 className="mt-4">Мы гарантируем доступные цены на программы основного ухода: химию для мойки кузова и дисков, защитный воск и осмос ополаскивание, уборку салона пылесосом.</h4>
|
||||||
|
<h4>Предоставляем средства для дополнительного ухода:</h4>
|
||||||
|
<h4> чернитель резины, полироль пластика, очиститель битумных пятен.</h4>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Page1;
|
24
Лаб5/src/pages/Page2.jsx
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import Map from '../assets/Map.png';
|
||||||
|
|
||||||
|
const Page2 = () => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className="text-l.ight text-center mx-auto mt-5 mb-5 fw-bold rounded-8 p-4 razdel2" >
|
||||||
|
<h1>
|
||||||
|
Адреса:
|
||||||
|
</h1>
|
||||||
|
<h1>
|
||||||
|
г. Ульяновск, Дзержинского, 6
|
||||||
|
<br/>г. Ульяновск, Карла Маркса, 61
|
||||||
|
<br/>г. Ульяновск, Пожарный пер., 5
|
||||||
|
<br/>г. Ульяновск, Металлистов, 1
|
||||||
|
</h1>
|
||||||
|
<div className="mx-auto text-center">
|
||||||
|
<img src={Map} alt='map' className='Map'/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Page2;
|
11
Лаб5/src/pages/Page3.jsx
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import Lines from '../components/linesPrice/table/Lines.jsx';
|
||||||
|
|
||||||
|
const Page3 = () => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Lines />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Page3;
|
9
Лаб5/src/pages/Page4.jsx
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import Reviews from '../components/reviews/Reviews/Reviews.jsx';
|
||||||
|
|
||||||
|
const Page4 = () => {
|
||||||
|
return (
|
||||||
|
<Reviews />
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Page4;
|
11
Лаб5/src/pages/Page5.jsx
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import GalereyBody from '../components/Galerey/Galerey.jsx';
|
||||||
|
|
||||||
|
const Page4 = () => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<GalereyBody/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Page4;
|