Skip to content

Commit

Permalink
Merge pull request #11 from moevm/koroleva/serverCommunication
Browse files Browse the repository at this point in the history
Correct requests to server
  • Loading branch information
polinaKoroleva05 authored Nov 8, 2024
2 parents 65741c1 + 806a846 commit a383fc2
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 8 deletions.
2 changes: 1 addition & 1 deletion client/src/pages/manyEntity/AllCellsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function AllCellsPage() {
});
}
useEffect(() => {
axios.post(GET_ALL_CELLS_URL, filters).then(response => { setCells(response.data) }).catch(error => {
axios.get(GET_ALL_CELLS_URL, {params: filters}).then(response => { setCells(response.data) }).catch(error => {
console.error('Ошибка при получении ячеек. Взяты дефолтные ячейки', error);
setCells(cellsInit);
});
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/manyEntity/AllEventsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function AllEventsPage() {
const [filters, setFilters] = useState({});

useEffect(() => {
axios.post(GET_ALL_EVENTS_URL, filters).then(response => { setEvent(response.data) }).catch(error => {
axios.get(GET_ALL_EVENTS_URL, {params: filters}).then(response => { setEvent(response.data) }).catch(error => {
console.error('Ошибка при получении событий. Взяты дефолтные события', error);
setEvent(eventsInit);
});
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/manyEntity/AllUsersPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function AllUsersPage() {
const [filters, setFilters] = useState({});

useEffect(() => {
axios.post(GET_ALL_USERS_URL, filters).then(response => { setUsers(response.data) }).catch(error => {
axios.get(GET_ALL_USERS_URL, {params: filters}).then(response => { setUsers(response.data) }).catch(error => {
console.error('Ошибка при получении пользователей. Взяты дефолтные пользователи', error);
setUsers(usersInit);
});
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/manyEntity/AllWarehousesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function AllWarehousesPage() {
const [filters, setFilters] = useState({});

useEffect(() => {
axios.post(GET_ALL_WAREHOUSES_URL, filters).then(response => { setWarehouses(response.data) }).catch(error => {
axios.get(GET_ALL_WAREHOUSES_URL, {params: filters}).then(response => { setWarehouses(response.data) }).catch(error => {
console.error('Ошибка при получении складов. Взяты дефолтные склады', error);
setWarehouses(warehousesInit);
});
Expand Down
12 changes: 10 additions & 2 deletions client/src/pages/manyEntity/MyCellsPage.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import { useState } from "react";
import { useEffect, useState } from "react";
import CellsTable from "../../components/CellsTable";
import { cellsInit } from "../../serviceFiles/constants";
import { cellsInit, GET_MY_CELLS_URL } from "../../serviceFiles/constants";
import axios from "axios";

export default function MyCellsPage() {
const [cells, setCells] = useState(cellsInit);
const [filters, setFilters] = useState({});
useEffect(() => {
axios.get(GET_MY_CELLS_URL, {params: filters}).then(response => { setCells(response.data) }).catch(error => {
console.error('Ошибка при получении ячеек пользователя. Взяты дефолтные ячейки', error);
setCells(cellsInit);
});
})
return (<>
<CellsTable isForRent={false} isForAdmin={false} cells={cells} ></CellsTable>
</>)
Expand Down
12 changes: 10 additions & 2 deletions client/src/pages/manyEntity/RentCellPage.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import { useState } from "react";
import { useEffect, useState } from "react";
import CellsTable from "../../components/CellsTable";
import { cellsInit } from "../../serviceFiles/constants";
import { cellsInit, GET_FREE_CELLS_URL } from "../../serviceFiles/constants";
import axios from "axios";

export default function RentCellPage(){
const [cells, setCells] = useState(cellsInit);
const [filters, setFilters] = useState({});
useEffect(() => {
axios.get(GET_FREE_CELLS_URL, {params: filters}).then(response => { setCells(response.data) }).catch(error => {
console.error('Ошибка при получении свободных ячеек. Взяты дефолтные ячейки', error);
setCells(cellsInit);
});
})
return (<>
<CellsTable isForRent={true} isForAdmin={false} cells={cells} ></CellsTable>
</>)
Expand Down
2 changes: 2 additions & 0 deletions client/src/serviceFiles/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ export let warehousesInit = [
]
export const SIGN_IN_URL = ""
export const GET_ALL_CELLS_URL = ""
export const GET_MY_CELLS_URL = ""
export const GET_FREE_CELLS_URL = ""
export const POST_NEW_CELL_URL = ""
export const GET_ALL_EVENTS_URL = ""
export const POST_NEW_EVENT_URL = ""
Expand Down

0 comments on commit a383fc2

Please sign in to comment.