Лаб5
28
Lab5 old/.eslintrc.cjs
Normal file
@ -0,0 +1,28 @@
|
||||
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',
|
||||
'no-trailing-spaces' : 'off',
|
||||
'max-len' : 'off',
|
||||
'no-multiple-empty-lines' : 'off',
|
||||
},
|
||||
}
|
45
Lab5 old/.gitignore
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
||||
|
||||
# Compiled output
|
||||
/dist
|
||||
/tmp
|
||||
/out-tsc
|
||||
/bazel-out
|
||||
|
||||
# Node
|
||||
/node_modules
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
|
||||
# IDEs and editors
|
||||
.idea/
|
||||
.project
|
||||
.classpath
|
||||
.c9/
|
||||
*.launch
|
||||
.settings/
|
||||
*.sublime-workspace
|
||||
|
||||
# Visual Studio Code
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
.history/*
|
||||
|
||||
# Miscellaneous
|
||||
/.angular/cache
|
||||
.sass-cache/
|
||||
/connect.lock
|
||||
/coverage
|
||||
/libpeerconnection.log
|
||||
testem.log
|
||||
/typings
|
||||
|
||||
# System files
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Ignore dist
|
||||
dist/
|
BIN
Lab5 old/Dark Nights preview.jpg
Normal file
After Width: | Height: | Size: 63 KiB |
BIN
Lab5 old/Late Shift preview.jpg
Normal file
After Width: | Height: | Size: 91 KiB |
BIN
Lab5 old/Papers, Please preview.jpg
Normal file
After Width: | Height: | Size: 30 KiB |
BIN
Lab5 old/Song of Farca preview.jpg
Normal file
After Width: | Height: | Size: 72 KiB |
BIN
Lab5 old/Ten Dates preview.jpg
Normal file
After Width: | Height: | Size: 82 KiB |
80
Lab5 old/admin.html
Normal file
@ -0,0 +1,80 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Steam</title>
|
||||
<script type="module" src="./node_modules/bootstrap/dist/js/bootstrap.js"></script>
|
||||
<link rel="stylesheet" href="./node_modules/bootstrap/dist/css/bootstrap.css" />
|
||||
<link rel="stylesheet" href="style.css">
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-md navbar-dark">
|
||||
<div class="container-fluid">
|
||||
<a class="nav-link active" href="./index.html"> Главная </a>
|
||||
<!--КНОПКА С ТРЕМЯ ПОЛОСКАМИ ПРИ УМЕНЬШЕНИИ-->
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
|
||||
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="navbar-collapse collapse justify-content-end" id="navbarNav">
|
||||
<div class="navbar-nav">
|
||||
<a class="nav-link active" href="./basket.html">Корзина</a>
|
||||
<a class="nav-link active" href="./library.html">Библиотека</a>
|
||||
<a class="nav-link active" href="./entry.html">Вход</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="container-fluid p-2">
|
||||
<div class="text-center">
|
||||
<img id="image-preview" src="placeholder.jpg" alt="placeholder">
|
||||
</div>
|
||||
|
||||
<form id="games-form" class="admin_panel mt-4 needs-validation" novalidate>
|
||||
<div class="input-group mb-4">
|
||||
<span class="input-group-text span_admin_panel" id="basic-addon1">Жанр:</span>
|
||||
<select id="genre" class="form-select" name="selected" required>
|
||||
</select>
|
||||
</div>
|
||||
<div class="input-group mb-4">
|
||||
<span class="input-group-text span_admin_panel" id="basic-addon1">Название:</span>
|
||||
<input id="name" type="text" class="form-control" placeholder="Название" required>
|
||||
</div>
|
||||
<div class="input-group mb-4">
|
||||
<span class="input-group-text span_admin_panel" id="basic-addon1">Цена:</span>
|
||||
<input id = "price" type="number" class="form-control" placeholder="Цена" required>
|
||||
</div>
|
||||
<div class="input-group mb-4">
|
||||
<span class="input-group-text span_admin_panel" id="basic-addon1">Фото:</span>
|
||||
<input id="image" name="image" type="file" class="form-control" placeholder="Фото" accept="image/*">
|
||||
</div>
|
||||
<div class = "d-flex justify-content-center">
|
||||
<button class = "btn_admin_panel" type="submit"> Подтвердить </button> <!-- onclick="window.location.href = './index.html';" -->
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
</main>
|
||||
<footer class="footer mt-auto d-flex flex-shrink-0 justify-content-center align-items-center">
|
||||
</footer>
|
||||
<script type="module">
|
||||
import validation from "./js/validation";
|
||||
import { linesPageForm } from "./js/lines"
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
validation();
|
||||
linesPageForm();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
96
Lab5 old/basket.html
Normal file
@ -0,0 +1,96 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Steam</title>
|
||||
<script type="module" src="./node_modules/bootstrap/dist/js/bootstrap.js"></script>
|
||||
<link rel="stylesheet" href="./node_modules/bootstrap/dist/css/bootstrap.css" />
|
||||
<link rel="stylesheet" href="style.css">
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-md navbar-dark">
|
||||
<div class="container-fluid">
|
||||
<a class="nav-link" href="./index.html"> Главная </a>
|
||||
|
||||
<!--КНОПКА С ТРЕМЯ ПОЛОСКАМИ ПРИ УМЕНЬШЕНИИ-->
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
|
||||
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="navbar-collapse collapse justify-content-end" id="navbarNav">
|
||||
<div class="navbar-nav">
|
||||
<a class="nav-link active" href="./basket.html">Корзина</a>
|
||||
<a class="nav-link active" href="./library.html">Библиотека</a>
|
||||
<a class="nav-link active" href="./entry.html">Вход</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="container-fluid p-2">
|
||||
<table class="table table-bordered align-middle">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class = "p-0 cell1_basket">
|
||||
<img src="Dark Nights preview.jpg" alt="Dark Nights with Poe & Munro" class="img-fluid">
|
||||
</td>
|
||||
<td class = "p-0 cell2_basket">
|
||||
<p class = "basket_name_of_game">Dark Nights with Poe and Munro</p>
|
||||
|
||||
</td>
|
||||
<td class = "p-0 text-center align-middle cell3_basket">
|
||||
|
||||
<p class = "price_of_game_main_page"> 299 руб.</p>
|
||||
</td>
|
||||
<td class = "p-0 text-center align-middle">
|
||||
<button class = "basket_delete_button"> X </button>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class = "p-0 cell1_basket">
|
||||
<img src="Ten Dates preview.jpg" alt="Ten Dates" class="img-fluid">
|
||||
</td>
|
||||
<td class = "p-0 text-center align-middle cell2_basket">
|
||||
<p class = "basket_name_of_game">Ten Dates</p>
|
||||
|
||||
</td>
|
||||
<td class = "p-0 text-center align-middle cell3_basket">
|
||||
<p class = "price_of_game_main_page"> 509 руб.</p>
|
||||
</td>
|
||||
<td class = "p-0 text-center align-middle">
|
||||
<button class = "basket_delete_button"> X </button>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="2" class = "align-left">
|
||||
<p class = "basket_price_of_games"> Итого: 808 руб.</p>
|
||||
</td>
|
||||
<td colspan="2" class = "text-end">
|
||||
<button class = "basket_buy_button">КУПИТЬ</button>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
</table>
|
||||
</main>
|
||||
|
||||
<footer class="footer mt-auto d-flex flex-shrink-0 justify-content-center align-items-center">
|
||||
Сайт Чернышева Георгия, ПИбд-22
|
||||
</footer>
|
||||
</body>
|
||||
|
||||
</html>
|
78
Lab5 old/create_account.html
Normal file
@ -0,0 +1,78 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Steam</title>
|
||||
<script type="module" src="./node_modules/bootstrap/dist/js/bootstrap.js"></script>
|
||||
<link rel="stylesheet" href="./node_modules/bootstrap/dist/css/bootstrap.css" />
|
||||
<link rel="stylesheet" href="style.css">
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-md navbar-dark">
|
||||
<div class="container-fluid">
|
||||
<a class="nav-link active" href="./index.html"> Главная </a>
|
||||
|
||||
<!--КНОПКА С ТРЕМЯ ПОЛОСКАМИ ПРИ УМЕНЬШЕНИИ-->
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
|
||||
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="navbar-collapse collapse justify-content-end" id="navbarNav">
|
||||
<div class="navbar-nav">
|
||||
<a class="nav-link active" href="./basket.html">Корзина</a>
|
||||
<a class="nav-link active" href="./library.html">Библиотека</a>
|
||||
<a class="nav-link active" href="./entry.html">Вход</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="container-fluid">
|
||||
<div class="row align-items-center justify-content-center mb-2 mt-20vh">
|
||||
<div class="col-auto justify-content-left">
|
||||
<label for="inputMail" class="account_text" id = "label_nickname">ВВЕДИТЕ ПОЧТУ:</label>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row align-items-center justify-content-center mb-2">
|
||||
<div class="col-auto justify-content-left">
|
||||
<label for="inputMail" class="account_text" id = "label_nickname">ВВЕДИТЕ НИК:</label>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<input type="text" class="form-control" aria-label="Username" id = "inputMail">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row align-items-center justify-content-center mb-2">
|
||||
<div class="col-auto">
|
||||
<label for="inputPassword6" class="account_text">ВВЕДИТЕ ПАРОЛЬ:</label>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<input type="password" id="inputPassword6" class="form-control" aria-describedby="passwordHelpInline">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row align-items-center justify-content-center">
|
||||
<div class="col-auto mt-3">
|
||||
<button class = "account_btn"> СОЗДАТЬ </button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</main>
|
||||
|
||||
<footer class="footer mt-auto d-flex flex-shrink-0 justify-content-center align-items-center">
|
||||
<a class = "account_text" href = "entry.html">ВОЙТИ В АККАУНТ</a>
|
||||
</footer>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
67
Lab5 old/dark_nights_page.html
Normal file
@ -0,0 +1,67 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Steam</title>
|
||||
<script type="module" src="./node_modules/bootstrap/dist/js/bootstrap.js"></script>
|
||||
<link rel="stylesheet" href="./node_modules/bootstrap/dist/css/bootstrap.css" />
|
||||
<link rel="stylesheet" href="style.css">
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-md navbar-dark">
|
||||
<div class="container-fluid">
|
||||
<a class="nav-link active" href="./index.html"> Главная </a>
|
||||
|
||||
<!--КНОПКА С ТРЕМЯ ПОЛОСКАМИ ПРИ УМЕНЬШЕНИИ-->
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
|
||||
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="navbar-collapse collapse justify-content-end" id="navbarNav">
|
||||
<div class="navbar-nav">
|
||||
<a class="nav-link active" href="./basket.html">Корзина</a>
|
||||
<a class="nav-link active" href="./library.html">Библиотека</a>
|
||||
<a class="nav-link active" href="./entry.html">Вход</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="container-fluid p-2">
|
||||
<!-- ВЕРХНИЙ DIV -->
|
||||
<div class = "row info_about_game_pic_and_name">
|
||||
<div class = "col-sm-5">
|
||||
<img src="Dark Nights preview.jpg" alt="Dark Nights with Poe & Munro" class="img-fluid">
|
||||
</div>
|
||||
<div class = "col-sm-7 text-center align-items-center">
|
||||
<p class = "info_about_game_name">Dark Nights with Poe and Munro</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class = "row">
|
||||
<div class = "col-sm 12">
|
||||
<p class = "info_about_game_text">Проведите местных радиоведущих По и Манро через шесть похожих на короткометражки эпизодов сверъестественной странности и обжигающего сюжета. От создателей The Infectious Madness of Doctor Dekker и The Shapeshifting Detective.</p>
|
||||
|
||||
</div>
|
||||
<div class = "info_about_game_div_button text-center align-items-center">
|
||||
<button class = "info_about_game_add_to_basket_button"> Добавить в корзину </button>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer class="footer mt-auto d-flex flex-shrink-0 justify-content-center align-items-center">
|
||||
Сайт Чернышева Георгия, ПИбд-22
|
||||
</footer>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
50
Lab5 old/data.json
Normal file
68
Lab5 old/entry.html
Normal file
@ -0,0 +1,68 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Steam</title>
|
||||
<script type="module" src="./node_modules/bootstrap/dist/js/bootstrap.js"></script>
|
||||
<link rel="stylesheet" href="./node_modules/bootstrap/dist/css/bootstrap.css" />
|
||||
<link rel="stylesheet" href="style.css">
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-md navbar-dark">
|
||||
<div class="container-fluid">
|
||||
<a class="nav-link active" href="./index.html"> Главная </a>
|
||||
|
||||
<!--КНОПКА С ТРЕМЯ ПОЛОСКАМИ ПРИ УМЕНЬШЕНИИ-->
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
|
||||
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="navbar-collapse collapse justify-content-end" id="navbarNav">
|
||||
<div class="navbar-nav">
|
||||
<a class="nav-link active" href="./basket.html">Корзина</a>
|
||||
<a class="nav-link active" href="./library.html">Библиотека</a>
|
||||
<a class="nav-link active" href="./entry.html">Вход</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
|
||||
<main class = "container-fluid">
|
||||
<div class="row align-items-center justify-content-center mb-2 mt-25vh">
|
||||
<div class="col-auto">
|
||||
<label for="inputMail" class="account_text" id = "label_nickname">ВВЕДИТЕ НИК:</label>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row align-items-center justify-content-center mb-2">
|
||||
<div class="col-auto">
|
||||
<label for="inputMail" class="account_text" id = "label_nickname">ВВЕДИТЕ ПАРОЛЬ:</label>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<input type="text" class="form-control" aria-label="Username" id = "inputMail">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row align-items-center justify-content-center">
|
||||
<div class="col-auto mt-3">
|
||||
<button class = "account_btn"> ВОЙТИ </button>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer class="footer mt-auto d-flex flex-shrink-0 justify-content-center align-items-center">
|
||||
<a class = "account_text" href = "create_account.html">СОЗДАТЬ АККАУНТ</a>
|
||||
</footer>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
12
Lab5 old/index.html
Normal file
@ -0,0 +1,12 @@
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Steam</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="root" class = "d-flex flex-column"></div>
|
||||
<script type="module" src="/src/main.jsx"></script>
|
||||
</body>
|
||||
</html>
|
15
Lab5 old/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/*"
|
||||
]
|
||||
}
|
120
Lab5 old/library.html
Normal file
@ -0,0 +1,120 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Steam</title>
|
||||
<script type="module" src="./node_modules/bootstrap/dist/js/bootstrap.js"></script>
|
||||
<link rel="stylesheet" href="./node_modules/bootstrap/dist/css/bootstrap.css" />
|
||||
<link rel="stylesheet" href="style.css">
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-md navbar-dark">
|
||||
<div class="container-fluid">
|
||||
<a class="nav-link active" href="./index.html"> Главная </a>
|
||||
|
||||
<!--КНОПКА С ТРЕМЯ ПОЛОСКАМИ ПРИ УМЕНЬШЕНИИ-->
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
|
||||
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="navbar-collapse collapse justify-content-end" id="navbarNav">
|
||||
<div class="navbar-nav">
|
||||
<a class="nav-link active" href="./basket.html">Корзина</a>
|
||||
<a class="nav-link active" href="./library.html">Библиотека</a>
|
||||
<a class="nav-link active" href="./entry.html">Вход</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="container-fluid p-2">
|
||||
<table class="table table-borderless table_of_library">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class = "align-middle p-0 cell1_library">
|
||||
<img src="Dark Nights preview.jpg" alt="Dark Nights with Poe & Munro" class="img-fluid">
|
||||
</td>
|
||||
<td class = "align-middle p-0 cell2_library">
|
||||
<a class = "nav-link library_name_of_game" href="./dark_nights_page.html">Dark Nights with Poe and Munro</a>
|
||||
</td>
|
||||
<td class = "align-middle text-center p-0">
|
||||
<select>
|
||||
<option disabled selected>ИГРА</option>
|
||||
<option>Играть</option>
|
||||
<option>Установить</option>
|
||||
<option>Удалить</option>
|
||||
</select>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class = "align-middle p-0 cell1_library" >
|
||||
<img src="Song of Farca preview.jpg" alt="Song of Farca" class="img-fluid">
|
||||
</td>
|
||||
<td class = "align-middle p-0 cell2_library" >
|
||||
<a class = "nav-link library_name_of_game" href="./dark_nights_page.html">Song of Farca</a>
|
||||
</td>
|
||||
<td class = "align-middle text-center p-0">
|
||||
<select>
|
||||
<option disabled selected>ИГРА</option>
|
||||
<option>Играть</option>
|
||||
<option>Установить</option>
|
||||
<option>Удалить</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class = "align-middle p-0 cell1_library">
|
||||
<img src="Papers, Please preview.jpg" alt="Papers, Please" class="img-fluid">
|
||||
</td>
|
||||
<td class = "align-middle p-0 cell2_library">
|
||||
<a class = "nav-link library_name_of_game" href="./dark_nights_page.html"> Papers, Please </a>
|
||||
</td>
|
||||
<td class = "align-middle text-center p-0">
|
||||
<select>
|
||||
<option disabled selected>ИГРА</option>
|
||||
<option>Играть</option>
|
||||
<option>Установить</option>
|
||||
<option>Удалить</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class = "align-middle p-0 cell1_library">
|
||||
<img src="Ten Dates preview.jpg" alt="Ten Dates" class="img-fluid">
|
||||
</td>
|
||||
<td class = "align-middle p-0 cell2_library">
|
||||
<a class = "nav-link library_name_of_game" href="./dark_nights_page.html">Ten Dates</a>
|
||||
</td>
|
||||
<td class = "align-middle text-center p-0">
|
||||
<select>
|
||||
<option disabled selected>ИГРА</option>
|
||||
<option>Играть</option>
|
||||
<option>Установить</option>
|
||||
<option>Удалить</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
</main>
|
||||
|
||||
<footer class="footer mt-auto d-flex flex-shrink-0 justify-content-center align-items-center">
|
||||
Сайт Чернышева Георгия, ПИбд-22
|
||||
</footer>
|
||||
</body>
|
||||
|
||||
</html>
|
6046
Lab5 old/package-lock.json
generated
Normal file
39
Lab5 old/package.json
Normal file
@ -0,0 +1,39 @@
|
||||
{
|
||||
"name": "lab5",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "npm-run-all --parallel rest vite",
|
||||
"rest": "json-server data.json",
|
||||
"vite": "vite",
|
||||
"lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
|
||||
"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.2.1",
|
||||
"react-bootstrap": "^2.9.1",
|
||||
"react-bootstrap-icons": "^1.10.3",
|
||||
"@fortawesome/fontawesome-free": "6.2.0",
|
||||
"prop-types": "^15.8.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^18.2.15",
|
||||
"@types/react-dom": "^18.2.7",
|
||||
"@vitejs/plugin-react": "^4.0.3",
|
||||
"eslint": "8.50.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"
|
||||
}
|
||||
}
|
BIN
Lab5 old/placeholder.jpg
Normal file
After Width: | Height: | Size: 10 KiB |
0
Lab5 old/src/App.css
Normal file
25
Lab5 old/src/App.jsx
Normal file
@ -0,0 +1,25 @@
|
||||
import PropTypes from 'prop-types';
|
||||
import { Container } from 'react-bootstrap';
|
||||
import { Outlet } from 'react-router-dom';
|
||||
import './App.css';
|
||||
import Footer from './components/footer/Footer.jsx';
|
||||
import Navigation from './components/navigation/Navigation.jsx';
|
||||
|
||||
// Компонент основной части сайта (панель навигации, контейнер для main, футер)
|
||||
function App({ routes }) {
|
||||
return (
|
||||
<>
|
||||
<Navigation routes={routes}></Navigation>
|
||||
<Container className='p-2' as="main" fluid>
|
||||
<Outlet />
|
||||
</Container>
|
||||
<Footer/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
App.propTypes = {
|
||||
routes: PropTypes.array,
|
||||
};
|
||||
|
||||
export default App;
|
40
Lab5 old/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
Lab5 old/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;
|
13
Lab5 old/src/components/footer/Footer.css
Normal file
@ -0,0 +1,13 @@
|
||||
footer {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
background-color: #385a80;
|
||||
height: 70px !important;
|
||||
max-height: 100px;
|
||||
width: 100%;
|
||||
font-family: sans-serif;
|
||||
color:white;
|
||||
font-size: calc(2vw + 8px) !important;
|
||||
font-weight: 600;
|
||||
}
|
12
Lab5 old/src/components/footer/Footer.jsx
Normal file
@ -0,0 +1,12 @@
|
||||
import './Footer.css';
|
||||
|
||||
// Компонент - подвал
|
||||
function Footer() {
|
||||
return (
|
||||
<footer className="footer mt-auto d-flex flex-shrink-0 justify-content-center align-items-center">
|
||||
Сайт Чернышева Георгия, ПИбд-22{}
|
||||
</footer>
|
||||
);
|
||||
}
|
||||
|
||||
export default Footer;
|
23
Lab5 old/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
Lab5 old/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
Lab5 old/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;
|
4
Lab5 old/src/components/lines/form/LinesItemForm.css
Normal file
@ -0,0 +1,4 @@
|
||||
#image-preview {
|
||||
width: 350px;
|
||||
height: 200px;
|
||||
}
|
35
Lab5 old/src/components/lines/form/LinesItemForm.jsx
Normal file
@ -0,0 +1,35 @@
|
||||
import PropTypes from 'prop-types';
|
||||
import imgPlaceholder from '../../../../placeholder.jpg';
|
||||
import Input from '../../input/Input.jsx';
|
||||
import Select from '../../input/Select.jsx';
|
||||
import useTypes from '../../types/hooks/TypesHook';
|
||||
import './LinesItemForm.css';
|
||||
|
||||
// МБ ТУТ ВМЕСТО item что-то другое
|
||||
const LinesItemForm = ({ item, handleChange }) => {
|
||||
const { types } = useTypes();
|
||||
// ТУТ МЕНЯТЬ
|
||||
return (
|
||||
<>
|
||||
<div className='text-center'>
|
||||
<img id='image-preview' className='rounded' alt='placeholder'
|
||||
src={item.image || imgPlaceholder} />
|
||||
</div>
|
||||
<Select values={types} name='typeId' label='Товары' value={item.typeId} onChange={handleChange}
|
||||
required />
|
||||
<Input name='price' label='Цена' value={item.price} onChange={handleChange}
|
||||
type='number' min='1000.0' step='0.50' required />
|
||||
<Input name='count' label='Количество' value={item.count} onChange={handleChange}
|
||||
type='number' min='1' step='1' required />
|
||||
<Input name='image' label='Изображение' onChange={handleChange}
|
||||
type='file' accept='image/*' />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
LinesItemForm.propTypes = {
|
||||
item: PropTypes.object,
|
||||
handleChange: PropTypes.func,
|
||||
};
|
||||
|
||||
export default LinesItemForm;
|
28
Lab5 old/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;
|
29
Lab5 old/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
Lab5 old/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(price * count).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
Lab5 old/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
Lab5 old/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;
|
77
Lab5 old/src/components/lines/table/Lines.jsx
Normal file
@ -0,0 +1,77 @@
|
||||
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 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);
|
||||
|
||||
const navigate = useNavigate();
|
||||
|
||||
const showEditPage = (id) => {
|
||||
navigate(`/page-edit/${id}`);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<ButtonGroup>
|
||||
<Button variant='info' onClick={() => showFormModal()}>
|
||||
Добавить товар (диалог)
|
||||
</Button>
|
||||
<Button as={Link} to='/page-edit' variant='success'>
|
||||
Добавить товар (страница)
|
||||
</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)}
|
||||
onEditInPage={() => showEditPage(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;
|
30
Lab5 old/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>
|
||||
<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>
|
||||
<th scope='col'></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{children}
|
||||
</tbody >
|
||||
</Table >
|
||||
);
|
||||
};
|
||||
|
||||
LinesTable.propTypes = {
|
||||
children: PropTypes.node,
|
||||
};
|
||||
|
||||
export default LinesTable;
|
34
Lab5 old/src/components/lines/table/LinesTableRow.jsx
Normal file
@ -0,0 +1,34 @@
|
||||
import PropTypes from 'prop-types';
|
||||
import { PencilFill, PencilSquare, Trash3 } from 'react-bootstrap-icons';
|
||||
|
||||
const LinesTableRow = ({
|
||||
index, line, onDelete, onEdit, onEditInPage,
|
||||
}) => {
|
||||
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, 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;
|
30
Lab5 old/src/components/navigation/Navigation.css
Normal file
@ -0,0 +1,30 @@
|
||||
/* .my-navbar {
|
||||
background-color: #3c3c3c !important;
|
||||
}
|
||||
|
||||
.my-navbar .link a:hover {
|
||||
text-decoration: underline !important;
|
||||
}
|
||||
|
||||
.my-navbar .logo {
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
} */
|
||||
|
||||
/* НАДО БУДЕТ ПОМЕНЯТЬ НА НАЗВАНИЕ КЛАССА, НАВЕРНОЕ */
|
||||
.my-navbar {
|
||||
font-family: sans-serif;
|
||||
background-color:#385a80 !important;
|
||||
min-height: 100px;
|
||||
|
||||
}
|
||||
.my-navbar-main-link {
|
||||
font-weight: 600;
|
||||
font-size: calc(18px + 2vw) !important;
|
||||
}
|
||||
.my-navbar-links {
|
||||
font-family: sans-serif;
|
||||
color: white;
|
||||
font-size: calc(12px + 2vw);
|
||||
font-weight: 600;
|
||||
}
|
30
Lab5 old/src/components/navigation/Navigation.jsx
Normal file
@ -0,0 +1,30 @@
|
||||
import PropTypes from 'prop-types';
|
||||
import { Container, Nav, Navbar } from 'react-bootstrap';
|
||||
import { Link } from 'react-router-dom';
|
||||
import './Navigation.css';
|
||||
|
||||
function Navigation() {
|
||||
return (
|
||||
<header>
|
||||
<Navbar bg="dark" expand="md" variant="dark" className = "my-navbar">
|
||||
<Container fluid>
|
||||
<Navbar.Brand as = {Link} to ="/" className = "active my-navbar-main-link" >Главная</Navbar.Brand>
|
||||
<Navbar.Toggle aria-controls="basic-navbar-nav" />
|
||||
<Navbar.Collapse id="basic-navbar-nav">
|
||||
<Nav className="ms-auto">
|
||||
<Nav.Link as = {Link} to = "/basket" className = "my-navbar-links">Корзина</Nav.Link>
|
||||
<Nav.Link as = {Link} to = "/library" className = "my-navbar-links">Библиотека</Nav.Link>
|
||||
<Nav.Link as = {Link} to = "/entry" className = "my-navbar-links">Вход</Nav.Link>
|
||||
</Nav>
|
||||
</Navbar.Collapse>
|
||||
</Container>
|
||||
</Navbar>
|
||||
</header>
|
||||
);
|
||||
}
|
||||
|
||||
Navigation.propTypes = {
|
||||
routes: PropTypes.array,
|
||||
};
|
||||
|
||||
export default Navigation;
|
21
Lab5 old/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
Lab5 old/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
Lab5 old/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;
|
4
Lab5 old/src/index.css
Normal file
@ -0,0 +1,4 @@
|
||||
body {
|
||||
background-color: #2e4150;
|
||||
margin-bottom: 70px;
|
||||
}
|
66
Lab5 old/src/main.jsx
Normal file
@ -0,0 +1,66 @@
|
||||
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 MainPage from './pages/MainPage.jsx';
|
||||
import BasketPage from './pages/BasketPage.jsx';
|
||||
import LibraryPage from './pages/LibraryPage.jsx';
|
||||
import EntryPage from './pages/EntryPage.jsx';
|
||||
import AdminPage from './pages/AdminPage.jsx';
|
||||
import InfoGamePage from './pages/InfoGamePage.jsx';
|
||||
import RegistryPage from './pages/RegistryPage.jsx';
|
||||
|
||||
// МАРШРУТИЗАЦИЯ
|
||||
const routes = [
|
||||
{
|
||||
index: true,
|
||||
path: '/',
|
||||
element: <MainPage />,
|
||||
title: 'Главная страница',
|
||||
},
|
||||
{
|
||||
path: '/basket',
|
||||
element: <BasketPage />,
|
||||
title: 'Корзина',
|
||||
},
|
||||
{
|
||||
path: '/library',
|
||||
element: <LibraryPage />,
|
||||
title: 'Библиотека',
|
||||
},
|
||||
{
|
||||
path: '/entry',
|
||||
element: <EntryPage />,
|
||||
title: 'Вход',
|
||||
},
|
||||
{
|
||||
path: '/registry',
|
||||
element: <RegistryPage />,
|
||||
},
|
||||
{
|
||||
path: '/admin',
|
||||
element: <AdminPage />,
|
||||
},
|
||||
{
|
||||
path: '/info',
|
||||
element: <InfoGamePage />,
|
||||
},
|
||||
];
|
||||
|
||||
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>,
|
||||
);
|
45
Lab5 old/src/pages/AdminPage.css
Normal file
@ -0,0 +1,45 @@
|
||||
@media (min-width: 600px) {
|
||||
.admin_panel {
|
||||
margin-left: 20%;
|
||||
margin-right: 20%;
|
||||
}
|
||||
}
|
||||
@media (max-width: 600px) {
|
||||
.admin_panel {
|
||||
margin-left: 5%;
|
||||
margin-right: 5%;
|
||||
}
|
||||
}
|
||||
|
||||
.span_admin_panel {
|
||||
background-color: #385a80 !important;
|
||||
color: white !important;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
@media (min-width: 600px) {
|
||||
.span_admin_panel {
|
||||
font-size: 1.5vw;
|
||||
}
|
||||
}
|
||||
@media (max-width: 600px) {
|
||||
.span_admin_panel {
|
||||
font-size: 3vw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.btn_admin_panel {
|
||||
border: none;
|
||||
background-color: #385a80 !important;
|
||||
color: white;
|
||||
font-size: calc(1.5vh + 1.5vw) !important;
|
||||
border-radius: 3px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
|
||||
#image-preview {
|
||||
width: 350px;
|
||||
height: 200px;
|
||||
}
|
59
Lab5 old/src/pages/AdminPage.jsx
Normal file
@ -0,0 +1,59 @@
|
||||
import { useState } from 'react';
|
||||
import { Button, Form } from 'react-bootstrap';
|
||||
import './AdminPage.css';
|
||||
|
||||
function AdminPage() {
|
||||
const [validated, setValidated] = useState(false);
|
||||
|
||||
const handleSubmit = (event) => {
|
||||
const form = event.currentTarget;
|
||||
if (form.checkValidity() === false) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
setValidated(true);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className = "text-center">
|
||||
<img id="image-preview" src="placeholder.jpg" alt="placeholder"/>
|
||||
</div>
|
||||
<Form id="games-form" className = "admin_panel mt-4 needs-validation" noValidate validated={validated} onSubmit={handleSubmit}>
|
||||
<Form.Group className = "input-group mb-4">
|
||||
<span className ="input-group-text span_admin_panel" id="basic-addon1">Жанр:</span>
|
||||
<select id="genre" className ="form-select" name="selected" required>
|
||||
<option disabled> Выберите жанр </option>
|
||||
<option>FMV</option>
|
||||
<option>Экшен</option>
|
||||
<option>Квест</option>
|
||||
<option>Стратегия</option>
|
||||
<option>RPG</option>
|
||||
</select>
|
||||
</Form.Group>
|
||||
<Form.Group className = "input-group mb-4">
|
||||
<span className = "input-group-text span_admin_panel" id="basic-addon1">Название:</span>
|
||||
<Form.Control id="name" type="text" className = "form-control" placeholder="Название" required/>
|
||||
</Form.Group>
|
||||
<Form.Group className = "input-group mb-4">
|
||||
<span className = "input-group-text span_admin_panel" id="basic-addon1">Цена:</span>
|
||||
<Form.Control id = "price" type="number" className = "form-control" placeholder="Цена" required/>
|
||||
</Form.Group>
|
||||
<Form.Group className = "input-group mb-4">
|
||||
<span className = "input-group-text span_admin_panel" id="basic-addon1">Фото:</span>
|
||||
<Form.Control id="image" name="image" type="file" className = "form-control" placeholder="Фото" accept="image/*"/>
|
||||
</Form.Group>
|
||||
<Form.Group className = "input-group mb-4">
|
||||
<span className = "input-group-text span_admin_panel">Описание</span>
|
||||
<textarea className ="form-control" aria-label="With textarea"></textarea>
|
||||
</Form.Group>
|
||||
<Form.Group className = "d-flex justify-content-center">
|
||||
<Button className = "btn_admin_panel" type="submit"> Подтвердить </Button>
|
||||
</Form.Group>
|
||||
</Form>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default AdminPage;
|
42
Lab5 old/src/pages/BasketPage.css
Normal file
@ -0,0 +1,42 @@
|
||||
.basket_name_of_game {
|
||||
color: white;
|
||||
font-family: sans-serif;
|
||||
font-size: 3vw;
|
||||
font-size: auto;
|
||||
margin: 0;
|
||||
}
|
||||
.basket_price_of_games{
|
||||
color: white;
|
||||
font-size: 3vw;
|
||||
margin-bottom: auto;
|
||||
font-weight: 600;
|
||||
}
|
||||
.basket_delete_button {
|
||||
font-family: sans-serif;
|
||||
border: none !important;
|
||||
background: none !important;
|
||||
color: white !important;
|
||||
font-size: 3vw !important;
|
||||
}
|
||||
.basket_buy_button {
|
||||
background-color: #385a80;
|
||||
color: white;
|
||||
font-family: sans-serif;
|
||||
font-size: 3vw;
|
||||
border: none;
|
||||
border-radius: 3px;
|
||||
}
|
||||
.cell1_basket {
|
||||
width: 20% !important;
|
||||
}
|
||||
.cell2_basket {
|
||||
width: 50% !important;
|
||||
vertical-align: middle;
|
||||
text-align: center;
|
||||
}
|
||||
.cell3_basket {
|
||||
width: 20% !important;
|
||||
}
|
||||
tfoot {
|
||||
border-color: #2e4150;
|
||||
}
|
55
Lab5 old/src/pages/BasketPage.jsx
Normal file
@ -0,0 +1,55 @@
|
||||
import './BasketPage.css';
|
||||
|
||||
function BasketPage() {
|
||||
return (
|
||||
<>
|
||||
<table className = "table table-bordered align-middle">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td className = "p-0 cell1_basket">
|
||||
<img src="Dark Nights preview.jpg" alt="Dark Nights with Poe & Munro" className = "img-fluid"/>
|
||||
</td>
|
||||
<td className = "p-0 cell2_basket">
|
||||
<p className = "basket_name_of_game">Dark Nights with Poe and Munro</p>
|
||||
</td>
|
||||
<td className = "p-0 text-center align-middle cell3_basket">
|
||||
<p className = "price_of_game_main_page"> 299 руб.</p>
|
||||
</td>
|
||||
<td className = "p-0 text-center align-middle">
|
||||
<button className = "basket_delete_button"> X </button>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td className = "p-0 cell1_basket">
|
||||
<img src="Ten Dates preview.jpg" alt="Ten Dates" className = "img-fluid"/>
|
||||
</td>
|
||||
<td className = "p-0 text-center align-middle cell2_basket">
|
||||
<p className = "basket_name_of_game">Ten Dates</p>
|
||||
</td>
|
||||
<td className = "p-0 text-center align-middle cell3_basket">
|
||||
<p className = "price_of_game_main_page"> 509 руб.</p>
|
||||
</td>
|
||||
<td className = "p-0 text-center align-middle">
|
||||
<button className = "basket_delete_button"> X </button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colSpan="2" className = "align-left">
|
||||
<p className = "basket_price_of_games"> Итого: 808 руб.</p>
|
||||
</td>
|
||||
<td colSpan="2" className = "text-end">
|
||||
<button className = "basket_buy_button">КУПИТЬ</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
</table>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default BasketPage;
|
55
Lab5 old/src/pages/EntryPage.css
Normal file
@ -0,0 +1,55 @@
|
||||
.account_text {
|
||||
font-family: sans-serif;
|
||||
color: white;
|
||||
font-size: calc(2.5vw + 1.5vh);
|
||||
font-weight: 600;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.account_btn {
|
||||
background-color:#385a80;
|
||||
color: white;
|
||||
font-family: sans-serif;
|
||||
font-size: calc(2.5vw + 1.5vh);
|
||||
border: none;
|
||||
border-radius: 3px;
|
||||
font-weight: 500;
|
||||
|
||||
}
|
||||
|
||||
.account_form {
|
||||
position: fixed;
|
||||
/* top: 30%;
|
||||
left: 30%; */
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
.account_input {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.account_col {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.account_ref {
|
||||
color: white;
|
||||
font-size: calc(1.5vw + 1.5vh);
|
||||
text-decoration: none;
|
||||
position: fixed;
|
||||
bottom: 75px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.account_ref_div {
|
||||
/* position: fixed; */
|
||||
text-align: center;
|
||||
/* bottom: 70px; */
|
||||
}
|
105
Lab5 old/src/pages/EntryPage.jsx
Normal file
@ -0,0 +1,105 @@
|
||||
import { Form, Row, Col } from 'react-bootstrap';
|
||||
import { Link } from 'react-router-dom';
|
||||
import './EntryPage.css';
|
||||
|
||||
function EntryPage() {
|
||||
return (
|
||||
<>
|
||||
<Form className = "account_form">
|
||||
|
||||
<Row className='align-items-center justify-content-center'>
|
||||
<Col xs = "auto" className='account_col'>
|
||||
<label className = 'account_text'>Введите ник:</label>
|
||||
</Col>
|
||||
<Col xs = "auto" className='account_col'>
|
||||
<Form.Control type="text"/>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row className='align-items-center justify-content-center'>
|
||||
<Col xs = "auto" className='account_col'>
|
||||
<Form.Label className = 'account_text'>Введите пароль:</Form.Label>
|
||||
</Col>
|
||||
<Col xs = "auto" className='account_col'>
|
||||
<Form.Control
|
||||
type="password"
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row className='justify-content-center'>
|
||||
<Col xs="auto">
|
||||
<button type="submit" className = 'account_btn'>Войти</button>
|
||||
</Col>
|
||||
</Row>
|
||||
</Form>
|
||||
<div className = 'account_ref_div'>
|
||||
<Link className = "account_ref" to = "/registry">СОЗДАТЬ АККАУНТ</Link>
|
||||
</div>
|
||||
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default EntryPage;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// class EntryPage extends React.Component {
|
||||
// constructor(props) {
|
||||
// super(props);
|
||||
// this.state = {
|
||||
// username: '',
|
||||
// password: ''
|
||||
// };
|
||||
// }
|
||||
|
||||
// validateForm() {
|
||||
// return this.state.username.length > 0 && this.state.password.length > 0;
|
||||
// }
|
||||
|
||||
// handleChange = (event) => {
|
||||
// this.setState({
|
||||
// [event.target.id]: event.target.value
|
||||
// });
|
||||
// }
|
||||
|
||||
// handleSubmit = (event) => {
|
||||
// event.preventDefault();
|
||||
// }
|
||||
|
||||
// render() {
|
||||
// return (
|
||||
// <div className="Login">
|
||||
// <Form onSubmit={this.handleSubmit}>
|
||||
// <Form.Group controlId="username">
|
||||
// <Form.Label>Логин</Form.Label>
|
||||
// <Form.Control
|
||||
// autoFocus
|
||||
// type="text"
|
||||
// value={this.state.username}
|
||||
// onChange={this.handleChange}
|
||||
// />
|
||||
// </Form.Group>
|
||||
// <Form.Group controlId="password">
|
||||
// <Form.Label>Пароль</Form.Label>
|
||||
// <Form.Control
|
||||
// value={this.state.password}
|
||||
// onChange={this.handleChange}
|
||||
// type="password"
|
||||
// />
|
||||
// </Form.Group>
|
||||
// <Button
|
||||
// block
|
||||
// disabled={!this.validateForm()}
|
||||
// type="submit"
|
||||
// >
|
||||
// Войти
|
||||
// </Button>
|
||||
// </Form>
|
||||
// </div>
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
|
19
Lab5 old/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;
|
32
Lab5 old/src/pages/InfoGamePage.css
Normal file
@ -0,0 +1,32 @@
|
||||
.info_about_game_pic_and_name {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 40% !important;
|
||||
}
|
||||
|
||||
.info_about_game_name {
|
||||
color: white;
|
||||
font-weight: 700;
|
||||
align-items: center !important;
|
||||
font-size: calc(3vw + 2vh) !important;
|
||||
}
|
||||
|
||||
.info_about_game_text {
|
||||
color: white;
|
||||
align-items: center !important;
|
||||
font-size: calc(2vw + 2vh) !important;
|
||||
}
|
||||
|
||||
.info_about_game_add_to_basket_button {
|
||||
background-color: #385a80;
|
||||
color: white;
|
||||
font-family: sans-serif;
|
||||
font-size: calc(2.5vw + 1.5vh);
|
||||
border: none;
|
||||
border-radius: 3px;
|
||||
}
|
||||
.info_about_game_div_button {
|
||||
border: 1px white;
|
||||
align-items: center !important;
|
||||
|
||||
}
|
28
Lab5 old/src/pages/InfoGamePage.jsx
Normal file
@ -0,0 +1,28 @@
|
||||
import './InfoGamePage.css';
|
||||
|
||||
|
||||
function InfoGamePage() {
|
||||
return (
|
||||
<>
|
||||
<div className = "row info_about_game_pic_and_name">
|
||||
<div className = "col-sm-5">
|
||||
<img src="Dark Nights preview.jpg" alt="Dark Nights with Poe & Munro" className="img-fluid"/>
|
||||
</div>
|
||||
<div className = "col-sm-7 text-center align-items-center">
|
||||
<p className = "info_about_game_name">Dark Nights with Poe and Munro</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className = "row">
|
||||
<div className = "col-sm 12">
|
||||
<p className = "info_about_game_text">Проведите местных радиоведущих По и Манро через шесть похожих на короткометражки эпизодов сверъестественной странности и обжигающего сюжета. От создателей The Infectious Madness of Doctor Dekker и The Shapeshifting Detective.</p>
|
||||
</div>
|
||||
<div className = "info_about_game_div_button text-center align-items-center">
|
||||
<button className = "info_about_game_add_to_basket_button"> Добавить в корзину </button>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default InfoGamePage;
|
33
Lab5 old/src/pages/LibraryPage.css
Normal file
@ -0,0 +1,33 @@
|
||||
.library_name_of_game {
|
||||
color: white;
|
||||
font-size: calc(3vw + 0.5vh);
|
||||
font-weight: 600;
|
||||
margin-left: 0.5vw;
|
||||
}
|
||||
.table_of_library {
|
||||
border-collapse: separate;
|
||||
border-spacing: 0 0.5vw;
|
||||
}
|
||||
.cell1_library {
|
||||
width: 20%;
|
||||
}
|
||||
.cell2_library {
|
||||
width: 60%;
|
||||
}
|
||||
select {
|
||||
background-color: #385a80;
|
||||
color: white;
|
||||
font-weight: bold;
|
||||
font-size: 2.5vw;
|
||||
border: none;
|
||||
border-radius: 2px;
|
||||
text-align: center;
|
||||
}
|
||||
select option {
|
||||
background-color: #385a80;
|
||||
color: white;
|
||||
font-weight: bold;
|
||||
font-size: auto;
|
||||
border-radius: 2px;
|
||||
width: 100%;
|
||||
}
|
82
Lab5 old/src/pages/LibraryPage.jsx
Normal file
@ -0,0 +1,82 @@
|
||||
import './LibraryPage.css';
|
||||
|
||||
function LibraryPage() {
|
||||
return (
|
||||
<table className="table table-borderless table_of_library">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td className = "align-middle p-0 cell1_library">
|
||||
<img src="Dark Nights preview.jpg" alt="Dark Nights with Poe & Munro" className="img-fluid"/>
|
||||
</td>
|
||||
<td className = "align-middle p-0 cell2_library">
|
||||
<a className = "nav-link library_name_of_game" href="./dark_nights_page.html">Dark Nights with Poe and Munro</a>
|
||||
</td>
|
||||
<td className = "align-middle text-center p-0">
|
||||
<select defaultValue="ИГРА">
|
||||
<option disabled >ИГРА</option>
|
||||
<option>Играть</option>
|
||||
<option>Установить</option>
|
||||
<option>Удалить</option>
|
||||
</select>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td className = "align-middle p-0 cell1_library" >
|
||||
<img src="Song of Farca preview.jpg" alt="Song of Farca" className="img-fluid"/>
|
||||
</td>
|
||||
<td className = "align-middle p-0 cell2_library" >
|
||||
<a className = "nav-link library_name_of_game" href="./dark_nights_page.html">Song of Farca</a>
|
||||
</td>
|
||||
<td className = "align-middle text-center p-0">
|
||||
<select defaultValue="ИГРА">
|
||||
<option disabled >ИГРА</option>
|
||||
<option>Играть</option>
|
||||
<option>Установить</option>
|
||||
<option>Удалить</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td className = "align-middle p-0 cell1_library">
|
||||
<img src="Papers, Please preview.jpg" alt="Papers, Please" className="img-fluid"/>
|
||||
</td>
|
||||
<td className = "align-middle p-0 cell2_library">
|
||||
<a className = "nav-link library_name_of_game" href="./dark_nights_page.html"> Papers, Please </a>
|
||||
</td>
|
||||
<td className = "align-middle text-center p-0">
|
||||
<select defaultValue="ИГРА">
|
||||
<option disabled >ИГРА</option>
|
||||
<option>Играть</option>
|
||||
<option>Установить</option>
|
||||
<option>Удалить</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td className = "align-middle p-0 cell1_library">
|
||||
<img src="Ten Dates preview.jpg" alt="Ten Dates" className="img-fluid"/>
|
||||
</td>
|
||||
<td className = "align-middle p-0 cell2_library">
|
||||
<a className = "nav-link library_name_of_game" href="./dark_nights_page.html">Ten Dates</a>
|
||||
</td>
|
||||
<td className = "align-middle text-center p-0">
|
||||
<select defaultValue="ИГРА">
|
||||
<option disabled >ИГРА</option>
|
||||
<option>Играть</option>
|
||||
<option>Установить</option>
|
||||
<option>Удалить</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
);
|
||||
}
|
||||
|
||||
export default LibraryPage;
|
78
Lab5 old/src/pages/MainPage.css
Normal file
@ -0,0 +1,78 @@
|
||||
.button_search {
|
||||
background-color: #385a80 !important;
|
||||
color: white !important;
|
||||
font-weight: bold;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.button_add_game {
|
||||
background-color: #385a80 !important;
|
||||
color: white !important;
|
||||
font-weight: bold !important;
|
||||
border: none !important;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.table_of_main_page {
|
||||
border-collapse: separate;
|
||||
}
|
||||
@media (max-width: 420px) {
|
||||
.table_of_main_page {
|
||||
border-spacing: 0 0;
|
||||
}
|
||||
}
|
||||
@media (min-width: 420px) {
|
||||
.table_of_main_page {
|
||||
border-spacing: 0 0.5vw;
|
||||
}
|
||||
}
|
||||
|
||||
.cell1_main_page {
|
||||
width: 20% !important;
|
||||
}
|
||||
|
||||
.cell2_main_page {
|
||||
width: 55% !important;
|
||||
}
|
||||
|
||||
.name_of_game_main_page {
|
||||
color: white;
|
||||
font-size: 3vw !important;
|
||||
margin-left: 1vw !important;
|
||||
}
|
||||
|
||||
.price_of_game_main_page {
|
||||
color: white;
|
||||
font-size: 2.7vw !important;
|
||||
margin-left: 1vw !important;
|
||||
font-weight: 600 !important;
|
||||
margin-bottom: 0;
|
||||
margin-top: -3px;
|
||||
}
|
||||
|
||||
.genre_of_game_main_page {
|
||||
color: white;
|
||||
font-size: 1.5vw !important;
|
||||
margin-left: 0 !important;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.btn_for_game_main_page {
|
||||
border: none;
|
||||
/* size: 0.5rem; */
|
||||
background-color: #385a80 !important;
|
||||
color: white;
|
||||
font-size: calc(1vh + 0.5vw) !important;
|
||||
margin-right: 0.3rem;
|
||||
border-radius: 3px;
|
||||
}
|
||||
@media (min-width: 600px) {
|
||||
.btn_for_game_main_page {
|
||||
margin-bottom: 10%;
|
||||
}
|
||||
}
|
||||
@media (max-width: 600px) {
|
||||
.btn_for_game_main_page {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
96
Lab5 old/src/pages/MainPage.jsx
Normal file
@ -0,0 +1,96 @@
|
||||
import { FormControl, InputGroup, Button } from 'react-bootstrap';
|
||||
import { Link } from 'react-router-dom';
|
||||
import './MainPage.css';
|
||||
|
||||
function MainPage() {
|
||||
return (
|
||||
<>
|
||||
<InputGroup>
|
||||
<FormControl placeholder = "Название игры" aria-label = "Recipient's username" aria-describedby = "button_search"/>
|
||||
<Button variant = "primary" id = "button_search" className = "button_search"> Поиск </Button>
|
||||
</InputGroup>
|
||||
|
||||
<div className="d-flex flex-row-reverse">
|
||||
<div className = "pt-2">
|
||||
<Button className="pt-2 button_add_game" as={Link} to = "/admin"> + </Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table id="games-table" className="table table-borderless table_of_main_page">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td className = "align-middle p-0 cell1_main_page">
|
||||
<img src = "Dark Nights preview.jpg" alt = "Dark Nights with Poe & Munro" className = "img-fluid w-100 h-100"/>
|
||||
</td>
|
||||
<td className = "align-middle p-0 cell2_main_page">
|
||||
<Link className = "nav-link active name_of_game_main_page" to = "./info">Dark Nights with Poe and Munro</Link>
|
||||
<p className = "price_of_game_main_page"> 299 руб.</p>
|
||||
|
||||
</td>
|
||||
<td className = "align-middle p-0">
|
||||
<p className = "genre_of_game_main_page"> FMV </p>
|
||||
</td>
|
||||
<td className = "text-center align-middle p-0">
|
||||
<Button className = "btn_for_game_main_page" as={Link} to = "/admin"> изменить </Button>
|
||||
<Button className = "btn_for_game_main_page" as={Link} to = "/admin"> удалить </Button>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td className = "align-middle p-0 cell1_main_page" >
|
||||
<img src = "Late Shift preview.jpg" alt = "Late Shift" className = "img-fluid w-100 h-100"/>
|
||||
</td>
|
||||
<td className = "align-middle p-0 cell2_main_page" >
|
||||
<Link className = "nav-link active name_of_game_main_page" to = "./info">Late Shift</Link>
|
||||
<p className = "price_of_game_main_page"> 399 руб.</p>
|
||||
</td>
|
||||
<td className = "align-middle p-0">
|
||||
<p className = "genre_of_game_main_page"> Экшен </p>
|
||||
</td>
|
||||
<td className = "text-center align-middle p-0">
|
||||
<Button className = "btn_for_game_main_page" as={Link} to = "/admin"> изменить </Button>
|
||||
<Button className = "btn_for_game_main_page" as={Link} to = "/admin"> удалить </Button>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td className = "align-middle p-0 cell1_main_page">
|
||||
<img src = "Ten Dates preview.jpg" alt="Ten Dates" className = "img-fluid w-100 h-100"/>
|
||||
</td>
|
||||
<td className = "align-middle p-0 cell2_main_page">
|
||||
<Link className = "nav-link active name_of_game_main_page" to = "./info">Ten Dates</Link>
|
||||
<p className = "price_of_game_main_page"> 590 руб.</p>
|
||||
</td>
|
||||
<td className = "align-middle p-0">
|
||||
<p className = "genre_of_game_main_page"> FMV </p>
|
||||
</td>
|
||||
<td className = "text-center align-middle p-0">
|
||||
<Button className = "btn_for_game_main_page" as={Link} to = "/admin"> изменить </Button>
|
||||
<Button className = "btn_for_game_main_page" as={Link} to = "/admin"> удалить </Button>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td className = "align-middle p-0 cell1_main_page">
|
||||
<img src = "Ten Dates preview.jpg" alt="Ten Dates" className="img-fluid w-100 h-100"/>
|
||||
</td>
|
||||
<td className = "align-middle p-0 cell2_main_page">
|
||||
<Link className = "nav-link active name_of_game_main_page" to = "./info">Ten Dates</Link>
|
||||
<p className = "price_of_game_main_page"> 590 руб.</p>
|
||||
</td>
|
||||
<td className = "align-middle p-0">
|
||||
<p className = "genre_of_game_main_page"> FMV </p>
|
||||
</td>
|
||||
<td className = "text-center align-middle p-0">
|
||||
<Button className = "btn_for_game_main_page" as={Link} to = "/admin"> изменить </Button>
|
||||
<Button className = "btn_for_game_main_page" as={Link} to = "/admin"> удалить </Button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default MainPage;
|
57
Lab5 old/src/pages/RegistryPage.jsx
Normal file
@ -0,0 +1,57 @@
|
||||
import { Form, Row, Col } from 'react-bootstrap';
|
||||
import { Link } from 'react-router-dom';
|
||||
import './EntryPage.css';
|
||||
|
||||
function RegistryPage() {
|
||||
return (
|
||||
<>
|
||||
<Form className = "account_form">
|
||||
<Row className='align-items-center justify-content-center'>
|
||||
<Col xs = "auto" className='account_col'>
|
||||
<label className = 'account_text'>Введите почту:</label>
|
||||
</Col>
|
||||
<Col xs = "auto" className='account_col'>
|
||||
<Form.Control type="text"/>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row className='align-items-center justify-content-center'>
|
||||
<Col xs = "auto" className='account_col'>
|
||||
<Form.Label className = 'account_text'>Введите ник:</Form.Label>
|
||||
</Col>
|
||||
<Col xs = "auto" className='account_col'>
|
||||
<Form.Control
|
||||
type="password"
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row className='align-items-center justify-content-center'>
|
||||
<Col xs = "auto" className='account_col'>
|
||||
<Form.Label className = 'account_text'>Введите пароль:</Form.Label>
|
||||
</Col>
|
||||
<Col xs = "auto" className='account_col'>
|
||||
<Form.Control
|
||||
type="password"
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row className='justify-content-center'>
|
||||
<Col xs="auto">
|
||||
<button type="submit" className = 'account_btn'>Создать</button>
|
||||
</Col>
|
||||
</Row>
|
||||
</Form>
|
||||
<div className='account_ref_div'>
|
||||
<Link className = "account_ref" to = "/entry">ВОЙТИ В АККАУНТ</Link>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default RegistryPage;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
323
Lab5 old/style.css
Normal file
@ -0,0 +1,323 @@
|
||||
html {
|
||||
position: relative;
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: #2e4150;
|
||||
margin-bottom: 70px; /*Равно высоте подвала*/
|
||||
}
|
||||
main {
|
||||
height: 100% !important;
|
||||
}
|
||||
select {
|
||||
background-color: #385a80;
|
||||
color: white;
|
||||
font-weight: bold;
|
||||
font-size: 2.5vw;
|
||||
border: none;
|
||||
border-radius: 2px;
|
||||
text-align: center;
|
||||
}
|
||||
select option {
|
||||
background-color: #385a80;
|
||||
color: white;
|
||||
font-weight: bold;
|
||||
font-size: auto;
|
||||
border-radius: 2px;
|
||||
width: 100%;
|
||||
}
|
||||
nav {
|
||||
font-family: sans-serif;
|
||||
background-color:#385a80 !important;
|
||||
min-height: 100px;
|
||||
}
|
||||
|
||||
footer {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
background-color: #385a80;
|
||||
height: 70px;
|
||||
max-height: 100px;
|
||||
width: 100%;
|
||||
font-family: sans-serif;
|
||||
color:white;
|
||||
font-size: calc(2vw + 8px) !important;
|
||||
font-weight: 600;
|
||||
}
|
||||
.navbar > div > a {
|
||||
font-size: calc(18px + 2vw) !important;
|
||||
}
|
||||
.navbar-nav > a {
|
||||
font-family: sans-serif;
|
||||
color: white;
|
||||
font-size: calc(12px + 2vw);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.container-fluid > a {
|
||||
font-family: sans-serif;
|
||||
color: white;
|
||||
font-size: 32px;
|
||||
font-weight: 600;
|
||||
}
|
||||
/* ГЛАВНАЯ СТРАНИЦА */
|
||||
.btn_for_game_main_page {
|
||||
border: none;
|
||||
/* size: 0.5rem; */
|
||||
background-color: #385a80 !important;
|
||||
color: white;
|
||||
font-size: calc(1vh + 0.5vw) !important;
|
||||
margin-right: 0.3rem;
|
||||
border-radius: 3px;
|
||||
}
|
||||
@media (min-width: 600px) {
|
||||
.btn_for_game_main_page {
|
||||
margin-bottom: 10%;
|
||||
}
|
||||
}
|
||||
@media (max-width: 600px) {
|
||||
.btn_for_game_main_page {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.name_of_game_main_page {
|
||||
color: white;
|
||||
font-size: 3vw !important;
|
||||
margin-left: 1vw !important;
|
||||
}
|
||||
|
||||
.price_of_game_main_page {
|
||||
color: white;
|
||||
font-size: 2.7vw !important;
|
||||
margin-left: 1vw !important;
|
||||
font-weight: 600 !important;
|
||||
margin-bottom: 0;
|
||||
margin-top: -3px;
|
||||
}
|
||||
|
||||
/* .img-fluid {
|
||||
max-height: 100%;
|
||||
} */
|
||||
.genre_of_game_main_page {
|
||||
color: white;
|
||||
font-size: 1.5vw !important;
|
||||
margin-left: 0 !important;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.table_of_main_page {
|
||||
border-collapse: separate;
|
||||
}
|
||||
@media (max-width: 420px) {
|
||||
.table_of_main_page {
|
||||
border-spacing: 0 0;
|
||||
}
|
||||
}
|
||||
@media (min-width: 420px) {
|
||||
.table_of_main_page {
|
||||
border-spacing: 0 0.5vw;
|
||||
}
|
||||
}
|
||||
.cell1_main_page {
|
||||
width: 20% !important;
|
||||
}
|
||||
.cell2_main_page {
|
||||
width: 55% !important;
|
||||
}
|
||||
|
||||
main > .container-fluid {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.btn_searching {
|
||||
background-color: #385a80 !important;
|
||||
color: white !important;
|
||||
font-weight: bold;
|
||||
}
|
||||
.searching_input {
|
||||
size: 2vw !important;
|
||||
}
|
||||
|
||||
.btn_adding_game {
|
||||
background-color: #385a80 !important;
|
||||
color: white !important;
|
||||
font-weight: bold !important;
|
||||
border: none !important;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
/* СТРАНИЦА С ОПИСАНИЕМ ИГРЫ */
|
||||
|
||||
.info_about_game_pic_and_name {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 40% !important;
|
||||
}
|
||||
|
||||
.info_about_game_name {
|
||||
color: white;
|
||||
font-weight: 700;
|
||||
align-items: center !important;
|
||||
font-size: calc(3vw + 2vh) !important;
|
||||
}
|
||||
|
||||
.info_about_game_text {
|
||||
color: white;
|
||||
align-items: center !important;
|
||||
font-size: calc(2vw + 2vh) !important;
|
||||
}
|
||||
|
||||
.info_about_game_add_to_basket_button {
|
||||
background-color: #385a80;
|
||||
color: white;
|
||||
font-family: sans-serif;
|
||||
font-size: calc(2.5vw + 1.5vh);
|
||||
border: none;
|
||||
border-radius: 3px;
|
||||
}
|
||||
.info_about_game_div_button {
|
||||
border: 1px white;
|
||||
align-items: center !important;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* СТРАНИЦЫ АККАУНТА */
|
||||
.account_text {
|
||||
font-family: sans-serif;
|
||||
color: white;
|
||||
font-size: calc(2.5vw + 1.5vh);
|
||||
font-weight: 600;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.account_btn {
|
||||
background-color:#385a80;
|
||||
color: white;
|
||||
font-family: sans-serif;
|
||||
font-size: calc(2.5vw + 1.5vh);
|
||||
border: none;
|
||||
border-radius: 3px;
|
||||
font-weight: 500;
|
||||
|
||||
}
|
||||
.mt-25vh {
|
||||
margin-top: 25vh;
|
||||
}
|
||||
.mt-20vh {
|
||||
margin-top: 20vh;
|
||||
}
|
||||
|
||||
/* БИБЛИОТЕКА */
|
||||
.library_name_of_game {
|
||||
color: white;
|
||||
font-size: calc(3vw + 0.5vh);
|
||||
font-weight: 600;
|
||||
margin-left: 0.5vw;
|
||||
}
|
||||
.table_of_library {
|
||||
border-collapse: separate;
|
||||
border-spacing: 0 0.5vw;
|
||||
}
|
||||
.cell1_library {
|
||||
width: 20%;
|
||||
}
|
||||
.cell2_library {
|
||||
width: 60%;
|
||||
}
|
||||
|
||||
|
||||
/* КОРЗИНА */
|
||||
.basket_name_of_game {
|
||||
color: white;
|
||||
font-family: sans-serif;
|
||||
font-size: 3vw;
|
||||
font-size: auto;
|
||||
margin: 0;
|
||||
}
|
||||
.basket_price_of_games{
|
||||
color: white;
|
||||
font-size: 3vw;
|
||||
margin-bottom: auto;
|
||||
font-weight: 600;
|
||||
}
|
||||
.basket_delete_button {
|
||||
font-family: sans-serif;
|
||||
border: none !important;
|
||||
background: none !important;
|
||||
color: white !important;
|
||||
font-size: 3vw !important;
|
||||
}
|
||||
.basket_buy_button {
|
||||
background-color: #385a80;
|
||||
color: white;
|
||||
font-family: sans-serif;
|
||||
font-size: 3vw;
|
||||
border: none;
|
||||
border-radius: 3px;
|
||||
}
|
||||
.cell1_basket {
|
||||
width: 20% !important;
|
||||
}
|
||||
.cell2_basket {
|
||||
width: 50% !important;
|
||||
vertical-align: middle;
|
||||
text-align: center;
|
||||
}
|
||||
.cell3_basket {
|
||||
width: 20% !important;
|
||||
}
|
||||
tfoot {
|
||||
border-color: #2e4150;
|
||||
}
|
||||
|
||||
/* СТРАНИЦА АДМИНА */
|
||||
@media (min-width: 600px) {
|
||||
.admin_panel {
|
||||
margin-left: 20%;
|
||||
margin-right: 20%;
|
||||
}
|
||||
}
|
||||
@media (max-width: 600px) {
|
||||
.admin_panel {
|
||||
margin-left: 5%;
|
||||
margin-right: 5%;
|
||||
}
|
||||
}
|
||||
|
||||
.span_admin_panel {
|
||||
background-color: #385a80 !important;
|
||||
color: white !important;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
@media (min-width: 600px) {
|
||||
.span_admin_panel {
|
||||
font-size: 1.5vw;
|
||||
}
|
||||
}
|
||||
@media (max-width: 600px) {
|
||||
.span_admin_panel {
|
||||
font-size: 3vw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.btn_admin_panel {
|
||||
border: none;
|
||||
background-color: #385a80 !important;
|
||||
color: white;
|
||||
font-size: calc(1.5vh + 1.5vw) !important;
|
||||
border-radius: 3px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
|
||||
#image-preview {
|
||||
width: 350px;
|
||||
height: 200px;
|
||||
}
|
13
Lab5 old/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,
|
||||
},
|
||||
});
|
28
Lab5/.eslintrc.cjs
Normal file
@ -0,0 +1,28 @@
|
||||
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',
|
||||
'no-trailing-spaces' : 'off',
|
||||
'max-len' : 'off',
|
||||
'no-multiple-empty-lines' : 'off',
|
||||
},
|
||||
}
|
24
Lab5/.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?
|
44
Lab5/README.md
Normal file
@ -0,0 +1,44 @@
|
||||
### Окружение:
|
||||
- [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. Global Object - https://developer.mozilla.org/en-US/docs/Glossary/Global_object
|
||||
2. Global Scope - https://developer.mozilla.org/en-US/docs/Glossary/Global_scope
|
||||
3. localStorage - https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage
|
||||
4. JavaScript Execution Context – How JS Works Behind The Scenes - https://www.freecodecamp.org/news/execution-context-how-javascript-works-behind-the-scenes/
|
||||
5. Extracting State Logic into a Reducer - https://react.dev/learn/extracting-state-logic-into-a-reducer
|
||||
6. Passing Data Deeply with Context - https://react.dev/learn/passing-data-deeply-with-context
|
||||
7. Scaling Up with Reducer and Context - https://react.dev/learn/scaling-up-with-reducer-and-context
|
138
Lab5/data.json
Normal file
15
Lab5/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>Steam</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="root" class="d-flex flex-column"></div>
|
||||
<script type="module" src="/src/main.jsx"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
15
Lab5/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
Lab5/json-server.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"static": "./node_modules/json-server/public",
|
||||
"port": 8081,
|
||||
"watch": "true"
|
||||
}
|
5936
Lab5/package-lock.json
generated
Normal file
38
Lab5/package.json
Normal file
@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "lab5",
|
||||
"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
Lab5/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 |
29
Lab5/src/App.jsx
Normal file
@ -0,0 +1,29 @@
|
||||
import PropTypes from 'prop-types';
|
||||
import { Container } from 'react-bootstrap';
|
||||
import { Toaster } from 'react-hot-toast';
|
||||
import { Outlet } from 'react-router-dom';
|
||||
import { CartProvider } from './components/cart/CartContext.jsx';
|
||||
import Footer from './components/footer/Footer.jsx';
|
||||
import Navigation from './components/navigation/Navigation.jsx';
|
||||
import { UserProvider } from './components/users/UserContext.jsx';
|
||||
|
||||
const App = ({ routes }) => {
|
||||
return (
|
||||
<UserProvider>
|
||||
<CartProvider>
|
||||
<Navigation routes={routes}></Navigation>
|
||||
<Container className='p-2' as='main' fluid>
|
||||
<Outlet />
|
||||
</Container>
|
||||
<Footer />
|
||||
<Toaster position='top-center' reverseOrder={true} />
|
||||
</CartProvider>
|
||||
</UserProvider>
|
||||
);
|
||||
};
|
||||
|
||||
App.propTypes = {
|
||||
routes: PropTypes.array,
|
||||
};
|
||||
|
||||
export default App;
|
BIN
Lab5/src/assets/200.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
Lab5/src/assets/Dark Nights preview.jpg
Normal file
After Width: | Height: | Size: 63 KiB |
BIN
Lab5/src/assets/Late Shift preview.jpg
Normal file
After Width: | Height: | Size: 91 KiB |
BIN
Lab5/src/assets/Papers, Please preview.jpg
Normal file
After Width: | Height: | Size: 30 KiB |
BIN
Lab5/src/assets/Song of Farca preview.jpg
Normal file
After Width: | Height: | Size: 72 KiB |
BIN
Lab5/src/assets/Ten Dates preview.jpg
Normal file
After Width: | Height: | Size: 82 KiB |
BIN
Lab5/src/assets/logo.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
Lab5/src/assets/placeholder.jpg
Normal file
After Width: | Height: | Size: 10 KiB |
40
Lab5/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);
|
33
Lab5/src/components/api/ApiService.js
Normal file
@ -0,0 +1,33 @@
|
||||
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 getByHandle(name) {
|
||||
return ApiClient.get(`${this.url}?name=${name}`);
|
||||
}
|
||||
|
||||
async delete(id) {
|
||||
return ApiClient.delete(`${this.url}/${id}`);
|
||||
}
|
||||
}
|
||||
|
||||
export default ApiService;
|
60
Lab5/src/components/cart/Cart.css
Normal file
@ -0,0 +1,60 @@
|
||||
.cart-image {
|
||||
width: 5.5rem;
|
||||
padding: 0rem !important;
|
||||
}
|
||||
|
||||
.cart-item {
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.cart-text{
|
||||
color: White;
|
||||
font-size: 32px;
|
||||
}
|
||||
|
||||
Table {
|
||||
--bs-table-bg: #2e4150 !important;
|
||||
}
|
||||
|
||||
.cart_name_of_game {
|
||||
color: white;
|
||||
font-family: sans-serif;
|
||||
font-size: 3vw;
|
||||
font-size: auto;
|
||||
margin: 0;
|
||||
}
|
||||
.cart_price_of_games{
|
||||
color: white;
|
||||
font-size: 3vw;
|
||||
margin-bottom: auto;
|
||||
font-weight: 600;
|
||||
}
|
||||
.cart_delete_button {
|
||||
font-family: sans-serif;
|
||||
border: none !important;
|
||||
background: none !important;
|
||||
color: white !important;
|
||||
font-size: 3vw !important;
|
||||
}
|
||||
.cart_buy_button {
|
||||
background-color: #385a80;
|
||||
color: white;
|
||||
font-family: sans-serif;
|
||||
font-size: 3vw;
|
||||
border: none;
|
||||
border-radius: 3px;
|
||||
}
|
||||
.cell1_cart {
|
||||
width: 20% !important;
|
||||
}
|
||||
.cell2_cart {
|
||||
width: 50% !important;
|
||||
vertical-align: middle;
|
||||
text-align: center;
|
||||
}
|
||||
.cell3_cart {
|
||||
width: 20% !important;
|
||||
}
|
||||
tfoot {
|
||||
border-color: #2e4150 !important;
|
||||
}
|
57
Lab5/src/components/cart/Cart.jsx
Normal file
@ -0,0 +1,57 @@
|
||||
import { Button, Table } from 'react-bootstrap';
|
||||
import { XLg } from 'react-bootstrap-icons';
|
||||
import placeholder from '../../assets/placeholder.jpg';
|
||||
import './Cart.css';
|
||||
import useCart from './CartHook';
|
||||
|
||||
const Cart = () => {
|
||||
const {
|
||||
cart,
|
||||
getCartSum,
|
||||
removeFromCart,
|
||||
clearCart,
|
||||
} = useCart();
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className='d-flex flex-row-reverse mb-2'>
|
||||
<Button variant='danger' onClick={() => clearCart()}>
|
||||
<XLg /> Очистить
|
||||
</Button>
|
||||
</div>
|
||||
<Table className = 'table table-bordered align-middle m-0'>
|
||||
<tbody>
|
||||
{
|
||||
cart.map((cartItem) =>
|
||||
<tr key={cartItem.id}>
|
||||
<td className = 'p-0 cell1_cart'>
|
||||
<img className = 'img-fluid' src={cartItem.image || placeholder} alt="Превью игры" />
|
||||
</td>
|
||||
<td className = "p-0 cell2_cart">
|
||||
<p className = "cart_name_of_game"> {cartItem.title} </p>
|
||||
</td>
|
||||
<td className = "p-0 text-center align-middle cell3_basket">
|
||||
<p className = "price_of_game_main_page"> {cartItem.price} ₽ </p>
|
||||
</td>
|
||||
<td className = "p-0 text-center align-middle">
|
||||
<Button className = "cart_delete_button" onClick={() => removeFromCart(cartItem)}> X </Button>
|
||||
</td>
|
||||
</tr>)
|
||||
}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colSpan='2' className = 'align-left'>
|
||||
<p className = 'cart_price_of_games'> ИТОГО: {getCartSum()} ₽ </p>
|
||||
</td>
|
||||
<td colSpan='2' className = 'text-end'>
|
||||
<button className = 'cart_buy_button' onClick={() => clearCart()}>КУПИТЬ</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</Table>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Cart;
|
29
Lab5/src/components/cart/CartContext.jsx
Normal file
@ -0,0 +1,29 @@
|
||||
import PropTypes from 'prop-types';
|
||||
import {
|
||||
createContext,
|
||||
useEffect,
|
||||
useReducer,
|
||||
} from 'react';
|
||||
import { cartReducer, loadCart, saveCart } from './CartReducer';
|
||||
|
||||
const CartContext = createContext(null);
|
||||
|
||||
export const CartProvider = ({ children }) => {
|
||||
const [cart, dispatch] = useReducer(cartReducer, [], loadCart);
|
||||
|
||||
useEffect(() => {
|
||||
saveCart(cart || []);
|
||||
}, [cart]);
|
||||
|
||||
return (
|
||||
<CartContext.Provider value={{ cart, dispatch }}>
|
||||
{children}
|
||||
</CartContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
CartProvider.propTypes = {
|
||||
children: PropTypes.node,
|
||||
};
|
||||
|
||||
export default CartContext;
|
26
Lab5/src/components/cart/CartHook.js
Normal file
@ -0,0 +1,26 @@
|
||||
import { useContext } from 'react';
|
||||
import CartContext from './CartContext.jsx';
|
||||
import { cartAdd, cartClear, cartRemove } from './CartReducer';
|
||||
|
||||
const useCart = () => {
|
||||
const { cart, dispatch } = useContext(CartContext);
|
||||
|
||||
const cartSum = () => {
|
||||
return parseFloat(
|
||||
cart?.reduce((sum, cartItem) => {
|
||||
return sum + parseInt(cartItem.price, 10);
|
||||
}, 0)
|
||||
?? 0,
|
||||
).toFixed(0);
|
||||
};
|
||||
|
||||
return {
|
||||
cart,
|
||||
getCartSum: () => cartSum(),
|
||||
addToCart: (item) => dispatch(cartAdd(item)),
|
||||
removeFromCart: (item) => dispatch(cartRemove(item)),
|
||||
clearCart: () => dispatch(cartClear()),
|
||||
};
|
||||
};
|
||||
|
||||
export default useCart;
|
71
Lab5/src/components/cart/CartReducer.js
Normal file
@ -0,0 +1,71 @@
|
||||
const setCartCount = (cart, item) => {
|
||||
return cart.map((cartItem) => {
|
||||
if (cartItem.id === item.id) {
|
||||
return { ...cartItem, count: cartItem.count };
|
||||
}
|
||||
return cartItem;
|
||||
});
|
||||
};
|
||||
|
||||
const addToCart = (cart, item) => {
|
||||
const existsItem = cart.find((cartItem) => cartItem.id === item.id);
|
||||
if (existsItem !== undefined) {
|
||||
return setCartCount(cart, item, 1);
|
||||
}
|
||||
return [...cart, { ...item, count: 1 }];
|
||||
};
|
||||
|
||||
const removeFromCart = (cart, item) => {
|
||||
const existsItem = cart.find((cartItem) => cartItem.id === item.id);
|
||||
if (existsItem !== undefined && existsItem.count > 1) {
|
||||
return setCartCount(cart, item, -1);
|
||||
}
|
||||
return cart.filter((cartItem) => cartItem.id !== item.id);
|
||||
};
|
||||
|
||||
const CART_KEY = 'localCart';
|
||||
const CART_ADD = 'cart/add';
|
||||
const CART_REMOVE = 'cart/remove';
|
||||
const CART_CLEAR = 'cart/clear';
|
||||
|
||||
export const saveCart = (cart) => {
|
||||
localStorage.setItem(CART_KEY, JSON.stringify(cart));
|
||||
};
|
||||
|
||||
export const loadCart = (initialValue = []) => {
|
||||
const cartData = localStorage.getItem(CART_KEY);
|
||||
if (cartData) {
|
||||
return JSON.parse(cartData);
|
||||
}
|
||||
return initialValue;
|
||||
};
|
||||
|
||||
export const cartReducer = (cart, action) => {
|
||||
const { item } = action;
|
||||
switch (action.type) {
|
||||
case CART_ADD: {
|
||||
return addToCart(cart, item);
|
||||
}
|
||||
case CART_REMOVE: {
|
||||
return removeFromCart(cart, item);
|
||||
}
|
||||
case CART_CLEAR: {
|
||||
return [];
|
||||
}
|
||||
default: {
|
||||
throw Error(`Unknown action: ${action.type}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const cartAdd = (item) => ({
|
||||
type: CART_ADD, item,
|
||||
});
|
||||
|
||||
export const cartRemove = (item) => ({
|
||||
type: CART_REMOVE, item,
|
||||
});
|
||||
|
||||
export const cartClear = () => ({
|
||||
type: CART_CLEAR,
|
||||
});
|
13
Lab5/src/components/footer/Footer.css
Normal file
@ -0,0 +1,13 @@
|
||||
footer {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
background-color: #385a80;
|
||||
height: 70px !important;
|
||||
max-height: 100px;
|
||||
width: 100%;
|
||||
font-family: sans-serif;
|
||||
color:white;
|
||||
font-size: calc(2vw + 8px) !important;
|
||||
font-weight: 600;
|
||||
}
|
11
Lab5/src/components/footer/Footer.jsx
Normal file
@ -0,0 +1,11 @@
|
||||
import './Footer.css';
|
||||
|
||||
const Footer = () => {
|
||||
return (
|
||||
<footer className="footer mt-auto d-flex flex-shrink-0 justify-content-center align-items-center">
|
||||
Сайт Чернышева Георгия, ПИбд-22{}
|
||||
</footer>
|
||||
);
|
||||
};
|
||||
|
||||
export default Footer;
|
41
Lab5/src/components/input/Input.css
Normal file
@ -0,0 +1,41 @@
|
||||
#image-preview {
|
||||
width: 350px !important;
|
||||
height: 200px !important;
|
||||
}
|
||||
|
||||
@media (min-width: 600px) {
|
||||
.admin_panel {
|
||||
margin-left: 20%;
|
||||
margin-right: 20%;
|
||||
}
|
||||
}
|
||||
@media (max-width: 600px) {
|
||||
.admin_panel {
|
||||
margin-left: 5%;
|
||||
margin-right: 5%;
|
||||
}
|
||||
}
|
||||
|
||||
.span_admin_panel {
|
||||
background-color: #385a80 !important;
|
||||
color: white !important;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
@media (min-width: 600px) {
|
||||
.span_admin_panel {
|
||||
font-size: 1.5vw;
|
||||
}
|
||||
}
|
||||
@media (max-width: 600px) {
|
||||
.span_admin_panel {
|
||||
font-size: 3vw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.my_select {
|
||||
border-bottom: none !important;
|
||||
text-decoration: none !important;
|
||||
font-size: large !important;
|
||||
}
|
24
Lab5/src/components/input/Input.jsx
Normal file
@ -0,0 +1,24 @@
|
||||
import PropTypes from 'prop-types';
|
||||
import { Form } from 'react-bootstrap';
|
||||
import './Input.css';
|
||||
// поля ввода со входа в аккаунт и страницы редактирования
|
||||
const Input = ({
|
||||
name, label, value, onChange, className, ...rest
|
||||
}) => {
|
||||
return (
|
||||
<Form.Group className={`input-group mb-4 ${className || ''}`} controlId={name}>
|
||||
<span className = "input-group-text span_admin_panel"> {label} </span>
|
||||
<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;
|
32
Lab5/src/components/input/Select.jsx
Normal file
@ -0,0 +1,32 @@
|
||||
import PropTypes from 'prop-types';
|
||||
import { Form } from 'react-bootstrap';
|
||||
import './Input.css';
|
||||
|
||||
const Select = ({
|
||||
needSpan, values, name, label, value, onChange, className, ...rest
|
||||
}) => {
|
||||
return (
|
||||
<Form.Group className = {`input-group mt-2 mb-3 ${className || ''}`} controlId={name}>
|
||||
{/* Проверка, что span нужна */}
|
||||
{needSpan && <span className ="input-group-text span_admin_panel"> Жанр: </span>}
|
||||
<Form.Select className='my_select' name={name || ''} value={value || ''} onChange={onChange} {...rest}>
|
||||
<option value=''> {label} </option>
|
||||
{
|
||||
values.map((type) => <option key={type.id} value={type.id}>{type.name}</option>)
|
||||
}
|
||||
</Form.Select>
|
||||
</Form.Group>
|
||||
);
|
||||
};
|
||||
|
||||
Select.propTypes = {
|
||||
needSpan: PropTypes.bool,
|
||||
values: PropTypes.array,
|
||||
name: PropTypes.string,
|
||||
label: PropTypes.string,
|
||||
value: PropTypes.string,
|
||||
onChange: PropTypes.func,
|
||||
className: PropTypes.string,
|
||||
};
|
||||
|
||||
export default Select;
|
49
Lab5/src/components/lines/form/LinesForm.jsx
Normal file
@ -0,0 +1,49 @@
|
||||
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();
|
||||
// использование хука, получение инфы для формы на page-edit для игры с переданным id
|
||||
const {
|
||||
item,
|
||||
validated,
|
||||
handleSubmit,
|
||||
handleChange,
|
||||
} = useLinesItemForm(id);
|
||||
// возврат на страницу назад
|
||||
const onBack = () => {
|
||||
navigate(-1);
|
||||
};
|
||||
// Возвращение на страницу назад после успешного сохранения формы
|
||||
const onSubmit = async (event) => {
|
||||
if (await handleSubmit(event)) {
|
||||
onBack();
|
||||
}
|
||||
};
|
||||
// Сама форма с данными о игре (LinesItemForm) и одинаковыми для всех кнопками
|
||||
return (
|
||||
<>
|
||||
<Form className='m-0 p-2 mb-5' 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 mb-3' variant='secondary' onClick={() => onBack()}>
|
||||
Назад
|
||||
</Button>
|
||||
<Button className='col-5 col-lg-2 m-0 ms-2 mb-3' type='submit' variant='primary'>
|
||||
Сохранить
|
||||
</Button>
|
||||
</Form.Group>
|
||||
</Form>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
LinesForm.propTypes = {
|
||||
id: PropTypes.string,
|
||||
};
|
||||
|
||||
export default LinesForm;
|
44
Lab5/src/components/lines/form/LinesItemForm.css
Normal file
@ -0,0 +1,44 @@
|
||||
#image-preview {
|
||||
width: 350px !important;
|
||||
height: 200px !important;
|
||||
}
|
||||
|
||||
@media (min-width: 600px) {
|
||||
.admin_panel {
|
||||
margin-left: 20%;
|
||||
margin-right: 20%;
|
||||
}
|
||||
}
|
||||
@media (max-width: 600px) {
|
||||
.admin_panel {
|
||||
margin-left: 5%;
|
||||
margin-right: 5%;
|
||||
}
|
||||
}
|
||||
|
||||
.span_admin_panel {
|
||||
background-color: #385a80 !important;
|
||||
color: white !important;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
@media (min-width: 600px) {
|
||||
.span_admin_panel {
|
||||
font-size: 1.5vw;
|
||||
}
|
||||
}
|
||||
@media (max-width: 600px) {
|
||||
.span_admin_panel {
|
||||
font-size: 3vw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.btn_admin_panel {
|
||||
border: none;
|
||||
background-color: #385a80 !important;
|
||||
color: white;
|
||||
font-size: calc(1.5vh + 1.5vw) !important;
|
||||
border-radius: 3px;
|
||||
font-weight: 700;
|
||||
}
|
40
Lab5/src/components/lines/form/LinesItemForm.jsx
Normal file
@ -0,0 +1,40 @@
|
||||
import PropTypes from 'prop-types';
|
||||
// import { Form } from 'react-bootstrap';
|
||||
import Input from '../../input/Input.jsx';
|
||||
import Select from '../../input/Select.jsx';
|
||||
import useTypes from '../../types/hooks/TypesHook';
|
||||
import imgPlaceholder from '../../../assets/placeholder.jpg';
|
||||
|
||||
import './LinesItemForm.css';
|
||||
// СТРАНИЦА ИЗМЕНЕНИЯ ИГРЫ
|
||||
const LinesItemForm = ({ item, handleChange }) => {
|
||||
const { types } = useTypes();
|
||||
return (
|
||||
<>
|
||||
<div className='text-center'>
|
||||
<img id='image-preview' alt='placeholder'
|
||||
src={item.image || imgPlaceholder} />
|
||||
</div>
|
||||
<Select values={types} name='typeId' label='Выберите жанр' value={item.typeId} onChange={handleChange} needSpan={true} required />
|
||||
|
||||
{/* Название игры */}
|
||||
<Input name='title' label='Название:' value={item.title} onChange={handleChange} type='text' required />
|
||||
|
||||
{/* Цена игры */}
|
||||
<Input name='price' label='Цена:' value={item.price} onChange={handleChange} type='number' min='1' step='1' required />
|
||||
|
||||
{/* Описание игры */}
|
||||
<Input name='description' label='Описание' value={item.description} onChange={handleChange} type='text' as = 'textarea' required />
|
||||
|
||||
{/* Файл с фото игры */}
|
||||
<Input name='image' label='Изображение' onChange={handleChange} type='file' accept='image/*' />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
LinesItemForm.propTypes = {
|
||||
item: PropTypes.object,
|
||||
handleChange: PropTypes.func,
|
||||
};
|
||||
|
||||
export default LinesItemForm;
|
14
Lab5/src/components/lines/hooks/IsAdminHook.js
Normal file
@ -0,0 +1,14 @@
|
||||
const checkIsAdmin = () => {
|
||||
// Результат получения данных о пользователе
|
||||
const storedUserData = localStorage.getItem('user');
|
||||
// Преобразованные данные
|
||||
const storedUser = storedUserData ? JSON.parse(storedUserData) : {};
|
||||
const userName = storedUser && storedUser.name ? storedUser.name : '';
|
||||
const isAdmin = userName.toLowerCase() === 'admin';
|
||||
|
||||
return {
|
||||
isAdmin,
|
||||
};
|
||||
};
|
||||
|
||||
export default checkIsAdmin;
|
34
Lab5/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
Lab5/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;
|
29
Lab5/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
Lab5/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 title = String(formData.title, 30);
|
||||
const price = parseFloat(formData.price).toFixed(0);
|
||||
const description = String(formData.description, 30);
|
||||
const image = formData.image.startsWith('data:image') ? formData.image : '';
|
||||
return {
|
||||
typeId: typeId.toString(),
|
||||
title: title.toString(),
|
||||
price: price.toString(),
|
||||
description: description.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;
|