From b3f016eca34661041d20130dbd888c24e6998180 Mon Sep 17 00:00:00 2001
From: Programmist73
Date: Tue, 16 May 2023 00:40:16 +0400
Subject: [PATCH] =?UTF-8?q?=D0=92=D0=BD=D0=BE=D0=B2=D1=8C=20=D0=BD=D0=B5?=
=?UTF-8?q?=D0=B1=D0=BE=D0=BB=D1=8C=D1=88=D0=BE=D0=B5=20=D0=BF=D1=80=D0=BE?=
=?UTF-8?q?=D0=B4=D0=B2=D0=B8=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
front/premium_store/src/App.js | 6 +-
.../src/components/AddClient.jsx | 72 +++++++++----------
.../src/components/AddNation.jsx | 39 ++++++----
.../components/items/DTO/user-singup-dto.js | 1 +
.../items/GameClient/ClientItem.jsx | 27 +++++--
.../items/GameClient/ModalClient.jsx | 16 ++++-
.../src/components/items/Pages/LoginPage.jsx | 2 +-
.../components/items/Pages/PrivateRoutes.jsx | 4 +-
.../src/components/items/Pages/SingupPage.jsx | 8 +++
.../controller/DTO/ClientDTO.java | 2 +-
.../controller/GameClientController.java | 25 +------
.../controller/NationController.java | 2 +-
12 files changed, 110 insertions(+), 94 deletions(-)
diff --git a/front/premium_store/src/App.js b/front/premium_store/src/App.js
index be39239..70d6f66 100644
--- a/front/premium_store/src/App.js
+++ b/front/premium_store/src/App.js
@@ -22,7 +22,7 @@ function App() {
{ path: 'levels', element: , label: 'Обзор уровней', userGroup: "AUTH" },
{ path: 'nations', element: , label: 'Обзор наций', userGroup: "AUTH" },
{ path: 'tanks', element: , label: 'Обзор танков', userGroup: "AUTH"},
- { path: 'clients', element: , label: 'Обзор клиентов', userGroup: "AUTH"},
+ { path: 'clients', element: , label: 'Обзор клиентов', userGroup: "ADMIN"},
{ path: 'checkPage', element: , label: 'Фильтр по танкам', userGroup: "AUTH"}
];
@@ -42,13 +42,11 @@ function App() {
} path="/singup" />
}>
} path="/tanks" />
+ } path="/levels" />
} path="/checkPage" />
} path="/nations" exact />
} path="*" />
- }>
- } path="/levels" />
-
}>
} path="/clients" />
diff --git a/front/premium_store/src/components/AddClient.jsx b/front/premium_store/src/components/AddClient.jsx
index cc706e2..545fcc4 100644
--- a/front/premium_store/src/components/AddClient.jsx
+++ b/front/premium_store/src/components/AddClient.jsx
@@ -4,6 +4,9 @@ import '../styles/App.css';
import ClientList from './items/GameClient/ClientList';
import './AddClient.css';
+const hostURL = "http://localhost:8080";
+const host = hostURL + "/api/1.0";
+
export default function AddClient() {
const [clientItems, setClientItems] = useState([]);
@@ -14,45 +17,41 @@ export default function AddClient() {
const [clientBalance, setClientBalance] = useState();
+ const [pageNumbers, setPageNumbers] = useState([]);
+
+ const [pageNumber, setPageNumber] = useState();
- //загрузка всех имеющихся уровней при старте
useEffect(() => {
- console.log('Обращение к БД');
- axios.get('http://localhost:8080/api/1.0/client/')
- .then((responce) => {
- console.log(responce.data);
- setClientItems(responce.data)
- })
- }, [])
+ getUsers(1);
+ }, []);
+
+ const pageButtonOnClick = function (page) {
+ getUsers(page);
+ }
+
+ const getTokenForHeader = function () {
+ return "Bearer " + localStorage.getItem("token");
+ }
+
+ //загрузка всех имеющихся клиентов при старте
+ const getUsers = async function (page) {
+ const requestParams = {
+ method: "GET",
+ headers: {
+ "Authorization": getTokenForHeader(),
+ }
+ };
+ const requestUrl = host + `/users?page=${page}`;
+ const response = await fetch(requestUrl, requestParams);
+ const data = await response.json();
+ setClientItems(data.first.content);
+ setPageNumber(data.first.number);
+ setPageNumbers(data.second);
+ }
//обновить список уровней
function CheckArray(){
- console.log('Обращение к БД');
- axios.get('http://localhost:8080/api/1.0/client/')
- .then((responce) => {
- console.log(responce.data);
- setClientItems(responce.data)
- })
- }
-
- //добавление нового уровня
- function addNewClient(){
- console.log(clientNickName);
- console.log(clientEmail);
- console.log(clientBalance);
-
- if(clientNickName === ''){
- return;
- }
- else {
- axios.post('http://localhost:8080/api/1.0/client/?nickName=' + clientNickName + '&email=' + clientEmail + '&balance=' + clientBalance)
- .then((response) => {
- CheckArray();
- setClientNickName('');
- setClientEmail('');
- setClientBalance('');
- });
- }
+ getUsers(1);
}
//добавили условную отрисовку
@@ -87,11 +86,6 @@ export default function AddClient() {
-