Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
24adbfec1a | |||
6063b1cd56 | |||
ad5c433e74 |
25
.eslintrc.cjs
Normal file
@ -0,0 +1,25 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
env: { browser: true, es2020: true },
|
||||
extends: [
|
||||
'airbnb-base',
|
||||
'plugin:react/recommended',
|
||||
'plugin:react/jsx-runtime',
|
||||
'plugin:react-hooks/recommended',
|
||||
],
|
||||
ignorePatterns: ['dist', '.eslintrc.cjs'],
|
||||
parserOptions: { ecmaVersion: 12, sourceType: 'module' },
|
||||
settings: { react: { version: '18.2' } },
|
||||
plugins: ['react-refresh'],
|
||||
rules: {
|
||||
'react-refresh/only-export-components': [
|
||||
'warn',
|
||||
{ allowConstantExport: true },
|
||||
],
|
||||
'indent': 'off',
|
||||
'no-console': 'off',
|
||||
'arrow-body-style': 'off',
|
||||
'implicit-arrow-linebreak': 'off',
|
||||
'linebreak-style': 'off',
|
||||
},
|
||||
}
|
8
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
9
.idea/InetProga.iml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
6
.idea/misc.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
8
.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/InetProga.iml" filepath="$PROJECT_DIR$/.idea/InetProga.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
29
README.md
@ -1,2 +1,29 @@
|
||||
# Internet-programming
|
||||
#### Окружение:
|
||||
- nodejs 18;
|
||||
- VSCode;
|
||||
- ESLint плагин для VSCode;
|
||||
- для отладки необходимы бразузеры Chrome или Edge.
|
||||
|
||||
#### Создание пустого проекта:
|
||||
|
||||
```commandline
|
||||
npm create vite@latest ./ -- --template react
|
||||
```
|
||||
|
||||
#### Установка зависимостей:
|
||||
|
||||
```commandline
|
||||
npm install
|
||||
```
|
||||
|
||||
#### Запуск проекта:
|
||||
|
||||
```commandline
|
||||
npm run dev
|
||||
```
|
||||
|
||||
#### Сборка проекта:
|
||||
|
||||
```commandline
|
||||
npm run build
|
||||
```
|
15
index.html
Normal file
@ -0,0 +1,15 @@
|
||||
<html lang="ru">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>OKPO</title>
|
||||
</head>
|
||||
|
||||
<body class="h-100 d-flex flex-column" style="background-color: #03001F">
|
||||
<div id="root" class="h-100 d-flex flex-column"></div>
|
||||
<script type="module" src="/src/main.jsx"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
14
jsconfig.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Node",
|
||||
"target": "ES2020",
|
||||
"jsx": "react",
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"**/node_modules/*"
|
||||
]
|
||||
}
|
BIN
media/sobaka-letit_(VIDEOMIN.NET).mp4
Normal file
5970
package-lock.json
generated
Normal file
39
package.json
Normal file
@ -0,0 +1,39 @@
|
||||
{
|
||||
"name": "lec4",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
|
||||
"rest": "json-server data.json",
|
||||
"vite": "vite",
|
||||
"dev": "npm-run-all --parallel rest vite",
|
||||
"prod": "npm-run-all lint 'vite build' --parallel rest 'vite preview'"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^1.6.1",
|
||||
"bootstrap": "^5.3.2",
|
||||
"fast-levenshtein": "^3.0.0",
|
||||
"prop-types": "^15.8.1",
|
||||
"react": "^18.2.0",
|
||||
"react-bootstrap": "^2.9.1",
|
||||
"react-bootstrap-icons": "^1.10.3",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-hot-toast": "^2.4.1",
|
||||
"react-router-dom": "^6.18.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^18.2.15",
|
||||
"@types/react-dom": "^18.2.15",
|
||||
"@vitejs/plugin-react": "^4.0.3",
|
||||
"eslint": "^8.45.0",
|
||||
"eslint-config-airbnb-base": "^15.0.0",
|
||||
"eslint-plugin-import": "^2.29.0",
|
||||
"eslint-plugin-react": "^7.32.2",
|
||||
"eslint-plugin-react-hooks": "^4.6.0",
|
||||
"eslint-plugin-react-refresh": "^0.4.3",
|
||||
"json-server": "^0.17.4",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"vite": "^4.4.5"
|
||||
}
|
||||
}
|
4
public/favicon.svg
Normal file
@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-0-circle-fill" viewBox="0 0 16 16">
|
||||
<path d="M8 4.951c-1.008 0-1.629 1.09-1.629 2.895v.31c0 1.81.627 2.895 1.629 2.895s1.623-1.09 1.623-2.895v-.31c0-1.8-.621-2.895-1.623-2.895"/>
|
||||
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0m-8.012 4.158c1.858 0 2.96-1.582 2.96-3.99V7.84c0-2.426-1.079-3.996-2.936-3.996-1.864 0-2.965 1.588-2.965 3.996v.328c0 2.42 1.09 3.99 2.941 3.99"/>
|
||||
</svg>
|
After Width: | Height: | Size: 476 B |
0
src/App.css
Normal file
22
src/App.jsx
Normal file
@ -0,0 +1,22 @@
|
||||
import PropTypes from 'prop-types';
|
||||
import { Container } from 'react-bootstrap';
|
||||
import { Outlet } from 'react-router-dom';
|
||||
import './App.css';
|
||||
import Navigation from './components/navigation/Navigation.jsx';
|
||||
|
||||
const App = ({ routes }) => {
|
||||
return (
|
||||
<>
|
||||
<Navigation routes={routes}></Navigation>
|
||||
<Container className='p-2' as="main" fluid>
|
||||
<Outlet />
|
||||
</Container>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
App.propTypes = {
|
||||
routes: PropTypes.array,
|
||||
};
|
||||
|
||||
export default App;
|
BIN
src/assets/200.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
src/assets/Fone.png
Normal file
After Width: | Height: | Size: 714 KiB |
BIN
src/assets/Prev.png
Normal file
After Width: | Height: | Size: 489 KiB |
BIN
src/assets/Title.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
src/assets/Title_black.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
src/assets/abstract-spectrum-wave.jpg
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
src/assets/icons8-загрузить-64.png
Normal file
After Width: | Height: | Size: 372 B |
BIN
src/assets/korotysh.png
Normal file
After Width: | Height: | Size: 75 KiB |
BIN
src/assets/photo.png
Normal file
After Width: | Height: | Size: 30 KiB |
12
src/components/AddExpected.jsx
Normal file
@ -0,0 +1,12 @@
|
||||
const AddExpected = () => {
|
||||
return (
|
||||
<>
|
||||
<span className='mr-2'>Добавить в ожидаемое</span>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="red" className="bi bi-archive-fill" viewBox="0 0 16 16">
|
||||
<path d="M12.643 15C13.979 15 15 13.845 15 12.5V5H1v7.5C1 13.845 2.021 15 3.357 15zM5.5 7h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1 0-1M.8 1a.8.8 0 0 0-.8.8V3a.8.8 0 0 0 .8.8h14.4A.8.8 0 0 0 16 3V1.8a.8.8 0 0 0-.8-.8z"/>
|
||||
</svg>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default AddExpected;
|
24
src/components/Card/Cards.jsx
Normal file
@ -0,0 +1,24 @@
|
||||
import { Button } from 'react-bootstrap';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { PropTypes } from 'prop-types';
|
||||
|
||||
const CreateCard = ({ line }) => {
|
||||
return (
|
||||
<>
|
||||
<Button className="prev" as={Link} to={`/Film/${line.id}`} style={{ backgroundColor: '#03001F', border: 'none', marginLeft: '1%' }}>
|
||||
<div className="card image-container text-bg-dark" style={{ maxWidth: '20rem' }}>
|
||||
<img src={line.image} className="card-img" alt="превью" />
|
||||
<div className="card-img-overlay overlay">
|
||||
<h5 className="card-title">{line.title}</h5>
|
||||
<p className="card-text">{line.description}</p>
|
||||
</div>
|
||||
</div>
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
};
|
||||
CreateCard.propTypes = {
|
||||
line: PropTypes.object,
|
||||
Button: PropTypes.func,
|
||||
};
|
||||
export default CreateCard;
|
21
src/components/UserPhoto.jsx
Normal file
@ -0,0 +1,21 @@
|
||||
import PropTypes from 'prop-types';
|
||||
import Input from './input/Input.jsx';
|
||||
|
||||
const UserPhoto = ({ item, handleChange }) => {
|
||||
return (
|
||||
<div style={{
|
||||
display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', width: '250px', height: '300px',
|
||||
}}>
|
||||
<img src={ item.photo } style={{ height: '300px', width: '250px', позиция: 'абсолютная' }}/>
|
||||
<Input type='file' accept='image/*' style ={{
|
||||
border: '1px пунктирная черная', backgroundColor: 'grey',
|
||||
}} onChange={handleChange}/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
UserPhoto.propTypes = {
|
||||
item: PropTypes.object,
|
||||
handleChange: PropTypes.func,
|
||||
handleSubmit: PropTypes.func,
|
||||
};
|
||||
export default UserPhoto;
|
40
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:3000/',
|
||||
timeout: '3000',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
},
|
||||
});
|
||||
|
||||
ApiClient.interceptors.response.use(responseHandler, responseErrorHandler);
|
29
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;
|
19
src/components/button/AdminButton.jsx
Normal file
@ -0,0 +1,19 @@
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
const CreateAdmin = () => {
|
||||
let id = '';
|
||||
try {
|
||||
id = localStorage.getItem('EnabledUser');
|
||||
} catch (error) {
|
||||
id = null;
|
||||
}
|
||||
if (id === '1') {
|
||||
return (
|
||||
<>
|
||||
<button className="btn btn-outline-warning button_add"><Link className="nav-link" to="/Admin" style={{ textDecoration: 'none' }}>Панель администратора</Link></button>
|
||||
</>
|
||||
);
|
||||
}
|
||||
return (<> </>);
|
||||
};
|
||||
export default CreateAdmin;
|
39
src/components/button/NavButton.jsx
Normal file
@ -0,0 +1,39 @@
|
||||
import { Button } from 'react-bootstrap';
|
||||
import { Link, useNavigate } from 'react-router-dom';
|
||||
|
||||
const CreateButton = () => {
|
||||
const navigator = useNavigate();
|
||||
let id = '';
|
||||
try {
|
||||
id = localStorage.getItem('EnabledUser');
|
||||
} catch (error) {
|
||||
id = null;
|
||||
}
|
||||
if (id === null) {
|
||||
return (
|
||||
<>
|
||||
<Button className="btn nav-link" variant="outline-info" style={{
|
||||
borderWidth: '2px', borderColor: '#0dcaf0', borderStyle: 'solid', marginRight: '10px', marginLeft: '20px',
|
||||
}}><Link to="/Join" style={{ color: 'white', textDecoration: 'none' }}>Вход</Link></Button>{' '}
|
||||
<Button className="btn nav-link" variant="outline-info" style={{
|
||||
borderWidth: '2px', borderColor: '#0dcaf0', borderStyle: 'solid', marginRight: '10px', marginLeft: '20px',
|
||||
}}><Link to="/Register" style={{ color: 'white', textDecoration: 'none' }}>Регистрация</Link></Button>{' '}
|
||||
</>
|
||||
);
|
||||
}
|
||||
const leave = () => {
|
||||
localStorage.removeItem('EnabledUser');
|
||||
navigator('/');
|
||||
};
|
||||
return (
|
||||
<>
|
||||
<Button className="btn nav-link" variant="outline-info" style={{
|
||||
borderWidth: '2px', borderColor: '#0dcaf0', borderStyle: 'solid', marginRight: '10px', marginLeft: '20px',
|
||||
}}><Link to={`/LK/${id}`} style={{ color: 'white', textDecoration: 'none' }}>Личный кабинет</Link></Button>{' '}
|
||||
<Button className="btn nav-link" variant="outline-danger" style={{
|
||||
borderWidth: '2px', borderColor: '#0dcaf0', borderStyle: 'solid', marginRight: '10px', marginLeft: '20px',
|
||||
}} onClick={ (leave) }>Выйти</Button>{' '}
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default CreateButton;
|
23
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 style={{ color: 'white' }}>{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;
|
30
src/components/input/Select.jsx
Normal file
@ -0,0 +1,30 @@
|
||||
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' style={{ color: 'white' }}>{label}</Form.Label>
|
||||
<Form.Select name={name || ''} value={value || ''} onChange={onChange} {...rest}>
|
||||
<option value=''>Выберите значение</option>
|
||||
{
|
||||
// eslint-disable-next-line max-len
|
||||
values.map((genre) => <option key={genre.id} value={genre.id}>{genre.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
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='btn-mw me-md-3 mb-md-0 mb-2' variant='secondary' style={{ height: '7%', fontSize: '16px' }} onClick={() => onBack()}>
|
||||
Назад
|
||||
</Button>
|
||||
<Button className='btn-mw me-md-3' type='submit' variant='primary' style={{ height: '7%', fontSize: '16px' }}>
|
||||
Сохранить
|
||||
</Button>
|
||||
</Form.Group>
|
||||
</Form>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
LinesForm.propTypes = {
|
||||
id: PropTypes.string,
|
||||
};
|
||||
|
||||
export default LinesForm;
|
7
src/components/lines/form/LinesItemForm.css
Normal file
@ -0,0 +1,7 @@
|
||||
#image-preview {
|
||||
width: 200px;
|
||||
}
|
||||
.Input > label {
|
||||
color: white;
|
||||
background-color: white;
|
||||
}
|
40
src/components/lines/form/LinesItemForm.jsx
Normal file
@ -0,0 +1,40 @@
|
||||
import PropTypes from 'prop-types';
|
||||
import imgPlaceholder from '../../../assets/200.png';
|
||||
import Input from '../../input/Input.jsx';
|
||||
import Select from '../../input/Select.jsx';
|
||||
import useGenres from '../../types/hooks/GenresHook';
|
||||
import './LinesItemForm.css';
|
||||
|
||||
const LinesItemForm = ({ item, handleChange }) => {
|
||||
const { genres } = useGenres();
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className='text-center'>
|
||||
<img id='image-preview' className='rounded' alt='placeholder' style={{ marginTop: '30px' }}
|
||||
src={item.image || imgPlaceholder} />
|
||||
</div>
|
||||
<Select values={genres} name='genreId' label='Жанр' value={item.genreId} onChange={handleChange}
|
||||
required />
|
||||
<Input name='title' label='Название продукта' value={item.title} onChange={handleChange}
|
||||
type='text' required />
|
||||
<Input name='cast' label='Актерский состав' value={item.cast} onChange={handleChange}
|
||||
type='text' required />
|
||||
<Input name='description' label='Описание' value={item.description} onChange={handleChange}
|
||||
type='text' required />
|
||||
<Input name='rating' label={`Рейтинг ${item.rating}`} value={item.rating} onChange={handleChange}
|
||||
type='range' min={0} max={10} step={1} required />
|
||||
<Input name='image' label='Превью' onChange={handleChange}
|
||||
type='file' accept='image/*' />
|
||||
<Input name='video' label='Видеофайл' onChange={handleChange}
|
||||
type='file' accept='video/*' />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
LinesItemForm.propTypes = {
|
||||
item: PropTypes.object,
|
||||
handleChange: PropTypes.func,
|
||||
};
|
||||
|
||||
export default LinesItemForm;
|
34
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
src/components/lines/hooks/LinesFilterHook.js
Normal file
@ -0,0 +1,28 @@
|
||||
import { useSearchParams } from 'react-router-dom';
|
||||
import useGenres from '../../types/hooks/GenresHook';
|
||||
|
||||
const useGenreFilter = () => {
|
||||
const filterName = 'genre';
|
||||
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
|
||||
const { genres } = useGenres();
|
||||
|
||||
const handleFilterChange = (event) => {
|
||||
const genre = event.target.value;
|
||||
if (genre) {
|
||||
searchParams.set(filterName, event.target.value);
|
||||
} else {
|
||||
searchParams.delete(filterName);
|
||||
}
|
||||
setSearchParams(searchParams);
|
||||
};
|
||||
|
||||
return {
|
||||
genres,
|
||||
currentFilter: searchParams.get(filterName) || '',
|
||||
handleFilterChange,
|
||||
};
|
||||
};
|
||||
|
||||
export default useGenreFilter;
|
29
src/components/lines/hooks/LinesHook.js
Normal file
@ -0,0 +1,29 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import LinesApiService from '../service/LinesApiService';
|
||||
|
||||
const useLines = (genreFilter) => {
|
||||
const [linesRefresh, setLinesRefresh] = useState(false);
|
||||
const [lines, setLines] = useState([]);
|
||||
const handleLinesChange = () => setLinesRefresh(!linesRefresh);
|
||||
|
||||
const getLines = async () => {
|
||||
let expand = '?_expand=genres';
|
||||
if (genreFilter) {
|
||||
expand = `${expand}&genresId=${genreFilter}`;
|
||||
}
|
||||
const data = await LinesApiService.getAll(expand);
|
||||
setLines(data ?? []);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
getLines();
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [linesRefresh, genreFilter]);
|
||||
|
||||
return {
|
||||
lines,
|
||||
handleLinesChange,
|
||||
};
|
||||
};
|
||||
|
||||
export default useLines;
|
92
src/components/lines/hooks/LinesItemFormHook.js
Normal file
@ -0,0 +1,92 @@
|
||||
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 genresId = parseInt(formData.genreId, 10);
|
||||
const title = formData.title.toString();
|
||||
const cast = formData.cast.toString();
|
||||
const description = formData.description.toString();
|
||||
const rating = parseInt(formData.rating, 10);
|
||||
const image = formData.image.startsWith('data:image') ? formData.image : '';
|
||||
const video = formData.video.startsWith('data:video') ? formData.video : '';
|
||||
return {
|
||||
genresId: genresId.toString(),
|
||||
title,
|
||||
cast,
|
||||
description,
|
||||
rating,
|
||||
image,
|
||||
video,
|
||||
};
|
||||
};
|
||||
|
||||
const handleImageChange = async (event) => {
|
||||
const { files } = event.target;
|
||||
const file = await getBase64FromFile(files.item(0));
|
||||
if (event.target.name === 'image') {
|
||||
setItem({
|
||||
...item,
|
||||
image: file,
|
||||
});
|
||||
} else {
|
||||
setItem({
|
||||
...item,
|
||||
video: 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;
|
36
src/components/lines/hooks/LinesItemHook.js
Normal file
@ -0,0 +1,36 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import LinesApiService from '../service/LinesApiService';
|
||||
|
||||
const useLinesItem = (id) => {
|
||||
const emptyItem = {
|
||||
genresId: '',
|
||||
title: '',
|
||||
cast: '',
|
||||
description: '',
|
||||
rating: '',
|
||||
image: '',
|
||||
video: '',
|
||||
};
|
||||
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;
|
83
src/components/lines/hooks/LinesUserFormHook.js
Normal file
@ -0,0 +1,83 @@
|
||||
import { useState } from 'react';
|
||||
import toast from 'react-hot-toast';
|
||||
import UserApiService from '../../types/service/UserApiService';
|
||||
import useLinesUser from './LinesUserHook';
|
||||
import getBase64FromFile from '../../utils/Base64';
|
||||
|
||||
const useLinesUserForm = (id, linesChangeHandle) => {
|
||||
const { item, setItem } = useLinesUser(id);
|
||||
|
||||
const [validated, setValidated] = useState(false);
|
||||
|
||||
const resetValidity = () => {
|
||||
setValidated(false);
|
||||
};
|
||||
|
||||
const getLineObject = (formData) => {
|
||||
const name = formData.name.toString();
|
||||
const login = formData.login.toString();
|
||||
const mail = formData.mail.toString();
|
||||
const password = formData.password.toString();
|
||||
const photo = formData.photo.startsWith('data:image') ? formData.photo : '';
|
||||
return {
|
||||
name,
|
||||
login,
|
||||
mail,
|
||||
password,
|
||||
photo,
|
||||
};
|
||||
};
|
||||
|
||||
const handleImageChange = async (event) => {
|
||||
const { files } = event.target;
|
||||
const file = await getBase64FromFile(files.item(0));
|
||||
if (event.target.name === 'photo') {
|
||||
setItem({
|
||||
...item,
|
||||
photo: 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 UserApiService.create(body);
|
||||
} else {
|
||||
await UserApiService.update(id, body);
|
||||
}
|
||||
if (linesChangeHandle) linesChangeHandle();
|
||||
toast.success('Элемент успешно сохранен', { id: 'LinesTable' });
|
||||
return true;
|
||||
}
|
||||
setValidated(true);
|
||||
return false;
|
||||
};
|
||||
|
||||
return {
|
||||
item,
|
||||
validated,
|
||||
handleSubmit,
|
||||
handleChange,
|
||||
resetValidity,
|
||||
};
|
||||
};
|
||||
|
||||
export default useLinesUserForm;
|
35
src/components/lines/hooks/LinesUserHook.js
Normal file
@ -0,0 +1,35 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import UserApiService from '../../types/service/UserApiService';
|
||||
|
||||
const useLinesUser = (id) => {
|
||||
const emptyItem = {
|
||||
id: '',
|
||||
name: '',
|
||||
login: '',
|
||||
mail: '',
|
||||
password: '',
|
||||
photo: '',
|
||||
};
|
||||
const [item, setItem] = useState({ ...emptyItem });
|
||||
|
||||
const getItem = async (itemId = undefined) => {
|
||||
if (itemId && itemId > 0) {
|
||||
const data = await UserApiService.get(itemId);
|
||||
setItem(data);
|
||||
} else {
|
||||
setItem({ ...emptyItem });
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
getItem(id);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [id]);
|
||||
|
||||
return {
|
||||
item,
|
||||
setItem,
|
||||
};
|
||||
};
|
||||
|
||||
export default useLinesUser;
|
33
src/components/lines/register/FormReg.jsx
Normal file
@ -0,0 +1,33 @@
|
||||
import PropTypes from 'prop-types';
|
||||
import { Button, Form, FormGroup } from 'react-bootstrap';
|
||||
import { Link } from 'react-router-dom';
|
||||
import titleBlack from '../../../assets/Title_black.png';
|
||||
|
||||
const FormRegister = ({ item, handleChange }) => {
|
||||
return (
|
||||
<>
|
||||
<center><Button as={Link} to="/" style={{ backgroundColor: 'white', borderColor: 'white' }}><img id="image_title" src={titleBlack} alt="название" className="Title"/></Button></center>
|
||||
<FormGroup className="reg_name" controlId="userName">
|
||||
<Form.Label className="form-label"></Form.Label>
|
||||
<Form.Control type="text" name="name" className="form-control" placeholder="Имя" value={item.name} onChange={handleChange} required />
|
||||
</FormGroup>
|
||||
<FormGroup className="reg_login" controlId="Login">
|
||||
<Form.Label className="form-label"></Form.Label>
|
||||
<Form.Control type="text" name="login" className="form-control" placeholder="Логин" value={item.login} onChange={handleChange} required />
|
||||
</FormGroup>
|
||||
<FormGroup className="reg_mail" controlId="Mail">
|
||||
<Form.Label className="form-label"></Form.Label>
|
||||
<Form.Control type="email" name="mail" className="form-control" placeholder="Почта пользователя" value={item.mail} onChange={handleChange} required />
|
||||
</FormGroup>
|
||||
<FormGroup className="reg_pass" controlId="regPassword">
|
||||
<Form.Label className="form-label"></Form.Label>
|
||||
<Form.Control type="password" name="password" className="form-control" placeholder="Пароль" value={item.password} onChange={handleChange} required />
|
||||
</FormGroup>
|
||||
</>
|
||||
);
|
||||
};
|
||||
FormRegister.propTypes = {
|
||||
item: PropTypes.object,
|
||||
handleChange: PropTypes.func,
|
||||
};
|
||||
export default FormRegister;
|
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;
|
55
src/components/lines/table/Lines.jsx
Normal file
@ -0,0 +1,55 @@
|
||||
import { Button, ButtonGroup } from 'react-bootstrap';
|
||||
import { Link, useNavigate } from 'react-router-dom';
|
||||
import Select from '../../input/Select.jsx';
|
||||
import ModalConfirm from '../../modal/ModalConfirm.jsx';
|
||||
import useLinesDeleteModal from '../hooks/LinesDeleteModalHook';
|
||||
import useGenreFilter from '../hooks/LinesFilterHook';
|
||||
import useLines from '../hooks/LinesHook';
|
||||
import LinesTable from './LinesTable.jsx';
|
||||
import LinesTableRow from './LinesTableRow.jsx';
|
||||
|
||||
const Lines = () => {
|
||||
const { genres, currentFilter, handleFilterChange } = useGenreFilter();
|
||||
|
||||
const { lines, handleLinesChange } = useLines(currentFilter);
|
||||
|
||||
const {
|
||||
isDeleteModalShow,
|
||||
showDeleteModal,
|
||||
handleDeleteConfirm,
|
||||
handleDeleteCancel,
|
||||
} = useLinesDeleteModal(handleLinesChange);
|
||||
|
||||
const navigate = useNavigate();
|
||||
|
||||
const showEditPage = (id) => {
|
||||
navigate(`/Input/${id}`);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<ButtonGroup>
|
||||
<Button as={Link} to='/Input' variant='outline-warning' style={{ marginTop: '40px' }}>
|
||||
Добавить товар
|
||||
</Button>
|
||||
</ButtonGroup>
|
||||
<Select className='mt-2' values={genres} label='Фильтр по жанрам'
|
||||
value={currentFilter} onChange={handleFilterChange} />
|
||||
<LinesTable>
|
||||
{
|
||||
lines.map((line, index) =>
|
||||
<LinesTableRow key={line.id}
|
||||
index={index} line={line}
|
||||
onDelete={() => showDeleteModal(line.id)}
|
||||
onEditInPage={() => showEditPage(line.id)}
|
||||
/>)
|
||||
}
|
||||
</LinesTable>
|
||||
<ModalConfirm show={isDeleteModalShow}
|
||||
onConfirm={handleDeleteConfirm} onClose={handleDeleteCancel}
|
||||
title='Удаление' message='Удалить элемент?' />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Lines;
|
30
src/components/lines/table/LinesTable.jsx
Normal file
@ -0,0 +1,30 @@
|
||||
import PropTypes from 'prop-types';
|
||||
import { Table } from 'react-bootstrap';
|
||||
|
||||
const LinesTable = ({ children }) => {
|
||||
return (
|
||||
<Table className='mt-2' striped responsive>
|
||||
<thead style={{ backgroundColor: '#03001F' }}>
|
||||
<tr>
|
||||
<th scope="col" className="colums" style={{ color: 'white' }}>№</th>
|
||||
<th scope="col" className="w-25 colums" style={{ color: 'white' }}>Жанр</th>
|
||||
<th scope="col" className="w-25 colums" style={{ color: 'white' }}>Название</th>
|
||||
<th scope="col" className="w-25 colums" style={{ color: 'white' }}>Актерский состав</th>
|
||||
<th scope="col" className="w-25 colums" style={{ color: 'white' }}>Описание</th>
|
||||
<th scope="col" className="w-25 colums" style={{ color: 'white' }}>Рейтинг</th>
|
||||
<th scope="col"></th>
|
||||
<th scope="col"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{children}
|
||||
</tbody >
|
||||
</Table >
|
||||
);
|
||||
};
|
||||
|
||||
LinesTable.propTypes = {
|
||||
children: PropTypes.node,
|
||||
};
|
||||
|
||||
export default LinesTable;
|
34
src/components/lines/table/LinesTableRow.jsx
Normal file
@ -0,0 +1,34 @@
|
||||
import PropTypes from 'prop-types';
|
||||
import { PencilSquare, Trash3 } from 'react-bootstrap-icons';
|
||||
|
||||
const LinesTableRow = ({
|
||||
index, line, onDelete, onEditInPage,
|
||||
}) => {
|
||||
const handleAnchorClick = (event, action) => {
|
||||
event.preventDefault();
|
||||
action();
|
||||
};
|
||||
|
||||
return (
|
||||
<tr>
|
||||
<th scope="row">{index + 1}</th>
|
||||
<td>{line.genres.name}</td>
|
||||
<td>{line.title}</td>
|
||||
<td>{line.cast}</td>
|
||||
<td>{line.description}</td>
|
||||
<td>{line.rating}</td>
|
||||
<td><a href="#" onClick={(event) => handleAnchorClick(event, onEditInPage)}><PencilSquare /></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;
|
3
src/components/modal/Modal.css
Normal file
@ -0,0 +1,3 @@
|
||||
.modal-title {
|
||||
font-size: 1.2rem;
|
||||
}
|
42
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
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;
|
21
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;
|
12
src/components/navigation/Navigation.css
Normal file
@ -0,0 +1,12 @@
|
||||
.my-navbar {
|
||||
background-color: #3c3c3c !important;
|
||||
}
|
||||
|
||||
.my-navbar .link a:hover {
|
||||
text-decoration: underline !important;
|
||||
}
|
||||
|
||||
.my-navbar .logo {
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
}
|
34
src/components/navigation/Navigation.jsx
Normal file
@ -0,0 +1,34 @@
|
||||
import PropTypes from 'prop-types';
|
||||
import {
|
||||
Container, Nav, Navbar,
|
||||
} from 'react-bootstrap';
|
||||
import { Link } from 'react-router-dom';
|
||||
import title from '../../assets/Title.png';
|
||||
import NavButton from '../button/NavButton.jsx';
|
||||
|
||||
const Navigation = ({ routes }) => {
|
||||
const indexPageLink = routes.filter((route) => route.index === false).shift();
|
||||
return (
|
||||
<header>
|
||||
<Navbar expand='md' className='my-navbar fixed-top' style={{ backgroundColor: '#03001F' }}>
|
||||
<Container fluid>
|
||||
<Navbar.Brand as={Link} to={indexPageLink?.path ?? '/'}>
|
||||
<img className="MainTitle" src={title} alt="название" aria-controls='main-navbar'/>
|
||||
</Navbar.Brand>
|
||||
<Navbar.Toggle aria-controls='main-navbar' />
|
||||
<Navbar.Collapse id='main-navbar' style={{ flexGrow: '0' }}>
|
||||
<Nav className="navbar-nav">
|
||||
<NavButton></NavButton>
|
||||
</Nav>
|
||||
</Navbar.Collapse>
|
||||
</Container>
|
||||
</Navbar >
|
||||
</header>
|
||||
);
|
||||
};
|
||||
|
||||
Navigation.propTypes = {
|
||||
routes: PropTypes.array,
|
||||
};
|
||||
|
||||
export default Navigation;
|
15
src/components/search/SearchButton.jsx
Normal file
@ -0,0 +1,15 @@
|
||||
import { PropTypes } from 'prop-types';
|
||||
import Input from '../input/Input.jsx';
|
||||
|
||||
const SearchButton = (props) => {
|
||||
return (
|
||||
<div className="col col-sm-4">
|
||||
<Input className="form-control" value={props.value} onChange={(event) => props.setSearchValue(event.target.value)} placeholder="Type to search..."/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
SearchButton.propTypes = {
|
||||
value: PropTypes.object,
|
||||
setSearchValue: PropTypes.func,
|
||||
};
|
||||
export default SearchButton;
|
29
src/components/search/SearchHook.js
Normal file
@ -0,0 +1,29 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import LinesApiService from '../lines/service/LinesApiService';
|
||||
|
||||
const useHookSearch = (genreFilter) => {
|
||||
const [linesRefresh, setLinesRefresh] = useState(false);
|
||||
const [lines, setLines] = useState([]);
|
||||
const handleLinesChange = () => setLinesRefresh(!linesRefresh);
|
||||
|
||||
const getLines = async () => {
|
||||
let expand = '?_expand=genres';
|
||||
if (genreFilter) {
|
||||
expand = `${expand}&title_like=${genreFilter}`;
|
||||
}
|
||||
const data = await LinesApiService.getAll(expand);
|
||||
setLines(data ?? []);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
getLines();
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [linesRefresh, genreFilter]);
|
||||
|
||||
return {
|
||||
lines,
|
||||
handleLinesChange,
|
||||
};
|
||||
};
|
||||
|
||||
export default useHookSearch;
|
22
src/components/search/SearchMovie.js
Normal file
@ -0,0 +1,22 @@
|
||||
import { useLocation } from 'react-router-dom';
|
||||
import useHookSearch from './SearchHook';
|
||||
|
||||
const useQuery = () => {
|
||||
return new URLSearchParams(useLocation().search);
|
||||
};
|
||||
|
||||
const SearchMovies = () => {
|
||||
const query = useQuery();
|
||||
const searchText = query.get('find')?.toLowerCase() || '';
|
||||
const { lines } = useHookSearch(searchText);
|
||||
|
||||
const files = lines.filter((line) => (
|
||||
line.title.toLowerCase().includes(searchText.toLowerCase())
|
||||
));
|
||||
|
||||
return {
|
||||
files,
|
||||
};
|
||||
};
|
||||
|
||||
export default SearchMovies;
|
30
src/components/types/hooks/GenreHook.js
Normal file
@ -0,0 +1,30 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import GenreApiService from '../service/GenreApiService';
|
||||
|
||||
const useGenre = (id) => {
|
||||
const emptyItem = {
|
||||
name: '',
|
||||
};
|
||||
const [genres, setGenre] = useState({ ...emptyItem });
|
||||
|
||||
const getGenre = async (Tid = undefined) => {
|
||||
if (Tid && Tid > 0) {
|
||||
const data = await GenreApiService.get(Tid);
|
||||
setGenre(data);
|
||||
} else {
|
||||
setGenre({ ...emptyItem });
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
getGenre(id);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [id]);
|
||||
|
||||
return {
|
||||
genres,
|
||||
setGenre,
|
||||
};
|
||||
};
|
||||
|
||||
export default useGenre;
|
21
src/components/types/hooks/GenresHook.js
Normal file
@ -0,0 +1,21 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import GenreApiService from '../service/GenreApiService';
|
||||
|
||||
const useGenres = () => {
|
||||
const [genres, setTypes] = useState([]);
|
||||
|
||||
const getTypes = async () => {
|
||||
const data = await GenreApiService.getAll();
|
||||
setTypes(data ?? []);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
getTypes();
|
||||
}, []);
|
||||
|
||||
return {
|
||||
genres,
|
||||
};
|
||||
};
|
||||
|
||||
export default useGenres;
|
5
src/components/types/service/GenreApiService.js
Normal file
@ -0,0 +1,5 @@
|
||||
import ApiService from '../../api/ApiService';
|
||||
|
||||
const GenreApiService = new ApiService('genres');
|
||||
|
||||
export default GenreApiService;
|
5
src/components/types/service/UserApiService.js
Normal file
@ -0,0 +1,5 @@
|
||||
import ApiService from '../../api/ApiService';
|
||||
|
||||
const UserApiService = new ApiService('user');
|
||||
|
||||
export default UserApiService;
|
69
src/components/user/PhotoHook.js
Normal file
@ -0,0 +1,69 @@
|
||||
import toast from 'react-hot-toast';
|
||||
import UserApiService from '../types/service/UserApiService';
|
||||
import useLinesUser from '../lines/hooks/LinesUserHook';
|
||||
import getBase64FromFile from '../utils/Base64';
|
||||
|
||||
const usePhoto = (id, linesChangeHandle) => {
|
||||
const { item, setItem } = useLinesUser(id);
|
||||
|
||||
const getLineObject = (formData) => {
|
||||
const name = formData.name.toString();
|
||||
const login = formData.login.toString();
|
||||
const mail = formData.mail.toString();
|
||||
const password = formData.password.toString();
|
||||
const photo = formData.photo.startsWith('data:image') ? formData.photo : '';
|
||||
return {
|
||||
name,
|
||||
login,
|
||||
mail,
|
||||
password,
|
||||
photo,
|
||||
};
|
||||
};
|
||||
|
||||
const handleImageChange = async (event) => {
|
||||
const { files } = event.target;
|
||||
const file = await getBase64FromFile(files.item(0));
|
||||
setItem({
|
||||
...item,
|
||||
photo: file,
|
||||
});
|
||||
};
|
||||
const handleSubmit = async (event) => {
|
||||
const form = event.currentTarget;
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
const body = getLineObject(item);
|
||||
if (form.checkValidity()) {
|
||||
if (id === undefined) {
|
||||
await UserApiService.create(body);
|
||||
} else {
|
||||
await UserApiService.update(id, body);
|
||||
}
|
||||
if (linesChangeHandle) linesChangeHandle();
|
||||
toast.success('Элемент успешно сохранен', { id: 'LinesTable' });
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
const handleChange = (event) => {
|
||||
if (event.target.type === 'file') {
|
||||
handleImageChange(event);
|
||||
handleSubmit(event);
|
||||
return;
|
||||
}
|
||||
const inputName = event.target.name;
|
||||
const inputValue = event.target.type === 'checkbox' ? event.target.checked : event.target.value;
|
||||
setItem({
|
||||
...item,
|
||||
[inputName]: inputValue,
|
||||
});
|
||||
};
|
||||
return {
|
||||
item,
|
||||
handleSubmit,
|
||||
handleChange,
|
||||
};
|
||||
};
|
||||
|
||||
export default usePhoto;
|
21
src/components/user/UserHook.js
Normal file
@ -0,0 +1,21 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import UserApiService from '../types/service/UserApiService';
|
||||
|
||||
const useUsers = () => {
|
||||
const [user, setTypes] = useState([]);
|
||||
|
||||
const getTypes = async () => {
|
||||
const data = await UserApiService.getAll();
|
||||
setTypes(data ?? []);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
getTypes();
|
||||
}, []);
|
||||
|
||||
return {
|
||||
user,
|
||||
};
|
||||
};
|
||||
|
||||
export default useUsers;
|
33
src/components/user/UserJoinHook.js
Normal file
@ -0,0 +1,33 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import UserApiService from '../types/service/UserApiService';
|
||||
|
||||
const useJoinUser = (loginEnter) => {
|
||||
let login = loginEnter;
|
||||
const [user, setUser] = useState(null);
|
||||
|
||||
const getUser = async () => {
|
||||
const data = await UserApiService.getAll(`?login=${login}`);
|
||||
if (data && data.length > 0) {
|
||||
setUser(data[0]);
|
||||
} else {
|
||||
setUser(null);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
getUser(login);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
const handlerLoginChanged = (newLogin) => {
|
||||
login = newLogin;
|
||||
getUser();
|
||||
};
|
||||
|
||||
return {
|
||||
user,
|
||||
handlerLoginChanged,
|
||||
};
|
||||
};
|
||||
|
||||
export default useJoinUser;
|
15
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;
|
913
src/index.css
Normal file
@ -0,0 +1,913 @@
|
||||
h1 {
|
||||
font-size: 1.5em;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 1.25em;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 1.1em;
|
||||
}
|
||||
|
||||
.btn-mw {
|
||||
width: 100%;
|
||||
}
|
||||
.mt-2{
|
||||
--bs-table-bg: #03001F;
|
||||
--bs-table-color: white;
|
||||
--bs-table-striped-color: white;
|
||||
}
|
||||
.card-text{
|
||||
font-size: 14px;
|
||||
}
|
||||
.image-container{
|
||||
position: relative;
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
.image-container:hover{
|
||||
cursor: pointer;
|
||||
transform: scale(1.1);
|
||||
}
|
||||
.image-container:hover .overlay{
|
||||
opacity: 1;
|
||||
}
|
||||
.overlay{
|
||||
position: absolute;
|
||||
background: rgba(0,0,0, 0.8);
|
||||
width: 100%;
|
||||
transition: 0.5s ease;
|
||||
opacity: 0;
|
||||
bottom: 0;
|
||||
font-size: 20px;
|
||||
padding: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
@media (min-width: 768px) {
|
||||
.btn-mw {
|
||||
width: 30%;
|
||||
}
|
||||
}
|
||||
|
||||
.selector-for-some-widget {
|
||||
box-sizing: content-box;
|
||||
}
|
||||
header {
|
||||
background-color: #03001F;
|
||||
color: #ffffff;
|
||||
height: 64px;
|
||||
padding: 0.5em;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.navbar-collapse{
|
||||
background-color: #03001F;
|
||||
}
|
||||
.dropdown-menu{
|
||||
background-color: #03001F;
|
||||
}
|
||||
|
||||
header nav {
|
||||
justify-content: flex-end !important;
|
||||
display: flex !important;
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
header nav {
|
||||
height: 64px;
|
||||
margin-top: 0;
|
||||
}
|
||||
.aboba{
|
||||
height: 64px;
|
||||
margin-top: 0;
|
||||
}
|
||||
}
|
||||
@media (max-width: 1020px){
|
||||
.card-group{
|
||||
margin-top: 5%;
|
||||
}
|
||||
}
|
||||
|
||||
header nav a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.nav-link{
|
||||
color: white;
|
||||
}
|
||||
.nav-item{
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.btn-secondary{
|
||||
font-size: 40px;
|
||||
width: 15rem;
|
||||
margin: 0 0 0 0.5%;
|
||||
}
|
||||
.btn-light{
|
||||
max-width: 50rem;
|
||||
width: 50rem;
|
||||
font-size: 45px;
|
||||
margin: 2% 2% 0 2%;
|
||||
}
|
||||
.card-group {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
flex-grow: 1;
|
||||
}
|
||||
.rows{
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
.images{
|
||||
justify-content: space-around;
|
||||
}
|
||||
.prev{
|
||||
max-width: 13rem;
|
||||
}
|
||||
@media (max-width: 1200px ){
|
||||
.selector-for-some-widget {
|
||||
box-sizing: content-box;
|
||||
}
|
||||
.nav-link{
|
||||
color: white;
|
||||
}
|
||||
.navbar-nav{
|
||||
margin-right: 10px;
|
||||
}
|
||||
.navbar{
|
||||
margin-bottom: 5%;
|
||||
}
|
||||
.btn-secondary{
|
||||
font-size: 40px;
|
||||
}
|
||||
.btn-light{
|
||||
max-width: 50rem;
|
||||
width: 50rem;
|
||||
font-size: 45px;
|
||||
margin: 2% 2% 0 2%;
|
||||
}
|
||||
.card-group {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
}
|
||||
.prev{
|
||||
margin-left: 25%;
|
||||
max-width: 13rem;
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
@media (max-width: 1020px){
|
||||
.selector-for-some-widget {
|
||||
box-sizing: content-box;
|
||||
}
|
||||
.nav-link{
|
||||
color: white;
|
||||
}
|
||||
|
||||
.nav-item{
|
||||
margin-right: 10px;
|
||||
}
|
||||
.btn-secondary{
|
||||
font-size: 20px;
|
||||
width: 17rem;
|
||||
}
|
||||
.btn-light{
|
||||
max-width: 50rem;
|
||||
width: 50rem;
|
||||
font-size: 45px;
|
||||
margin: 2% 2% 0 2%;
|
||||
}
|
||||
.prev{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin-left: 50%;
|
||||
width: 50%;
|
||||
height: 50%;
|
||||
font-size: 13px;
|
||||
}
|
||||
.images{
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.genreselection{
|
||||
display: none;
|
||||
}
|
||||
.btn-light{
|
||||
display: none;
|
||||
}
|
||||
.text{
|
||||
display: none;
|
||||
}
|
||||
.btn-groups{
|
||||
margin-left: 20%;
|
||||
margin-top: 20%;
|
||||
width: 60%;
|
||||
height: 60%;
|
||||
}
|
||||
.dropbutton{
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
@media (min-width: 1020px){
|
||||
.btn-groups{
|
||||
display: none;
|
||||
}
|
||||
.genreselection{
|
||||
display: flex;
|
||||
font-family: Inter, serif;
|
||||
}
|
||||
|
||||
}
|
||||
@media (max-width: 510px){
|
||||
.prev{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin-left: 50%;
|
||||
width: 60%;
|
||||
height: 50%;
|
||||
font-size: 7px;
|
||||
}
|
||||
.btn-groups{
|
||||
margin-left: 20%;
|
||||
margin-top: 20%;
|
||||
width: 60%;
|
||||
height: 60%;
|
||||
}
|
||||
.btn-secondary{
|
||||
font-size: 20px;
|
||||
width: 10rem;
|
||||
}
|
||||
.card-group{
|
||||
margin-top: 10%;
|
||||
}
|
||||
.navbar-brand{
|
||||
width: 120px;
|
||||
}
|
||||
}
|
||||
@media (max-width: 1200px) {
|
||||
}
|
||||
.info{
|
||||
padding-top: 0;
|
||||
margin-left: 10%;
|
||||
font-size: 25px;
|
||||
color: white;
|
||||
}
|
||||
.FIO{
|
||||
font-size: 40px;
|
||||
margin-top: -15%;
|
||||
}
|
||||
.LK-img{
|
||||
height: 30%;
|
||||
width: 30%;
|
||||
}
|
||||
.LK_block{
|
||||
margin-left: 8%;
|
||||
margin-top: 10%;
|
||||
}
|
||||
@media (max-width: 990px){
|
||||
.blocks{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin-left: 20%;
|
||||
}
|
||||
.LK-img{
|
||||
min-height: 20%;
|
||||
min-width: 20%;
|
||||
}
|
||||
.Title_blocks{
|
||||
font-size: 20px;
|
||||
}
|
||||
}
|
||||
@media (max-width: 615px){
|
||||
.DobPhoto{
|
||||
margin-top: 5%;
|
||||
margin-left: 5%;
|
||||
flex-direction: column;
|
||||
}
|
||||
.upload-container{
|
||||
margin-left: 25%;
|
||||
margin-top: 5%;
|
||||
}
|
||||
.info{
|
||||
margin-top: 15%;
|
||||
}
|
||||
.Title_blocks{
|
||||
font-size: 15px
|
||||
}
|
||||
.button_add{
|
||||
margin-left: 25%;
|
||||
}
|
||||
}
|
||||
@media (max-width: 400px){
|
||||
.upload-container{
|
||||
width: 10%;
|
||||
margin-left: 5%;
|
||||
}
|
||||
.info{
|
||||
font-size: 15px;
|
||||
}
|
||||
.FIO{
|
||||
font-size: 25px;
|
||||
}
|
||||
.button_add{
|
||||
margin-left: 5%;
|
||||
}
|
||||
.navbar-brand{
|
||||
width: 10%;
|
||||
height: 5%;
|
||||
}
|
||||
}
|
||||
@media (min-width: 615px) {
|
||||
.DobPhoto {
|
||||
padding: 0;
|
||||
margin: 4% 0 0 2%;
|
||||
display: flex;
|
||||
justify-content: left;
|
||||
align-items: center;
|
||||
|
||||
}
|
||||
}
|
||||
.needs-validation{
|
||||
color: white;
|
||||
}
|
||||
.film{
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
margin-top: 2%;
|
||||
}
|
||||
.Rating{
|
||||
width: 300px;
|
||||
margin-left: 2%;
|
||||
}
|
||||
.prevFilm{
|
||||
width: 90%;
|
||||
margin-top: 15%;
|
||||
margin-left: 5%;
|
||||
}
|
||||
.rat{
|
||||
color: white;
|
||||
font-size: 25px;
|
||||
margin-top: 5%;
|
||||
margin-left: 8%;
|
||||
}
|
||||
.watch{
|
||||
margin-top: 5%;
|
||||
margin-left: 10%;
|
||||
}
|
||||
.description{
|
||||
width: 400px;
|
||||
height: 500px;
|
||||
margin-left: 5%;
|
||||
}
|
||||
.description_info{
|
||||
background-color: #414141;
|
||||
color: white;
|
||||
border-radius: 15px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
text-align: center;
|
||||
margin-top: 5%;
|
||||
margin-left: 5%;
|
||||
font-size: 20px;
|
||||
}
|
||||
.actorList{
|
||||
margin: 20px 0 0 100px;
|
||||
width: 250px;
|
||||
height: 90%;
|
||||
}
|
||||
.actor{
|
||||
background-color: #414141;
|
||||
color: white;
|
||||
border-radius: 15px;
|
||||
width: 80%;
|
||||
height: 100%;
|
||||
text-align: center;
|
||||
margin-top: 15%;
|
||||
margin-left: 5%;
|
||||
font-size: 20px;
|
||||
}
|
||||
@media (min-width: 990px){
|
||||
.MainTitle{
|
||||
width: 150px;
|
||||
height: 50px;
|
||||
margin-left: 5%;
|
||||
}
|
||||
}
|
||||
@media (max-width: 990px){
|
||||
.MainTitle{
|
||||
width: 150px;
|
||||
height: 50px;
|
||||
}
|
||||
.Rating{
|
||||
width: 70%;
|
||||
}
|
||||
.description{
|
||||
width: 70%;
|
||||
}
|
||||
.actor{
|
||||
width: 80%;
|
||||
}
|
||||
}
|
||||
@media (max-width: 770px) {
|
||||
.MainTitle{
|
||||
width: 170px;
|
||||
height: 60px;
|
||||
margin: 0;
|
||||
}
|
||||
.film{
|
||||
flex-direction: column;
|
||||
}
|
||||
.prevFilm{
|
||||
width: 60%;
|
||||
margin-left: 30%;
|
||||
margin-top: 10%;
|
||||
}
|
||||
.Rating{
|
||||
width: 80%;
|
||||
}
|
||||
.rat{
|
||||
width: 100%;
|
||||
margin-top: 2%;
|
||||
}
|
||||
.description{
|
||||
margin-left: 3%;
|
||||
}
|
||||
.description_info{
|
||||
width: 138%;
|
||||
height: 300px;
|
||||
}
|
||||
.actor{
|
||||
height: 100px;
|
||||
width: 200%;
|
||||
}
|
||||
|
||||
}
|
||||
@media (max-width: 580px){
|
||||
.description{
|
||||
width: 90%;
|
||||
}
|
||||
.description_info{
|
||||
width: 100%;
|
||||
}
|
||||
.actorList{
|
||||
margin: 0 0 0 0;
|
||||
width: 90%;
|
||||
}
|
||||
.actor{
|
||||
width: 100%;
|
||||
margin-top: 5%;
|
||||
margin-left: 6%;
|
||||
}
|
||||
}
|
||||
.video-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
color: #fff;
|
||||
}
|
||||
.mediaLK{
|
||||
margin-top: 1%;
|
||||
background-color: inherit;
|
||||
}
|
||||
.LK2{
|
||||
margin-top: 1%;
|
||||
background-color: inherit;
|
||||
}
|
||||
.index{
|
||||
margin-top: 1%;
|
||||
background-color: inherit;
|
||||
}
|
||||
.film{
|
||||
margin-top: 1%;
|
||||
background-color: inherit;
|
||||
}
|
||||
.admin{
|
||||
margin-top: 1%;
|
||||
background-color: inherit;
|
||||
}
|
||||
.input{
|
||||
background-color: inherit;
|
||||
}
|
||||
@media (max-width: 1200px){
|
||||
.mediaLK{
|
||||
margin-top: 0;
|
||||
}
|
||||
.LK2{
|
||||
margin-top: 0;
|
||||
}
|
||||
.index{
|
||||
margin-top: 0;
|
||||
}
|
||||
.film{
|
||||
margin-top: 0;
|
||||
}
|
||||
.admin{
|
||||
margin-top: 0;
|
||||
}
|
||||
.input{
|
||||
margin-top: 0;
|
||||
}
|
||||
}
|
||||
@media (min-width: 550px){
|
||||
.video-container{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-top: 15%;
|
||||
}
|
||||
}
|
||||
@media (max-width: 550px){
|
||||
.video-player{
|
||||
width: 70%;
|
||||
}
|
||||
.video-container{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-top: 45%;
|
||||
}
|
||||
}
|
||||
.pageLK{
|
||||
display: flex;
|
||||
-ms-flex-align: center;
|
||||
align-items: center;
|
||||
margin: -4% 0 2% 70%;
|
||||
}
|
||||
.text{
|
||||
color: white;
|
||||
font-size: 40px;
|
||||
font-family: JejuGothic, serif;
|
||||
margin: 12% 0 0 0;
|
||||
}
|
||||
.Photo{
|
||||
height: 32%;
|
||||
width: 27%;
|
||||
}
|
||||
|
||||
.Ganr{
|
||||
background: #8C8C8C;
|
||||
color: white;
|
||||
width: 40%;
|
||||
height: 60px;
|
||||
border-radius: 50px;
|
||||
text-align: center;
|
||||
margin: 1% 1% 0 1%;
|
||||
font-size: 35px;
|
||||
padding: 1% 0 0 0;
|
||||
}
|
||||
.Genre{
|
||||
background: #D9D9D9;
|
||||
color: white;
|
||||
width: 50%;
|
||||
height: 55px;
|
||||
border-radius: 10px;
|
||||
text-align: center;
|
||||
margin: 1.5% 1% 0 1%;
|
||||
font-size: 35px;
|
||||
padding: 1% 0 0 0;
|
||||
}
|
||||
.Genre2{
|
||||
background: #D9D9D9;
|
||||
color: white;
|
||||
width: 50%;
|
||||
height: 55px;
|
||||
border-radius: 10px;
|
||||
text-align: center;
|
||||
margin: 1.5% 1% 0 1%;
|
||||
font-size: 35px;
|
||||
padding: 1% 0 0 0;
|
||||
}
|
||||
.body{
|
||||
width:100%;
|
||||
height:100%;
|
||||
}
|
||||
.Join{
|
||||
position: absolute;
|
||||
background-color: white;
|
||||
border-radius: 5%;
|
||||
margin: 10% 25% 10% 35%;
|
||||
height: 50%;
|
||||
width: 35%;
|
||||
}
|
||||
.name{
|
||||
background-color: #D9D9D9;
|
||||
color: black;
|
||||
font-size: 28px;
|
||||
margin: 10% 10% 0 15%;
|
||||
width: 70%;
|
||||
height: 40px;
|
||||
border-radius: 50px;
|
||||
}
|
||||
.Title{
|
||||
width:150px;
|
||||
height:50px;
|
||||
}
|
||||
|
||||
@media (max-width: 800px) {
|
||||
.Join{
|
||||
position: absolute;
|
||||
background-color: white;
|
||||
border-radius: 5%;
|
||||
margin: 12% 14% 12% 14%;
|
||||
height: 60%;
|
||||
width: 70%;
|
||||
}
|
||||
.name{
|
||||
background-color: #D9D9D9;
|
||||
color: black;
|
||||
font-size: 28px;
|
||||
width: 70%;
|
||||
height: 40px;
|
||||
border-radius: 50px;
|
||||
}
|
||||
.pass{
|
||||
background-color: #D9D9D9;
|
||||
color: black;
|
||||
margin: 25% 10% 5% 15%;
|
||||
width: 70%;
|
||||
height: 40px;
|
||||
border-radius: 50px;
|
||||
}
|
||||
.ButtonJoin{
|
||||
background-color: #03001F;
|
||||
color: white;
|
||||
margin: 15% 10% 0 15%;
|
||||
width: 70%;
|
||||
height: 40px;
|
||||
border-radius: 50px;
|
||||
}
|
||||
.Mistake{
|
||||
color: #0047FF;
|
||||
font-size: 20px;
|
||||
margin: 5% 0 0 30%;
|
||||
}
|
||||
}
|
||||
.pass{
|
||||
background-color: #D9D9D9;
|
||||
color: black;
|
||||
font-size: 28px;
|
||||
margin: 8% 10% 0 15%;
|
||||
width: 70%;
|
||||
height: 40px;
|
||||
border-radius: 50px;
|
||||
}
|
||||
.ButtonJoin{
|
||||
background-color: #03001F;
|
||||
color: white;
|
||||
margin: 8% 10% 0 15%;
|
||||
width: 70%;
|
||||
height: 40px;
|
||||
border-radius: 50px;
|
||||
}
|
||||
.Mistake{
|
||||
color: #0047FF;
|
||||
font-size: 14px;
|
||||
margin: 5% 0 0 55%;
|
||||
}
|
||||
@media (min-width: 800px) {
|
||||
.reg_pass{
|
||||
background-color: #D9D9D9;
|
||||
color: black;
|
||||
font-size: 28px;
|
||||
margin: 3% 10% 0 15%;
|
||||
width: 70%;
|
||||
height: 40px;
|
||||
border-radius: 50px;
|
||||
}
|
||||
.reg_ButtonJoin{
|
||||
background-color: #03001F;
|
||||
color: white;
|
||||
margin: 3% 10% 0 15%;
|
||||
width: 70%;
|
||||
height: 40px;
|
||||
border-radius: 50px;
|
||||
}
|
||||
.reg_name{
|
||||
background-color: #D9D9D9;
|
||||
color: black;
|
||||
font-size: 28px;
|
||||
margin: 3% 10% 0 15%;
|
||||
width: 70%;
|
||||
height: 40px;
|
||||
border-radius: 50px;
|
||||
}
|
||||
.Title{
|
||||
width:150px;
|
||||
height:50px;
|
||||
}
|
||||
.reg_login{
|
||||
background-color: #D9D9D9;
|
||||
color: black;
|
||||
font-size: 28px;
|
||||
margin: 3% 10% 0 15%;
|
||||
width: 70%;
|
||||
height: 40px;
|
||||
border-radius: 50px;
|
||||
}
|
||||
.reg_mail{
|
||||
background-color: #D9D9D9;
|
||||
color: black;
|
||||
font-size: 28px;
|
||||
margin: 3% 10% 0 15%;
|
||||
width: 70%;
|
||||
height: 40px;
|
||||
border-radius: 50px;
|
||||
}
|
||||
}
|
||||
@media (max-width: 800px) {
|
||||
.reg_pass{
|
||||
background-color: #D9D9D9;
|
||||
color: black;
|
||||
font-size: 28px;
|
||||
margin: 5% 10% 0 15%;
|
||||
width: 70%;
|
||||
height: 40px;
|
||||
border-radius: 50px;
|
||||
}
|
||||
.reg_ButtonJoin{
|
||||
background-color: #03001F;
|
||||
color: white;
|
||||
margin: 5% 10% 0 15%;
|
||||
width: 70%;
|
||||
height: 40px;
|
||||
border-radius: 50px;
|
||||
}
|
||||
.reg_name{
|
||||
background-color: #D9D9D9;
|
||||
color: black;
|
||||
font-size: 28px;
|
||||
margin: 2% 10% 0 15%;
|
||||
width: 70%;
|
||||
height: 40px;
|
||||
border-radius: 50px;
|
||||
}
|
||||
.Title{
|
||||
width:200px;
|
||||
height:75px;
|
||||
}
|
||||
.reg_login{
|
||||
background-color: #D9D9D9;
|
||||
color: black;
|
||||
font-size: 28px;
|
||||
margin: 5% 10% 0 15%;
|
||||
width: 70%;
|
||||
height: 40px;
|
||||
border-radius: 50px;
|
||||
}
|
||||
.reg_mail{
|
||||
background-color: #D9D9D9;
|
||||
color: black;
|
||||
font-size: 28px;
|
||||
margin: 5% 10% 0 15%;
|
||||
width: 70%;
|
||||
height: 40px;
|
||||
border-radius: 50px;
|
||||
}
|
||||
}
|
||||
@media (max-width: 400px) {
|
||||
.reg_pass{
|
||||
background-color: #D9D9D9;
|
||||
color: black;
|
||||
font-size: 28px;
|
||||
margin: 10% 10% 0 15%;
|
||||
width: 70%;
|
||||
height: 40px;
|
||||
border-radius: 50px;
|
||||
}
|
||||
.reg_ButtonJoin{
|
||||
background-color: #03001F;
|
||||
color: white;
|
||||
margin: 10% 10% 0 15%;
|
||||
width: 70%;
|
||||
height: 40px;
|
||||
border-radius: 50px;
|
||||
}
|
||||
.reg_name{
|
||||
background-color: #D9D9D9;
|
||||
color: black;
|
||||
font-size: 28px;
|
||||
margin: 10% 10% 0 15%;
|
||||
width: 70%;
|
||||
height: 40px;
|
||||
border-radius: 50px;
|
||||
}
|
||||
.Title{
|
||||
width:150px;
|
||||
height:75px;
|
||||
}
|
||||
.reg_login{
|
||||
background-color: #D9D9D9;
|
||||
color: black;
|
||||
font-size: 28px;
|
||||
margin: 10% 10% 0 15%;
|
||||
width: 70%;
|
||||
height: 40px;
|
||||
border-radius: 50px;
|
||||
}
|
||||
.reg_mail{
|
||||
background-color: #D9D9D9;
|
||||
color: black;
|
||||
font-size: 28px;
|
||||
margin: 10% 10% 0 15%;
|
||||
width: 70%;
|
||||
height: 40px;
|
||||
border-radius: 50px;
|
||||
}
|
||||
.Mistake{
|
||||
color: #0047FF;
|
||||
font-size: 14px;
|
||||
margin: 7% 0 0 38%;
|
||||
}
|
||||
}
|
||||
|
||||
.EnterLK{
|
||||
background: #03001F;
|
||||
color: white;
|
||||
font-family: Inter, serif;
|
||||
margin: -5% 1% 5% 75%;
|
||||
width: 60px;
|
||||
height: 25px;
|
||||
border: 1px solid #03B8B8;
|
||||
border-radius: 50px;
|
||||
font-size: 16px;
|
||||
}
|
||||
.RegLk{
|
||||
background: #03001F;
|
||||
color: white;
|
||||
font-family: Inter, serif;
|
||||
margin: -5% 1% 5% 0;
|
||||
width: 120px;
|
||||
height: 25px;
|
||||
border: 1px solid #03B8B8;
|
||||
border-radius: 50px;
|
||||
font-size: 16px;
|
||||
}
|
||||
.buttonLK{
|
||||
background: #03001F;
|
||||
color: white;
|
||||
font-family: Inter, serif;
|
||||
margin: -5% 1% 5% 0;
|
||||
width: 150px;
|
||||
height: 25px;
|
||||
border: 1px solid #03B8B8;
|
||||
border-radius: 50px;
|
||||
font-size: 16px;
|
||||
}
|
||||
.buttonLK:visited{
|
||||
color: white;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#upload-container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
width: 200px;
|
||||
height: 250px;
|
||||
outline: 2px dashed #5d5d5d;
|
||||
outline-offset: -12px;
|
||||
background-color: #e0f2f7;
|
||||
color: #1f3c44;
|
||||
|
||||
}
|
||||
|
||||
#upload-container img {
|
||||
width: 40%;
|
||||
margin-bottom: 20px;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
#upload-container label {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#upload-container label:hover {
|
||||
cursor: pointer;
|
||||
text-decoration: underline;
|
||||
}
|
||||
#upload-container div {
|
||||
position: relative;
|
||||
z-index: 10;
|
||||
padding: 0 0 0 10%;
|
||||
}
|
||||
|
||||
.button_input{
|
||||
margin-top: 2%;
|
||||
}
|
||||
@media (max-width: 615px){
|
||||
.AdminPanel{
|
||||
margin-top: 5%;
|
||||
}
|
||||
}
|
||||
.text-center{
|
||||
margin-top: 1%;
|
||||
}
|
||||
|
||||
@media (min-width: 1200px) {
|
||||
.btn-mw {
|
||||
width: 20%;
|
||||
}
|
||||
}
|
85
src/main.jsx
Normal file
@ -0,0 +1,85 @@
|
||||
import 'bootstrap/dist/css/bootstrap.min.css';
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import { RouterProvider, createBrowserRouter } from 'react-router-dom';
|
||||
import App from './App.jsx';
|
||||
import './index.css';
|
||||
import ErrorPage from './pages/ErrorPage.jsx';
|
||||
import Index from './pages/Index.jsx';
|
||||
import LK from './pages/LK.jsx';
|
||||
import Film from './pages/Film.jsx';
|
||||
import Admin from './pages/Admin.jsx';
|
||||
import Input from './pages/Input.jsx';
|
||||
import Join from './pages/Join.jsx';
|
||||
import Register from './pages/Register.jsx';
|
||||
import Media from './pages/Media.jsx';
|
||||
import Genre from './pages/Genre.jsx';
|
||||
import Search from './pages/Search.jsx';
|
||||
|
||||
const routes = [
|
||||
{
|
||||
index: true,
|
||||
path: '/',
|
||||
element: <Index />,
|
||||
title: 'Главная страница',
|
||||
},
|
||||
{
|
||||
path: '/LK/:id?',
|
||||
element: <LK />,
|
||||
title: 'Личный кабинет',
|
||||
},
|
||||
{
|
||||
path: '/Film/:id?',
|
||||
element: <Film />,
|
||||
title: 'Страница фильма',
|
||||
},
|
||||
{
|
||||
path: '/Join',
|
||||
element: <Join />,
|
||||
title: 'Страница входа',
|
||||
},
|
||||
{
|
||||
path: '/Register',
|
||||
element: <Register />,
|
||||
title: 'Страница регистрации',
|
||||
},
|
||||
{
|
||||
path: '/Media/:id?',
|
||||
element: <Media />,
|
||||
title: 'Страница видеоплеера',
|
||||
},
|
||||
{
|
||||
path: '/Admin',
|
||||
element: <Admin />,
|
||||
title: 'Админ-панель',
|
||||
},
|
||||
{
|
||||
path: '/Input/:id?',
|
||||
element: <Input />,
|
||||
},
|
||||
{
|
||||
path: '/Genre/:id?',
|
||||
element: <Genre />,
|
||||
title: 'Страница Жанра',
|
||||
},
|
||||
{
|
||||
path: '/Search',
|
||||
element: <Search />,
|
||||
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
src/pages/Admin.jsx
Normal file
@ -0,0 +1,9 @@
|
||||
import Lines from '../components/lines/table/Lines.jsx';
|
||||
|
||||
const Admin = () => {
|
||||
return (
|
||||
<Lines />
|
||||
);
|
||||
};
|
||||
|
||||
export default Admin;
|
19
src/pages/ErrorPage.jsx
Normal file
@ -0,0 +1,19 @@
|
||||
import { Alert, Button, Container } from 'react-bootstrap';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
const ErrorPage = () => {
|
||||
const navigate = useNavigate();
|
||||
|
||||
return (
|
||||
<Container fluid className="p-2 row justify-content-center">
|
||||
<Container className='col-md-6'>
|
||||
<Alert variant="danger">
|
||||
Страница не найдена
|
||||
</Alert>
|
||||
<Button className="w-25 mt-2" variant="primary" onClick={() => navigate(-1)}>Назад</Button>
|
||||
</Container>
|
||||
</Container>
|
||||
);
|
||||
};
|
||||
|
||||
export default ErrorPage;
|
46
src/pages/Film.jsx
Normal file
@ -0,0 +1,46 @@
|
||||
import { useParams, Link } from 'react-router-dom';
|
||||
import useLinesItemForm from '../components/lines/hooks/LinesItemFormHook';
|
||||
|
||||
const Film = () => {
|
||||
const { id } = useParams();
|
||||
const { item } = useLinesItemForm(id);
|
||||
return (
|
||||
<div className="film rows container item">
|
||||
<div className="Rating">
|
||||
<div>
|
||||
<img className="prevFilm" src={ item.image } alt="превью"/>
|
||||
</div>
|
||||
<div className="rat">
|
||||
Рейтинг
|
||||
</div>
|
||||
<div className="rat">
|
||||
{ item.rating } из 10
|
||||
</div>
|
||||
</div>
|
||||
<div className="description">
|
||||
<div className="rat">
|
||||
{ item.title }
|
||||
</div>
|
||||
<div>
|
||||
<button className="btn btn-warning watch"><Link className="nav-link" aria-current="page" to={`/Media/${item.id}`} style={{ textDecoration: 'none' }}>Просмотр</Link></button>
|
||||
</div>
|
||||
<div className="description_info">
|
||||
Описание
|
||||
<div>
|
||||
{ item.description }
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="actorList">
|
||||
<div style={{ color: 'white', margin: '40px 0 0 30px', fontSize: '20px' }}>
|
||||
Актерский состав
|
||||
</div>
|
||||
<div className="actor">
|
||||
{ item.cast }
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Film;
|
21
src/pages/Genre.jsx
Normal file
@ -0,0 +1,21 @@
|
||||
import { useParams } from 'react-router-dom';
|
||||
import useLines from '../components/lines/hooks/LinesHook';
|
||||
import CreateCard from '../components/Card/Cards.jsx';
|
||||
import useGenre from '../components/types/hooks/GenreHook';
|
||||
|
||||
const Genre = () => {
|
||||
const { id } = useParams();
|
||||
const { lines } = useLines(id);
|
||||
const { genres } = useGenre(id);
|
||||
return (
|
||||
<>
|
||||
<span className="text">{ genres.name }</span>
|
||||
<div className="card-group rows images">
|
||||
{
|
||||
lines.map((el) => <CreateCard key={el.id} line={el}/>)
|
||||
}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default Genre;
|
51
src/pages/Index.jsx
Normal file
@ -0,0 +1,51 @@
|
||||
import { Button, Dropdown } from 'react-bootstrap';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import useLines from '../components/lines/hooks/LinesHook';
|
||||
import CreateCard from '../components/Card/Cards.jsx';
|
||||
import useGenres from '../components/types/hooks/GenresHook';
|
||||
|
||||
const Index = () => {
|
||||
const { lines } = useLines();
|
||||
const { genres } = useGenres();
|
||||
const navigate = useNavigate();
|
||||
const RedirectSearch = (event) => {
|
||||
event.preventDefault();
|
||||
const searchText = document.getElementById('search').value;
|
||||
navigate(`/search?find=${encodeURIComponent(searchText)}`);
|
||||
};
|
||||
return (
|
||||
<>
|
||||
<right><div style={{ marginTop: '50px' }}>
|
||||
<input type="search" id="search" style={{
|
||||
borderRadius: '15px', borderColor: '#0dcaf0', backgroundColor: '#03001F', marginLeft: '20px', color: 'white',
|
||||
}} placeholder="Поиск" aria-label="Search" />
|
||||
<button onClick={RedirectSearch} className="btn" style={{ borderColor: '#0dcaf0', borderRadius: '50px', marginTop: '-3px' }} type="submit" >
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" fill="currentColor" className="bi bi-search" viewBox="0 0 16 16">
|
||||
<path d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001q.044.06.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1 1 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div></right>
|
||||
<span className="text">Жанры</span>
|
||||
<div className="genreselection">
|
||||
{ genres.map((ge) => <Button className="btn" variant="secondary" style={{ width: '17rem', margin: '0 0 0 1%' }} key={ge.id} onClick={() => navigate(`/Genre/${ge.id}`)} >{ge.name}</Button>) }
|
||||
</div>
|
||||
|
||||
<Dropdown className="btn-groups dropup" style={{ height: '50' }}>
|
||||
<Dropdown.Toggle className="btn dropbutton dropdown-toggle" variant="info" data-bs-toggle="dropdown" aria-expanded="false" style={{ fontSize: '20px' }}>
|
||||
Жанры
|
||||
</Dropdown.Toggle>
|
||||
<Dropdown.Menu>
|
||||
{ genres.map((ge) => <Button className="btn" flexWrap="wrap" variant="secondary" style={{ width: '10rem', margin: '0 0 0 1%' }} key={ge.id} onClick={() => navigate(`/Genre/${ge.id}`)} >{ge.name}</Button>) }
|
||||
</Dropdown.Menu>
|
||||
</Dropdown>
|
||||
<span className="text">Рекомендуемое</span>
|
||||
<div className="card-group rows images">
|
||||
{
|
||||
lines.map((el) => <CreateCard key={el.id} line={el}/>)
|
||||
}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Index;
|
12
src/pages/Input.jsx
Normal file
@ -0,0 +1,12 @@
|
||||
import { useParams } from 'react-router-dom';
|
||||
import LinesForm from '../components/lines/form/LinesForm.jsx';
|
||||
|
||||
const Input = () => {
|
||||
const { id } = useParams();
|
||||
|
||||
return (
|
||||
<LinesForm id={id} />
|
||||
);
|
||||
};
|
||||
|
||||
export default Input;
|
65
src/pages/Join.jsx
Normal file
@ -0,0 +1,65 @@
|
||||
import { useState } from 'react';
|
||||
import { useNavigate, Link } from 'react-router-dom';
|
||||
import { Button, Form, FormGroup } from 'react-bootstrap';
|
||||
import titleBlack from '../assets/Title_black.png';
|
||||
import useJoinUser from '../components/user/UserJoinHook';
|
||||
|
||||
const Join = () => {
|
||||
const navigator = useNavigate();
|
||||
const [validated, setValidated] = useState(false);
|
||||
const [formData, setFormData] = useState({
|
||||
login: '',
|
||||
password: '',
|
||||
});
|
||||
|
||||
const { user, handlerLoginChanged } = useJoinUser(formData.email);
|
||||
|
||||
const handleSubmit = (event) => {
|
||||
const form = event.currentTarget;
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
if (form.checkValidity() !== false) {
|
||||
console.log(formData);
|
||||
}
|
||||
if (user === null) {
|
||||
return;
|
||||
}
|
||||
if (user.password === formData.password) {
|
||||
const ind = user.id;
|
||||
localStorage.setItem('EnabledUser', JSON.stringify(user.id));
|
||||
navigator(`/LK/${ind}`);
|
||||
}
|
||||
|
||||
setValidated(true);
|
||||
};
|
||||
|
||||
const handleChange = (event) => {
|
||||
const inputName = event.target.name;
|
||||
const inputValue = event.target.type === 'checkbox' ? event.target.checked : event.target.value;
|
||||
setFormData({
|
||||
...formData,
|
||||
[inputName]: inputValue,
|
||||
});
|
||||
if (inputName === 'login') {
|
||||
handlerLoginChanged(inputValue);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form className="Join" noValidate validated={validated} onSubmit={handleSubmit}>
|
||||
<center><Button as={Link} to="/" style={{ backgroundColor: 'white', borderColor: 'white', marginTop: '20px' }}><img id="image_title" src={titleBlack} alt="название" className="Title"/></Button></center>
|
||||
<FormGroup className="name">
|
||||
<Form.Label className="form-label"></Form.Label>
|
||||
<Form.Control type="text" name="login" className="form-control" placeholder="Логин" value={formData.login} onChange={handleChange} required />
|
||||
</FormGroup>
|
||||
<FormGroup className="pass">
|
||||
<Form.Label className="form-label"></Form.Label>
|
||||
<Form.Control type="password" name="password" placeholder="Пароль" className="form-control" value={formData.password} onChange={handleChange} required />
|
||||
</FormGroup>
|
||||
<Button className="ButtonJoin" type="submit">Войти</Button>
|
||||
</Form>
|
||||
</>
|
||||
);
|
||||
};
|
||||
export default Join;
|
28
src/pages/LK.jsx
Normal file
@ -0,0 +1,28 @@
|
||||
import { useParams } from 'react-router-dom';
|
||||
import AdminButton from '../components/button/AdminButton.jsx';
|
||||
import UserPhoto from '../components/UserPhoto.jsx';
|
||||
import usePhoto from '../components/user/PhotoHook';
|
||||
|
||||
const LK = () => {
|
||||
const { id } = useParams();
|
||||
const { item, handleChange } = usePhoto(id);
|
||||
const onSubmit = async (event) => {
|
||||
await handleChange(event);
|
||||
};
|
||||
return (
|
||||
<>
|
||||
<div className="DobPhoto rows">
|
||||
<UserPhoto item={ item } handleChange={ onSubmit } />
|
||||
<div className="info">
|
||||
<div className="FIO">{ item.name }</div>
|
||||
<div className="info_list-item" style={{ marginTop: '5%' }}>Ваш логин: { item.login }</div>
|
||||
<div className="info_list-item" style={{ marginTop: '5%', marginBottom: '5%' }}>Ваша почта: { item.mail }</div>
|
||||
<AdminButton></AdminButton>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
// eslint-disable-next-line react-refresh/only-export-components
|
||||
export default LK;
|
18
src/pages/Media.jsx
Normal file
@ -0,0 +1,18 @@
|
||||
import { useParams } from 'react-router-dom';
|
||||
import useLinesItemForm from '../components/lines/hooks/LinesItemFormHook';
|
||||
|
||||
const Media = () => {
|
||||
const { id } = useParams();
|
||||
const { item } = useLinesItemForm(id);
|
||||
return (
|
||||
<>
|
||||
<main className="h-100 d-flex flex-column" style={{ backgroundColor: '#03001F' }}>
|
||||
<div className='video-container'>
|
||||
<video controls src={ item.video } className='video-player' id='video-player' preload='metadata'></video>
|
||||
</div>
|
||||
</main>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Media;
|
32
src/pages/Register.jsx
Normal file
@ -0,0 +1,32 @@
|
||||
import { Button, Form } from 'react-bootstrap';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import useLinesUserForm from '../components/lines/hooks/LinesUserFormHook';
|
||||
import FormRegister from '../components/lines/register/FormReg.jsx';
|
||||
|
||||
const Register = () => {
|
||||
const { id } = useParams();
|
||||
const navigate = useNavigate();
|
||||
const {
|
||||
item,
|
||||
validated,
|
||||
handleSubmit,
|
||||
handleChange,
|
||||
} = useLinesUserForm(id);
|
||||
|
||||
const onSubmit = async (event) => {
|
||||
if (await handleSubmit(event)) {
|
||||
navigate(-1);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form className="Join" noValidate validated={validated} onSubmit={onSubmit}>
|
||||
<FormRegister item = {item} handleChange={handleChange}></FormRegister>
|
||||
<Button className="reg_ButtonJoin" type="submit">Регистрация</Button>
|
||||
</Form>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Register;
|
34
src/pages/Search.jsx
Normal file
@ -0,0 +1,34 @@
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import SearchMovies from '../components/search/SearchMovie';
|
||||
import CreateCard from '../components/Card/Cards.jsx';
|
||||
|
||||
const Search = () => {
|
||||
const { files } = SearchMovies();
|
||||
const navigate = useNavigate();
|
||||
const RedirectSearch = (event) => {
|
||||
event.preventDefault();
|
||||
const searchText = document.getElementById('search').value;
|
||||
navigate(`/search?find=${encodeURIComponent(searchText)}`);
|
||||
};
|
||||
return (
|
||||
<>
|
||||
<center><div style={{ marginTop: '20px', marginBottom: '20px' }}>
|
||||
<input type="search" id="search" style={{
|
||||
borderRadius: '15px', borderColor: '#0dcaf0', backgroundColor: '#03001F', marginLeft: '20px', color: 'white',
|
||||
}} placeholder="Поиск" aria-label="Search" />
|
||||
<button onClick={RedirectSearch} className="btn" style={{ borderColor: '#0dcaf0', borderRadius: '50px', marginTop: '-3px' }} type="submit" >
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" fill="currentColor" className="bi bi-search" viewBox="0 0 16 16">
|
||||
<path d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001q.044.06.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1 1 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div></center>
|
||||
<div className="card-group rows images">
|
||||
{
|
||||
files.map((el) => <CreateCard key={el.id} line={el}/>)
|
||||
}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Search;
|
13
vite.config.js
Normal file
@ -0,0 +1,13 @@
|
||||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
import react from '@vitejs/plugin-react';
|
||||
import { defineConfig } from 'vite';
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
build: {
|
||||
sourcemap: true,
|
||||
chunkSizeWarningLimit: 1024,
|
||||
emptyOutDir: true,
|
||||
},
|
||||
});
|