Skip to content

Commit

Permalink
Merge pull request #7 from moevm/koroleva/auth
Browse files Browse the repository at this point in the history
Auth page
  • Loading branch information
polinaKoroleva05 authored Nov 6, 2024
2 parents fab7462 + b78a06e commit be0371e
Show file tree
Hide file tree
Showing 17 changed files with 1,412 additions and 616 deletions.
1,619 changes: 1,205 additions & 414 deletions client/package-lock.json

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0",
"@mui/material": "^6.1.5",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"@toolpad/core": "^0.8.1",
"@types/jest": "^27.5.2",
"@types/node": "^16.18.114",
"@types/react": "^18.3.11",
"@types/react-dom": "^18.3.1",
"chart.js": "^4.4.6",
"mobx-react": "^9.1.1",
"react": "^18.3.1",
"react-chartjs-2": "^5.2.0",
"bootstrap": "^5.3.3",
"react-bootstrap": "^2.10.5",
"react-dom": "^18.3.1",
"react-router-dom": "^6.27.0",
"react-scripts": "5.0.1",
Expand Down
22 changes: 12 additions & 10 deletions client/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import React from 'react';
import logo from './logo.svg';
import './App.css';
import ShowDialog from './components/showDialog';
import PersonalAccount from './pages/PersonalAccountPage';
import { BrowserRouter, Routes, Route, Link } from "react-router-dom";
import MyCellsPage from './pages/MyCellsPage';
import RentCellPage from './pages/RentCellPage';
import MyCellsPage from './pages/manyEntity/MyCellsPage';
import RentCellPage from './pages/manyEntity/RentCellPage';
import HelpPage from './pages/HelpPage';
import AllCellsPage from './pages/AllCellsPage';
import AllUsersPage from './pages/AllUsersPage';
import UserPage from './pages/UserPage';
import AllEventsPage from './pages/AllEventsPage';
import EventPage from './pages/EventPage';
import AllCellsPage from './pages/manyEntity/AllCellsPage';
import AllUsersPage from './pages/manyEntity/AllUsersPage';
import UserPage from './pages/oneEntity/UserPage';
import AllEventsPage from './pages/manyEntity/AllEventsPage';
import EventPage from './pages/oneEntity/EventPage';
import PaymentPage from './pages/PaymentPage';
import AuthPage from './pages/AuthPage';

function App() {
return (
Expand All @@ -21,18 +22,19 @@ function App() {
<Link to="/allUsers">Страница пользователей</Link>
</header>
<Routes>
<Route path="/" element={<AuthPage />}></Route>
<Route path="/personalAccount" element={<PersonalAccount />}></Route>
<Route path="/myCells" element={<MyCellsPage />}></Route>
<Route path="/bookCell" element={<RentCellPage />}></Route>
<Route path="/rentCell" element={<RentCellPage />}></Route>
<Route path="/help" element={<HelpPage />}></Route>
<Route path="/allCells" element={<AllCellsPage />}></Route>
<Route path="/allUsers" element={<AllUsersPage />}></Route>
<Route path="/user" element={<UserPage />}></Route>
<Route path="/allEvents" element={<AllEventsPage />}></Route>
<Route path="/event" element={<EventPage />}></Route>
<Route path="/paymentCell" element={<PaymentPage />}></Route>
</Routes>
</BrowserRouter>

);
}

Expand Down
72 changes: 37 additions & 35 deletions client/src/components/CellsTable.tsx
Original file line number Diff line number Diff line change
@@ -1,64 +1,66 @@
import { Button, Table, TableBody, TableCell, TableHead, TableRow } from "@mui/material"
import { useNavigate } from "react-router-dom"
import Payment from "./Payment";
import Payment from "../pages/PaymentPage";
import { useState } from "react";
import { Cell } from "../serviceFiles/types";
import Table from "react-bootstrap/Table";
import { Button } from "react-bootstrap";

export default function CellsTable(props: { isForRent: boolean, isForAdmin: boolean, cells: Cell[] }) {

let navigate = useNavigate();
const [showPayment, setShowPayment] = useState(false);
const [cellForRent, setCellForRent] = useState(props.cells[0]);
// let cellForRent: Cell|null = null;
function handleRent(cell: Cell) {
setCellForRent(cell);
console.log(cellForRent);
setShowPayment(!showPayment);
console.log("again", cellForRent);
navigate("/paymentCell", {state: cell})
// setCellForRent(cell);
// console.log(cellForRent);
// setShowPayment(!showPayment);
// console.log("again", cellForRent);
}
function CloseRent() {
setShowPayment(!showPayment);
}

const listCells = props.cells.map((cell: Cell, index) =>
<TableRow key={cell.cellId}>
<TableCell>
<tr key={cell.cellId}>
<td>
{cell.cellId}
</TableCell>
<TableCell>
</td>
<td>
{cell.isFree ? "Свободна" : "Занята"}
</TableCell>
<TableCell>
</td>
<td>
{cell.endOfRent}
</TableCell>
<TableCell>
</td>
<td>
{cell.warehouse}
</TableCell>
{props.isForRent && <TableCell> <Button variant="contained" onClick={() => handleRent(cell)}> Арендовать </Button></TableCell>}
{props.isForAdmin && <TableCell> {cell.needService ? "Требует" : "Не требует"}</TableCell>}
{props.isForAdmin && <TableCell> <Button variant="contained" > Обслужить </Button> </TableCell>}
</TableRow>
</td>
{props.isForRent && <td> <Button type="button" className="btn" onClick={() => handleRent(cell)}> Арендовать </Button></td>}
{props.isForAdmin && <td> {cell.needService ? "Требует" : "Не требует"}</td>}
{props.isForAdmin && <td> <Button type="button" className="btn" > Обслужить </Button> </td>}
</tr>
)
return (<>
{showPayment && <Payment cell={cellForRent} handleClick={CloseRent} isOpen={showPayment} />}
<Table>
<TableHead>
<TableCell>
{/* {showPayment && <Payment cell={cellForRent} handleClick={CloseRent} isOpen={showPayment} />} */}
<Table striped bordered hover>
<thead>
<th scope="col">
Номер
</TableCell>
<TableCell>
</th>
<th scope="col">
Статус
</TableCell>
<TableCell>
</th>
<th scope="col">
Дата окончания аренды
</TableCell>
<TableCell>
</th>
<th scope="col">
Склад
</TableCell>
{props.isForAdmin && <TableCell> Тех.обслуживание </TableCell>}
</TableHead>
<TableBody>
</th>
{props.isForAdmin && <th scope="col"> Тех.обслуживание </th>}
</thead>
<tbody>
{listCells}
</TableBody>
</tbody>
</Table>
</>)
}
29 changes: 0 additions & 29 deletions client/src/components/Payment.tsx

This file was deleted.

20 changes: 0 additions & 20 deletions client/src/components/showDialog.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion client/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';

import 'bootstrap/dist/css/bootstrap.min.css'
const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement
);
Expand Down
24 changes: 24 additions & 0 deletions client/src/pages/AuthPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Button, Form } from "react-bootstrap"

export default function AuthPage() {
return (<div>
<h2>Вход</h2>
<Form>
<Form.Group className="mb-3" controlId="formBasicEmail">
<Form.Label>Логин</Form.Label>
<Form.Control type="email" placeholder="Логин" />
</Form.Group>

<Form.Group className="mb-3" controlId="formBasicPassword">
<Form.Label>Пароль</Form.Label>
<Form.Control type="password" placeholder="Пароль" />
</Form.Group>
<Form.Group className="mb-3" controlId="formBasicCheckbox">
<Form.Check type="checkbox" label="Запомнить меня" />
</Form.Group>
<Button variant="primary" type="submit">
Вход
</Button>
</Form>
</div>)
}
24 changes: 24 additions & 0 deletions client/src/pages/PaymentPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { useState } from "react";
import { Cell } from "../serviceFiles/types";
import { useLocation, useNavigate } from "react-router-dom";
import { Button } from "react-bootstrap";

export default function PaymentPage() {
const {state} = useLocation();
let navigate = useNavigate();
function handleClick(){
navigate("/rentCell")
}
return (<>
{console.log("in payment", state)}
<h2>Оплата аренды ячейки</h2>
<div>
<p>Ячейка номер {state.cellId}</p>
<p>Размер {state.size}</p>
<Button> Оплата по карте </Button>
<Button> Оплата по СБП </Button>
<Button onClick={handleClick}>Отмена</Button>

</div>
</>)
}
33 changes: 16 additions & 17 deletions client/src/pages/PersonalAccountPage.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
import React, { useEffect, useRef, useState } from 'react'
import { BrowserRouter, Routes, Route, Link } from "react-router-dom";
import MyCellsPage from './MyCellsPage';
import BookCellPage from './RentCellPage';
import MyCellsPage from './manyEntity/MyCellsPage';
import BookCellPage from './manyEntity/RentCellPage';
import HelpPage from './HelpPage';
import { List, ListItemButton } from '@mui/material';
import ListItem from '@mui/material';


export default function PersonalAccount() {
return (<div>
PersonalPage
<nav>
<ListItemButton>
<ul className="list-group">
<li className="list-group-item">
{/* сам линк сделать элементом списка, а не вложенным */}
<Link to="/myCells">Мои ячейки</Link>
</ListItemButton>
<ListItemButton>
<Link to="/bookCell">Арендовать ячейку</Link>
</ListItemButton>
<ListItemButton>
</li>
<li className="list-group-item">
<Link to="/rentCell">Арендовать ячейку</Link>
</li>
<li className="list-group-item">
<Link to="/help">Поддержка</Link>
</ListItemButton>
<ListItemButton>
</li>
<li className="list-group-item">
<Link to="/allCells">Все ячейки</Link>
</ListItemButton>
<ListItemButton>
</li>
<li className="list-group-item">
<Link to="/allEvents">Все события</Link>
</ListItemButton>
</nav>
</li>
</ul>
</div>)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState } from "react";
import CellsTable from "../components/CellsTable";
import { cellsInit } from "../serviceFiles/constants";
import CellsTable from "../../components/CellsTable";
import { cellsInit } from "../../serviceFiles/constants";

export default function AllCellsPage() {
const [cells, setCells] = useState(cellsInit);
Expand Down
Loading

0 comments on commit be0371e

Please sign in to comment.