added backend and 2 endpoints fetch

This commit is contained in:
wt committed 2025-07-30 00:01:45 +07:00
1 parent 7c6db3dfbd
commit ca99cfcf6d
56 files changed
+344 -29

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
import "./css/App.css";
import NavigationBar from "./components/NavigationBar/NavigationBar";
import { useTheme } from "./contexts/ThemeContext";
import { useEffect } from "react";
import Home from "./pages/Home";
import {
BrowserRouter as Router,
Routes,
Route,
Navigate,
} from "react-router-dom";
import NotFound from "./pages/NotFound";
function App() {
const { theme } = useTheme();
useEffect(() => {
document.body.setAttribute("data-bs-theme", theme);
}, [theme]);
return (
<Router>
<NavigationBar />
<>
<Routes>
<Route path="/" element={<Home />} />
<Route path="/not-found" element={<NotFound />} />
<Route path="*" element={<Navigate to="/not-found" replace />} />
</Routes>
</>
</Router>
);
}
export default App;
+8
View File
@@ -0,0 +1,8 @@
import { render, screen } from '@testing-library/react';
import App from './App';
test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});
+14
View File
@@ -0,0 +1,14 @@
import axios from "axios";
import routes from "../routes";
const fetchCategories = async () => {
try {
const response = await axios.get(routes.categories);
return response.data;
} catch (error) {
console.error("Error fetching categories:", error);
return [];
}
};
export default fetchCategories;
@@ -0,0 +1,167 @@
import { Card, Accordion, ProgressBar } from "react-bootstrap";
const AppointmentDashboard = ({ ...props }) => {
return (
<>
<Card {...props}>
<Card.Body>
<h3
className="mb-3 fw-bolder"
style={{ fontSize: "1.1rem", fontWeight: 700 }}
>
Appointment
</h3>
<Accordion defaultActiveKey="">
<Accordion.Item eventKey="0" className="p-0">
<Accordion.Header className="p-0">
<div className="p-0" style={{ fontSize: "30px" }}>
<div>&#128512;</div>
</div>
<div className="d-flex flex-column p-0 justify-content-start align-items-start w-100">
<div className="d-flex justify-content-between w-100">
<h3 className="mb-0" style={{ fontSize: "1.1rem" }}>
Cash loan
</h3>
<h3
className="mb-0 fw-bolder"
style={{ fontSize: "1.1rem", fontWeight: 700 }}
>
21531,00 ₽
</h3>
</div>
<div className="d-flex w-100 align-items-end gap-2">
<ProgressBar
now={75}
className="mt-2 w-100"
style={{ height: "5px" }}
/>
<div
className="d-flex text-muted small mb-0"
style={{ fontSize: "0.8rem" }}
>
75%
</div>
</div>
</div>
</Accordion.Header>
<Accordion.Body>
<div className="d-flex align-items-center">
<div
className="p-2 justify-content-start align-items-start d-flex flex-column"
style={{ fontSize: "30px" }}
>
<div>&#10142;</div>
</div>
<div className="d-flex flex-column p-0 justify-content-start align-items-start w-100">
<div className="d-flex justify-content-between w-100">
<h3 className="mb-0" style={{ fontSize: "0.8rem" }}>
Cash loan
</h3>
<h3
className="mb-0 fw-bolder"
style={{ fontSize: "0.8rem", fontWeight: 700 }}
>
21531,00 ₽
</h3>
</div>
<div className="d-flex w-100 align-items-end gap-2">
<ProgressBar
now={100}
className="mt-2 w-100"
style={{ height: "5px" }}
/>
<div
className="d-flex text-muted small mb-0"
style={{ fontSize: "0.8rem" }}
>
100%
</div>
</div>
</div>
</div>
<hr />
<div className="d-flex align-items-center">
<div
className="p-2 justify-content-start align-items-start d-flex flex-column"
style={{ fontSize: "30px" }}
>
<div>&#10142;</div>
</div>
<div className="d-flex flex-column p-0 justify-content-start align-items-start w-100">
<div className="d-flex justify-content-between w-100">
<h3 className="mb-0" style={{ fontSize: "0.8rem" }}>
Cash loan
</h3>
<h3
className="mb-0 fw-bolder"
style={{ fontSize: "0.8rem", fontWeight: 700 }}
>
21531,00 ₽
</h3>
</div>
<div className="d-flex w-100 align-items-end gap-2">
<ProgressBar
now={100}
className="mt-2 w-100"
style={{ height: "5px" }}
/>
<div
className="d-flex text-muted small mb-0"
style={{ fontSize: "0.8rem" }}
>
100%
</div>
</div>
</div>
</div>
<hr />
</Accordion.Body>
</Accordion.Item>
</Accordion>
{/* <div>
<div className="d-flex flex-row gap-3 p-2">
<div
className="p-2 justify-content-start align-items-start d-flex flex-column"
style={{ fontSize: "30px" }}
>
<div>&#128512;</div>
</div>
<div className="d-flex flex-column p-0 justify-content-start align-items-start w-100">
<h3
className="mb-0 fw-bolder"
style={{ fontSize: "1.1rem", fontWeight: 700 }}
>
-63.00 ₽
</h3>
<div
className="text-muted small mb-1"
style={{ fontSize: "0.8rem" }}
>
Transport
</div>
<div
className="text-muted small mb-1"
style={{ fontSize: "0.8rem" }}
>
Note
</div>
</div>
<div
className="p-0 m-0"
style={{ width: "100%", height: "100%" }}
>
<div
className="text-muted small mb-1 text-end"
style={{ fontSize: "0.8rem" }}
>
09:14
</div>
</div>
</div>
</div> */}
</Card.Body>
</Card>
</>
);
};
export default AppointmentDashboard;
@@ -0,0 +1,26 @@
import React from "react";
import { Card } from "react-bootstrap";
import AddOperationModal from "../../modals/AddOperationModal/AddOperationModal";
const BalanceBlock = ({ balance }) => {
return (
<Card style={{ position: "fixed", bottom: 0, width: "100%" }}>
<Card.Body className="d-flex justify-content-between">
<div>
<div className="text-muted small mb-1" style={{ fontSize: "0.8rem" }}>
Balance
</div>
<h3
className="mb-0 fw-bolder"
style={{ fontSize: "1.1rem", fontWeight: 700 }}
>
40 407,17 ₽
</h3>
</div>
<AddOperationModal />
</Card.Body>
</Card>
);
};
export default BalanceBlock;
@@ -0,0 +1,69 @@
import { useTheme } from "../../contexts/ThemeContext";
import { Button } from "react-bootstrap";
import styles from "./CategorySign.module.css";
import classNames from "classnames";
const CategorySign = ({ icon, title, subcategories }) => {
const { theme } = useTheme();
return (
<Button variant={theme} className="w-100 mt-3">
<div>
<div className="d-flex flex-row gap-3 p-2">
<div
className="p-2 justify-content-start align-items-start d-flex flex-column"
style={{ fontSize: "30px" }}
>
<div>{icon}</div>
</div>
<div className="d-flex flex-column p-0 justify-content-center align-items-start w-100">
<h3
className="mb-0 fw-bolder"
style={{ fontSize: "1.1rem", fontWeight: 700 }}
>
{title}
</h3>
<div
className="text-muted small mb-1"
style={{ fontSize: "0.8rem" }}
>
{subcategories.length === 0
? "No subcategories"
: `Subcategories: ${subcategories.length}`}
</div>
</div>
</div>
{subcategories.length === 0 ? (
""
) : (
<div
className="d-flex align-items-center gap-3 p-0"
style={{ margin: "0 20px" }}
>
<div
className="p-2 justify-content-start align-items-start d-flex flex-column"
// style={{ fontSize: "30px" }}
>
<div>&#10142;</div>
</div>
<div
className={classNames("d-flex gap-3", styles.hideScrollbar)}
style={{ width: "100%", overflowX: "auto" }}
>
{subcategories.map((subcategory) => (
<Button
variant="secondary"
style={{ borderRadius: "25px", padding: "0 15px" }}
key={subcategory.id}
>
{subcategory.title}
</Button>
))}
</div>
</div>
)}
</div>
</Button>
);
};
export default CategorySign;
@@ -0,0 +1,7 @@
.hideScrollbar {
scrollbar-width: none;
-ms-overflow-style: none;
}
.hideScrollbar::-webkit-scrollbar {
display: none;
}
@@ -0,0 +1,58 @@
import React, { useState, useRef } from "react";
import { Button, Overlay, Popover, InputGroup } from "react-bootstrap";
import EmojiPicker from "emoji-picker-react";
import { useTheme } from "../../contexts/ThemeContext";
const EmojiPickerButton = () => {
const { theme } = useTheme();
const [showPicker, setShowPicker] = useState(false);
const [inputValue, setInputValue] = useState("😀");
const target = useRef(null);
const handleEmojiSelect = (emoji) => {
setInputValue(emoji.emoji);
setShowPicker(false);
};
return (
<div className="p-3">
<InputGroup>
<Button
ref={target}
variant="secondary"
style={{
borderRadius: "50%",
width: "100px",
height: "100px",
fontSize: "45px",
}}
onClick={() => setShowPicker(!showPicker)}
>
{inputValue}
</Button>
<Overlay
show={showPicker}
target={target.current}
placement="bottom"
rootClose
onHide={() => setShowPicker(false)}
>
<Popover id="emoji-popover">
<Popover.Body className="p-0">
<EmojiPicker
onEmojiClick={handleEmojiSelect}
height={350}
width="100%"
previewConfig={{ showPreview: false }}
theme={theme}
/>
</Popover.Body>
</Popover>
</Overlay>
</InputGroup>
</div>
);
};
export default EmojiPickerButton;
@@ -0,0 +1,121 @@
import React from "react";
import { Card, Col } from "react-bootstrap";
import { Bar } from "react-chartjs-2";
import {
Chart as ChartJS,
CategoryScale,
LinearScale,
BarElement,
Tooltip,
} from "chart.js";
// import { useTheme } from "../../contexts/ThemeContext";
import styles from "./FinancialDashboard.module.css";
ChartJS.register(CategoryScale, LinearScale, BarElement, Tooltip);
const FinancialDashboard = ({
chartData,
chartOptions,
maxValue,
LeftCardData,
RightCardData,
}) => {
// const { theme } = useTheme();
// const [incomedata, setIncomeData] = useState(income);
// const [expensesdata, setExpensesData] = useState(expenses);
return (
<div
className="d-flex flex-column p-3 gap-3"
style={{
margin: "0 auto",
fontFamily: "Inter, sans-serif",
}}
>
{/* Карточка с диаграммой */}
<Card className="border-0 shadow-sm" style={{ borderRadius: "15px" }}>
<Card.Body className="p-4">
<div className="d-flex justify-content-between align-items-center mb-0">
<Col md={6} className="mb-0">
<Card className="border-0">
<Card.Body className="p-0">
<div className="d-flex align-items-center p-0 m-0">
<div
style={{
width: "10px",
height: "10px",
backgroundColor: "#3576C3",
borderRadius: "50%",
display: "inline-block",
marginRight: "10px",
}}
/>
<div className="p-0 m-0">
<h3
className="mb-0 fw-bold"
style={{ fontSize: "1.1rem", fontWeight: 700 }}
>
{LeftCardData.value.toLocaleString("ru-RU", {
minimumFractionDigits: 2,
})}{" "}
₽
</h3>
</div>
</div>
<div
className="text-muted small mb-1"
style={{ fontSize: "0.8rem" }}
>
{LeftCardData.label}
</div>
</Card.Body>
</Card>
</Col>
<Col md={6} className="mb-0">
<Card className="border-0">
<Card.Body className="p-0">
<div className="d-flex align-items-center">
<div
style={{
width: "10px",
height: "10px",
backgroundColor: "#38393F",
borderRadius: "50%",
display: "inline-block",
marginRight: "10px",
}}
/>
<div className="p-0">
<h3
className="mb-0 fw-bold"
style={{ fontSize: "1.1rem", fontWeight: 700 }}
>
{RightCardData.value.toLocaleString("ru-RU", {
minimumFractionDigits: 2,
})}{" "}
₽
</h3>
</div>
</div>
<div
className="text-muted small mb-1"
style={{ fontSize: "0.8rem" }}
>
{RightCardData.label}
</div>
</Card.Body>
</Card>
</Col>
</div>
{/* Контейнер для диаграммы */}
<div className={styles.chartContainer}>
<Bar data={chartData} options={chartOptions} />
</div>
</Card.Body>
</Card>
</div>
);
};
export default FinancialDashboard;
@@ -0,0 +1,13 @@
.chartContainer {
margin: 0;
height: 200px;
width: auto;
position: relative;
margin-bottom: 0;
}
@media (max-width: 768px) {
.chartContainer {
height: 100px;
}
}
@@ -0,0 +1,18 @@
import React from "react";
import Navbar from "react-bootstrap/Navbar";
import SettingsModal from "../../modals/SettingsModal/SettingsModal";
const NavigationBar = () => {
return (
<div
expand="lg"
className="d-flex align-items-center justify-content-between"
style={{ padding: "1rem 1rem 0 1rem" }}
>
<Navbar.Brand href="/">Wallet</Navbar.Brand>
<SettingsModal />
</div>
);
};
export default NavigationBar;
Whitespace-only changes.
@@ -0,0 +1,60 @@
import getDateString from "../../logic/getDateString";
import { Button } from "react-bootstrap";
import classNames from "classnames";
import styles from "./OperationSign.module.css";
const OperationSign = ({ operation }) => {
return (
<div className="gap-2">
<div className="d-flex flex-row gap-3 p-2">
<div
className="p-2 justify-content-start align-items-start d-flex flex-column"
style={{ fontSize: "30px" }}
>
<div>&#128512;</div>
</div>
<div className="d-flex flex-column p-0 justify-content-start align-items-start w-100">
<h3
className="mb-0 fw-bolder"
style={
operation.type === "income"
? { fontSize: "1.1rem", fontWeight: 700, color: "#2DBB4D" }
: { fontSize: "1.1rem", fontWeight: 700 }
}
>
{operation.type === "income" ? "" : "-"}
{operation.amount} ₽
</h3>
<div className="text-muted small mb-1" style={{ fontSize: "0.8rem" }}>
{operation.category}
</div>
{!operation.subcategory ? (
""
) : (
<div
className="text-muted small mb-1"
style={{ fontSize: "0.8rem" }}
>
{operation.subcategory.title}
</div>
)}
<div className="text-muted small mb-1" style={{ fontSize: "0.8rem" }}>
{operation.note && operation.note !== ""
? operation.note
: "No note"}
</div>
</div>
<div className="p-0 m-0" style={{ width: "100%", height: "100%" }}>
<div
className="text-muted small mb-1 text-end"
style={{ fontSize: "0.8rem" }}
>
{getDateString(operation.date)}
</div>
</div>
</div>
</div>
);
};
export default OperationSign;
@@ -0,0 +1,7 @@
.hideScrollbar {
scrollbar-width: none;
-ms-overflow-style: none;
}
.hideScrollbar::-webkit-scrollbar {
display: none;
}
+25
View File
@@ -0,0 +1,25 @@
import React from "react";
import { Form, Row, Col } from "react-bootstrap";
import { useTheme } from "../contexts/ThemeContext";
const ThemeToggle = () => {
const { theme, toggleTheme } = useTheme();
return (
<>
<Form.Group as={Row}>
<Form.Label column>Dark Mode</Form.Label>
<Col className="d-flex align-items-center justify-content-end">
<Form.Check
type="switch"
id="dark-mode-switch"
checked={theme === "dark"}
onChange={toggleTheme}
/>
</Col>
</Form.Group>
</>
);
};
export default ThemeToggle;
+35
View File
@@ -0,0 +1,35 @@
import React, { createContext, useState, useEffect, useContext } from "react";
const ThemeContext = createContext();
export const ThemeProvider = ({ children }) => {
const [theme, setTheme] = useState(() => {
if (typeof window !== "undefined") {
const savedTheme = localStorage.getItem("theme");
const systemPreferDark = window.matchMedia(
"(prefers-color-scheme: dark)",
).matches;
return savedTheme || (systemPreferDark ? "dark" : "light");
}
return "light";
});
useEffect(() => {
if (typeof window !== "undefined") {
document.body.setAttribute("data-bs-theme", theme);
localStorage.setItem("theme", theme);
}
}, [theme]);
const toggleTheme = () => {
setTheme((prev) => (prev === "light" ? "dark" : "light"));
};
return (
<ThemeContext.Provider value={{ theme, toggleTheme }}>
{children}
</ThemeContext.Provider>
);
};
export const useTheme = () => useContext(ThemeContext);
+36
View File
@@ -0,0 +1,36 @@
/* src/App.css */
body[data-bs-theme="dark"] {
background-color: #121212;
color: #f8f9fa;
.modal-content {
background-color: #121212 !important;
}
.nav-link.active {
background-color: #121212 !important;
}
}
body[data-bs-theme="light"] {
background-color: #f8f9fa;
color: #212529;
}
.progress {
border-radius: 20px;
}
.progress-bar {
border-radius: 20px;
}
.accordion-button {
padding: 10px !important;
}
.accordion-body {
padding: 0 10px !important;
}
hr {
margin: 0 !important;
}
+19
View File
@@ -0,0 +1,19 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family:
-apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
code {
font-family:
source-code-pro, Menlo, Monaco, Consolas, "Courier New", monospace;
}
+28
View File
@@ -0,0 +1,28 @@
import React from "react";
import ReactDOM from "react-dom/client";
import "./css/index.css";
import App from "./App";
import reportWebVitals from "./reportWebVitals";
import "bootstrap/dist/css/bootstrap.min.css";
import { ThemeProvider } from "./contexts/ThemeContext";
const savedTheme =
localStorage.getItem("theme") ||
(window.matchMedia("(prefers-color-scheme: dark)").matches
? "dark"
: "light");
document.body.setAttribute("data-bs-theme", savedTheme);
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(
<React.StrictMode>
<ThemeProvider>
<App />
</ThemeProvider>
</React.StrictMode>,
);
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();
+8
View File
@@ -0,0 +1,8 @@
const getDateString = (date) => {
const dateData = new Date(date);
return [
dateData.getHours().toString().padStart(2, "0"),
dateData.getMinutes().toString().padStart(2, "0"),
].join(":");
};
export default getDateString;
@@ -0,0 +1,70 @@
import { useState } from "react";
import { useTheme } from "../../contexts/ThemeContext";
import { Modal, Button, Card, Form } from "react-bootstrap";
import EmojiPickerButton from "../../components/EmojiPickerButton/EmojiPickerButton";
const AddCategoryModal = ({ variant, ...props }) => {
const { theme } = useTheme();
const [show, setShow] = useState(false);
const handleClose = () => setShow(false);
const handleShow = () => setShow(true);
const [title, setTitle] = useState("");
return (
<>
<Button variant={theme} onClick={handleShow} className="m-0" {...props}>
New Category
</Button>
<Modal show={show} onHide={handleClose} fullscreen={true}>
<Modal.Header className="d-flex align-items-center justify-content-between">
<spacer />
<Modal.Title>New Category</Modal.Title>
<Button
variant={theme}
type="button"
onClick={handleClose}
style={{
borderRadius: "50%",
width: "30px",
height: "30px",
padding: "0",
}}
>
&#10005;
</Button>
</Modal.Header>
<Modal.Body className="p-3">
<div className="d-flex align-items-center justify-content-center">
<EmojiPickerButton />
</div>
<Form.Control
type="text"
placeholder="Title"
value={title}
onChange={(e) => setTitle(e.target.value)}
className="mb-3"
/>
<Card>
<Card.Body>
<div
className="text-muted small mb-1"
style={{ fontSize: "0.8rem" }}
>
SUBCATEGORIES
</div>
<Button
variant={"secondary"}
onClick={() => {}}
className="w-100 text-start mb-3"
>
Add subcategory
</Button>
<spacer />
<Button className="w-100">Add</Button>
</Card.Body>
</Card>
</Modal.Body>
</Modal>
</>
);
};
export default AddCategoryModal;
@@ -0,0 +1,194 @@
import { useState } from "react";
import { useTheme } from "../../contexts/ThemeContext";
import {
ListGroup,
Modal,
Button,
Card,
Form,
Row,
Col,
} from "react-bootstrap";
// import styles from "./HistoryModal.module.css";
const AddOperationModal = ({ variant }) => {
const { theme } = useTheme();
const [show, setShow] = useState(false);
const handleClose = () => setShow(false);
const handleShow = () => setShow(true);
const [isIncome, setIsIncome] = useState(false);
const [isExpense, setIsExpense] = useState(true);
const [isNoteVisible, setIsNoteVisible] = useState(false);
const [amount, setAmount] = useState();
return (
<>
{variant ? (
<Button variant={variant} onClick={handleShow}>
&#10010;
</Button>
) : (
<Button
className="fw-bold p-0 m-0"
variant="primary"
style={{ borderRadius: "50%", width: "40px", height: "40px" }}
onClick={handleShow}
>
&#10010;
</Button>
)}
<Modal show={show} onHide={handleClose} fullscreen={true}>
<Modal.Header className="d-flex align-items-center justify-content-between">
<spacer />
<Modal.Title>Add operation</Modal.Title>
<Button
variant={theme}
type="button"
onClick={handleClose}
style={{
borderRadius: "50%",
width: "30px",
height: "30px",
padding: "0",
}}
>
&#10005;
</Button>
</Modal.Header>
<Modal.Body className="p-0">
<div className="d-flex flex-column align-items-center justify-content-center m-2">
<h3
className="mb-0 fw-bolder text-start w-100"
style={{ fontSize: "1.1rem", fontWeight: 700 }}
>
Amount
</h3>
<div className="mb-3 d-flex gap-2 w-100 m-2">
<input
type="number"
className="form-control"
placeholder="-100 ₽"
value={amount}
onChange={(e) => setAmount(e.target.value)}
/>
<Button variant={theme} onClick={() => setAmount("")}>
&#10005;
</Button>
</div>
<div className="d-flex gap-2 w-100">
<Button
variant={isIncome ? "primary" : theme}
className="w-100"
onClick={() => {
setIsIncome(true);
setIsExpense(false);
}}
>
Income
</Button>
<Button
variant={isExpense ? "primary" : theme}
className="w-100"
onClick={() => {
setIsExpense(true);
setIsIncome(false);
}}
>
Expense
</Button>
</div>
</div>
<div className="d-flex flex-column align-items-center justify-content-center m-2">
<h3
className="mb-0 fw-bolder text-start w-100"
style={{ fontSize: "1.1rem", fontWeight: 700 }}
>
Appointment
</h3>
<Button variant={theme} className="w-100 mt-3">
<div className="d-flex flex-row gap-3 p-2">
<div
className="p-2 justify-content-start align-items-start d-flex flex-column"
style={{ fontSize: "30px" }}
>
<div>&#128512;</div>
</div>
<div className="d-flex flex-column p-0 justify-content-center align-items-start w-100">
<h3
className="mb-0 fw-bolder"
style={{ fontSize: "1.1rem", fontWeight: 700 }}
>
-63.00 ₽
</h3>
<div
className="text-muted small mb-1"
style={{ fontSize: "0.8rem" }}
>
Transport
</div>
</div>
</div>
</Button>
</div>
<Card className="m-2">
<Card.Body>
<div
className="text-muted small mb-1"
style={{ fontSize: "0.8rem" }}
>
ADDITIONAL
</div>
<ListGroup>
<ListGroup.Item>
<Form.Group as={Row}>
<Form.Label column>Date</Form.Label>
<Col>
<Form.Control type="date" />
</Col>
</Form.Group>
</ListGroup.Item>
<ListGroup.Item>
<Form.Group as={Row}>
<Form.Label column>Tag</Form.Label>
<Col>
<Form.Control type="text" />
</Col>
</Form.Group>
</ListGroup.Item>
<ListGroup.Item>
<Form.Group>
<Row>
<Form.Label column>Note</Form.Label>
<Col className="d-flex align-items-center justify-content-end">
<Form.Check
type="switch"
value={isNoteVisible}
onChange={() => setIsNoteVisible(!isNoteVisible)}
/>
</Col>
</Row>
<Row
style={{ display: isNoteVisible ? "block" : "none" }}
className="p-2"
>
<Form.Control type="text" placeholder="Your note text" />
</Row>
</Form.Group>
</ListGroup.Item>
<ListGroup.Item>
<Form.Group as={Row}>
<Form.Label column>Repeat payment</Form.Label>
<Col className="d-flex align-items-center justify-content-end">
<Form.Check type="switch" />
</Col>
</Form.Group>
</ListGroup.Item>
</ListGroup>
<Button className="w-100 mt-3">Add</Button>
</Card.Body>
</Card>
</Modal.Body>
</Modal>
</>
);
};
export default AddOperationModal;
@@ -0,0 +1,185 @@
import { useState } from "react";
import { useTheme } from "../../contexts/ThemeContext";
import { Tabs, Tab, Modal, Button } from "react-bootstrap";
import FinancialDashboard from "../../components/FinancialDashboard/FinancialDashboard";
import AppointmentDashboard from "../../components/AppointmentDashboard/AppointmentDashboard";
import styles from "./AnalyticsModal.module.css";
const AnalyticsModal = () => {
const { theme } = useTheme();
const [show, setShow] = useState(false);
const handleClose = () => setShow(false);
const handleShow = () => setShow(true);
// const income = 40407.17;
const expenses = 39985.23;
const monthdata = [
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 141, 15, 16, 17, 18, 19, 20, 21,
22, 23, 24, 25, 26, 27, 2, 29, 30, 31,
];
const monthMaxValue = Math.max(...monthdata);
const MonthChartData = {
labels: [
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"11",
"12",
"13",
"14",
"15",
"16",
"17",
"18",
"19",
"20",
"21",
"22",
"23",
"24",
"25",
"26",
"27",
"28",
"29",
"30",
"31",
],
datasets: [
{
data: monthdata,
backgroundColor: "#3576C3",
categoryPercentage: 0.5,
borderRadius: 3,
responsive: true,
},
],
};
const MonthLeftCardData = {
label: "Total for the period",
value: expenses,
};
const MonthRightCardData = {
label: "Daily average",
value: expenses / monthdata.length,
};
const MonthChartOptions = {
responsive: true,
maintainAspectRatio: false,
scales: {
y: {
display: false,
beginAtZero: true,
max: monthMaxValue * 1.1,
},
x: {
grid: {
display: false,
drawBorder: false,
},
ticks: {
color: "#6b7280",
font: {
size: 12,
weight: "500",
},
},
},
},
plugins: {
legend: {
display: false,
},
tooltip: {
// enabled: true,
callbacks: {
// title: function (context) {
// // Customize the tooltip title
// return `${context[0].label}`;
// },
label: function (context) {
// Customize the tooltip label
let label = context.dataset.label || "";
if (label) {
label += ": ";
}
if (context.parsed.y !== null) {
label += `${context.parsed.y} ₽`;
}
return label;
},
},
},
},
};
return (
<>
<Button
variant={theme}
className="shadow-sm p-2"
style={{ width: "100%", borderRadius: "15px" }}
onClick={handleShow}
>
Analytics
</Button>
<Modal show={show} onHide={handleClose} fullscreen={true}>
<Modal.Header className="d-flex align-items-center justify-content-between">
<Button variant={theme} type="button" onClick={handleClose}>
Close
</Button>
<Modal.Title>Analytics</Modal.Title>
<spacer />
</Modal.Header>
<Modal.Body style={{ paddingLeft: "0", paddingRight: "0" }}>
<Tabs defaultActiveKey="Expenses" id="analytics-tabs">
<Tab eventKey="Incomes" title="Incomes"></Tab>
<Tab eventKey="Expenses" title="Expenses" style={{ padding: "0" }}>
<div className="d-flex mt-2 justify-content-center">
<div className="d-flex flex-column p-0 justify-content-center align-items-center w-100">
<h3
className="mb-0 fw-bolder"
style={{ fontSize: "1.1rem", fontWeight: 700 }}
>
July 2025
</h3>
<div
className="d-flex text-muted small mb-0"
style={{ fontSize: "0.8rem" }}
>
Period: month
</div>
</div>
</div>
<hr className="mt-1" />
<div className={styles.scrollableContent}>
<FinancialDashboard
chartData={MonthChartData}
chartOptions={MonthChartOptions}
maxValue={monthMaxValue}
LeftCardData={MonthLeftCardData}
RightCardData={MonthRightCardData}
/>
<AppointmentDashboard className="m-3" />
</div>
</Tab>
</Tabs>
</Modal.Body>
</Modal>
</>
);
};
export default AnalyticsModal;
@@ -0,0 +1,11 @@
.scrollableContent {
height: calc(100vh - 220px);
bottom: 0;
overflow-y: auto;
}
@media (max-width: 768px) {
.scrollableContent {
height: calc(100vh - 280px);
}
}
@@ -0,0 +1,121 @@
import { useEffect, useState, useMemo, useCallback } from "react";
import { useTheme } from "../../contexts/ThemeContext";
import {
Modal,
Button,
Form,
InputGroup,
Tabs,
Tab,
Dropdown,
DropdownButton,
} from "react-bootstrap";
import styles from "./CategoriesModal.module.css";
import CategorySign from "../../components/CategorySign/CategorySign";
import AddCategoryModal from "../../modals/AddCategoryModal/AddCategoryModal";
import fetchCategories from "../../category/GetAllCategories";
const CategoriesModal = ({ variant }) => {
let [categories, setCategories] = useState([]);
const { theme } = useTheme();
const [show, setShow] = useState(false);
const [searchTerm, setSearchTerm] = useState("");
const handleClose = () => setShow(false);
const handleShow = () => setShow(true);
useEffect(() => {
fetchCategories().then((data) => {
setCategories(data);
console.log(data);
});
}, []);
const filteredCategories = useMemo(() => {
if (!searchTerm) return categories;
const term = searchTerm.toLowerCase();
return categories.filter((category) =>
category.title.toLowerCase().includes(term),
);
}, [categories, searchTerm]);
const handleSearch = useCallback((e) => {
setSearchTerm(e.target.value);
}, []);
return (
<>
<Button
variant={theme}
onClick={handleShow}
className="w-100 d-flex justify-content-between"
>
<div>&copy; Categories</div>
<div>&#10095;</div>
</Button>
<Modal show={show} onHide={handleClose} fullscreen={true}>
<Modal.Header>
<div className="d-flex flex-column w-100 gap-2">
<div className="d-flex align-items-center justify-content-between">
<Button
variant={theme}
onClick={handleClose}
className="d-flex justify-content-between gap-2"
>
<div style={{ transform: "rotate(180deg)" }}>&#10095;</div>
<div>Settings</div>
</Button>
<Modal.Title>Categories</Modal.Title>
<spacer />
<DropdownButton title="&#9776;" variant={theme} drop="start">
<Dropdown.Item className="p-0">
<AddCategoryModal
className="w-100"
style={{ paddingLeft: "0" }}
/>
</Dropdown.Item>
<Dropdown.Item>Reorder</Dropdown.Item>
</DropdownButton>
</div>
<InputGroup className="mb-3">
<InputGroup.Text id="basic-addon1">
<div style={{ transform: "rotate(90deg)" }}>&#9740;</div>
</InputGroup.Text>
<Form.Control
placeholder="Search"
aria-label="Search"
aria-describedby="basic-addon1"
value={searchTerm}
onChange={handleSearch}
/>
</InputGroup>
</div>
</Modal.Header>
<Modal.Body className="p-0">
<Tabs
defaultActiveKey="Expenses"
id="categories-tabs"
className="nav nav-tabs"
>
<Tab eventKey="Incomes" title="Incomes">
asdf
</Tab>
<Tab eventKey="Expenses" title="Expenses">
<div
className={styles.scrollableContent}
style={{ padding: "10px" }}
>
{filteredCategories.map((category) => (
<CategorySign
key={category.id}
icon={category.icon}
title={category.title}
subcategories={
category.subcategories ? category.subcategories : []
}
/>
))}
</div>
</Tab>
</Tabs>
</Modal.Body>
</Modal>
</>
);
};
export default CategoriesModal;
@@ -0,0 +1,11 @@
.scrollableContent {
height: calc(100vh - 220px);
bottom: 0;
overflow-y: auto;
}
@media (max-width: 768px) {
.scrollableContent {
height: calc(100vh - 280px);
}
}
@@ -0,0 +1,670 @@
import { useState, useEffect } from "react";
import { useTheme } from "../../contexts/ThemeContext";
import { ListGroup, Tabs, Tab, Modal, Button } from "react-bootstrap";
import styles from "./HistoryModal.module.css";
import AddOperationModal from "../AddOperationModal/AddOperationModal";
import GetAllOperation from "../../operation/GetAllOperation";
import OperationSign from "../../components/OperationSign/OperationSign";
const HistoryModal = () => {
const { theme } = useTheme();
const [show, setShow] = useState(false);
const handleClose = () => setShow(false);
const handleShow = () => setShow(true);
const [operations, setOperations] = useState([]);
useEffect(() => {
GetAllOperation().then((data) => {
console.log(data);
setOperations(data);
});
}, []);
return (
<>
<Button
variant={theme}
className="shadow-sm p-2"
style={{ width: "100%", borderRadius: "15px" }}
onClick={handleShow}
>
History
</Button>
<Modal show={show} onHide={handleClose} fullscreen={true}>
<Modal.Header className="d-flex align-items-center justify-content-between">
<Button variant={theme} type="button" onClick={handleClose}>
Close
</Button>
<Modal.Title>History</Modal.Title>
<AddOperationModal variant={theme} />
{/* <Button variant={theme}>&#43;</Button> */}
</Modal.Header>
<Modal.Body>
<Tabs defaultActiveKey="D" id="history-tabs">
<Tab
eventKey="D"
title="D"
className="pt-2 pb-2"
// style={{ maxHeight: "calc(100vh - 200px)", overflowY: "auto" }}
>
<div className={styles.scrollableContent}>
{operations.map((operation) => {
return (
<ListGroup className="mb-3 mt-0">
<ListGroup.Item className="p-0">
<OperationSign operation={operation} />
</ListGroup.Item>
</ListGroup>
);
})}
{/* <div className="d-flex m-1">
<div className="d-flex flex-column p-0 justify-content-start align-items-start w-100">
<h3
className="mb-0 fw-bolder"
style={{ fontSize: "1.1rem", fontWeight: 700 }}
>
25 Jul 2025
</h3>
<div
className="d-flex text-muted small mb-1 w-100"
style={{ fontSize: "0.8rem" }}
>
<div className="w-100">
Income: <b>0,00 ₽</b>
</div>
<div className="w-100 text-end">
Expense: <b>0,00 ₽</b>
</div>
</div>
</div>
</div>
<ListGroup className="mb-3 mt-0">
<ListGroup.Item className="p-0">
<div className="d-flex flex-row gap-3 p-2">
<div
className="p-2 justify-content-start align-items-start d-flex flex-column"
style={{ fontSize: "30px" }}
>
<div>&#128512;</div>
</div>
<div className="d-flex flex-column p-0 justify-content-start align-items-start w-100">
<h3
className="mb-0 fw-bolder"
style={{ fontSize: "1.1rem", fontWeight: 700 }}
>
-63.00 ₽
</h3>
<div
className="text-muted small mb-1"
style={{ fontSize: "0.8rem" }}
>
Transport
</div>
<div
className="text-muted small mb-1"
style={{ fontSize: "0.8rem" }}
>
Note
</div>
</div>
<div
className="p-0 m-0"
style={{ width: "100%", height: "100%" }}
>
<div
className="text-muted small mb-1 text-end"
style={{ fontSize: "0.8rem" }}
>
09:14
</div>
</div>
</div>
</ListGroup.Item>
<ListGroup.Item className="p-0">
<div className="d-flex flex-row gap-3 p-2">
<div
className="p-2 justify-content-start align-items-start d-flex flex-column"
style={{ fontSize: "30px" }}
>
<div>&#128508;</div>
</div>
<div className="d-flex flex-column p-0 justify-content-start align-items-start w-100">
<h3
className="mb-0 fw-bolder"
style={{
fontSize: "1.1rem",
fontWeight: 700,
color: "#2DBB4D",
}}
>
18000 ₽
</h3>
<div
className="text-muted small mb-1"
style={{ fontSize: "0.8rem" }}
>
Transport
</div>
<div
className="text-muted small mb-1"
style={{ fontSize: "0.8rem" }}
>
Note
</div>
</div>
<div
className="p-0 m-0"
style={{ width: "100%", height: "100%" }}
>
<div
className="text-muted small mb-1 text-end"
style={{ fontSize: "0.8rem" }}
>
09:14
</div>
</div>
</div>
</ListGroup.Item>
<ListGroup.Item className="p-0">
<div className="d-flex flex-row gap-3 p-2">
<div
className="p-2 justify-content-start align-items-start d-flex flex-column"
style={{ fontSize: "30px" }}
>
<div>&#128512;</div>
</div>
<div className="d-flex flex-column p-0 justify-content-start align-items-start w-100">
<h3
className="mb-0 fw-bolder"
style={{ fontSize: "1.1rem", fontWeight: 700 }}
>
-63.00 ₽
</h3>
<div
className="text-muted small mb-1"
style={{ fontSize: "0.8rem" }}
>
Transport
</div>
<div
className="text-muted small mb-1"
style={{ fontSize: "0.8rem" }}
>
Note
</div>
</div>
<div
className="p-0 m-0"
style={{ width: "100%", height: "100%" }}
>
<div
className="text-muted small mb-1 text-end"
style={{ fontSize: "0.8rem" }}
>
09:14
</div>
</div>
</div>
</ListGroup.Item>
</ListGroup>
<div className="d-flex m-1">
<div className="d-flex flex-column p-0 justify-content-start align-items-start w-100">
<h3
className="mb-0 fw-bolder"
style={{ fontSize: "1.1rem", fontWeight: 700 }}
>
25 Jul 2025
</h3>
<div
className="d-flex text-muted small mb-1 w-100"
style={{ fontSize: "0.8rem" }}
>
<div className="w-100">
Income: <b>0,00 ₽</b>
</div>
<div className="w-100 text-end">
Expense: <b>0,00 ₽</b>
</div>
</div>
</div>
</div>
<ListGroup className="mb-3 mt-0">
<ListGroup.Item className="p-0">
<div className="d-flex flex-row gap-3 p-2">
<div
className="p-2 justify-content-start align-items-start d-flex flex-column"
style={{ fontSize: "30px" }}
>
<div>&#128512;</div>
</div>
<div className="d-flex flex-column p-0 justify-content-start align-items-start w-100">
<h3
className="mb-0 fw-bolder"
style={{ fontSize: "1.1rem", fontWeight: 700 }}
>
-63.00 ₽
</h3>
<div
className="text-muted small mb-1"
style={{ fontSize: "0.8rem" }}
>
Transport
</div>
<div
className="text-muted small mb-1"
style={{ fontSize: "0.8rem" }}
>
Note
</div>
</div>
<div
className="p-0 m-0"
style={{ width: "100%", height: "100%" }}
>
<div
className="text-muted small mb-1 text-end"
style={{ fontSize: "0.8rem" }}
>
09:14
</div>
</div>
</div>
</ListGroup.Item>
<ListGroup.Item className="p-0">
<div className="d-flex flex-row gap-3 p-2">
<div
className="p-2 justify-content-start align-items-start d-flex flex-column"
style={{ fontSize: "30px" }}
>
<div>&#128508;</div>
</div>
<div className="d-flex flex-column p-0 justify-content-start align-items-start w-100">
<h3
className="mb-0 fw-bolder"
style={{
fontSize: "1.1rem",
fontWeight: 700,
color: "#2DBB4D",
}}
>
18000 ₽
</h3>
<div
className="text-muted small mb-1"
style={{ fontSize: "0.8rem" }}
>
Transport
</div>
<div
className="text-muted small mb-1"
style={{ fontSize: "0.8rem" }}
>
Note
</div>
</div>
<div
className="p-0 m-0"
style={{ width: "100%", height: "100%" }}
>
<div
className="text-muted small mb-1 text-end"
style={{ fontSize: "0.8rem" }}
>
09:14
</div>
</div>
</div>
</ListGroup.Item>
<ListGroup.Item className="p-0">
<div className="d-flex flex-row gap-3 p-2">
<div
className="p-2 justify-content-start align-items-start d-flex flex-column"
style={{ fontSize: "30px" }}
>
<div>&#128512;</div>
</div>
<div className="d-flex flex-column p-0 justify-content-start align-items-start w-100">
<h3
className="mb-0 fw-bolder"
style={{ fontSize: "1.1rem", fontWeight: 700 }}
>
-63.00 ₽
</h3>
<div
className="text-muted small mb-1"
style={{ fontSize: "0.8rem" }}
>
Transport
</div>
<div
className="text-muted small mb-1"
style={{ fontSize: "0.8rem" }}
>
Note
</div>
</div>
<div
className="p-0 m-0"
style={{ width: "100%", height: "100%" }}
>
<div
className="text-muted small mb-1 text-end"
style={{ fontSize: "0.8rem" }}
>
09:14
</div>
</div>
</div>
</ListGroup.Item>
</ListGroup>
<div className="d-flex m-1">
<div className="d-flex flex-column p-0 justify-content-start align-items-start w-100">
<h3
className="mb-0 fw-bolder"
style={{ fontSize: "1.1rem", fontWeight: 700 }}
>
25 Jul 2025
</h3>
<div
className="d-flex text-muted small mb-1 w-100"
style={{ fontSize: "0.8rem" }}
>
<div className="w-100">
Income: <b>0,00 ₽</b>
</div>
<div className="w-100 text-end">
Expense: <b>0,00 ₽</b>
</div>
</div>
</div>
</div>
<ListGroup className="mb-3 mt-0">
<ListGroup.Item className="p-0">
<div className="d-flex flex-row gap-3 p-2">
<div
className="p-2 justify-content-start align-items-start d-flex flex-column"
style={{ fontSize: "30px" }}
>
<div>&#128512;</div>
</div>
<div className="d-flex flex-column p-0 justify-content-start align-items-start w-100">
<h3
className="mb-0 fw-bolder"
style={{ fontSize: "1.1rem", fontWeight: 700 }}
>
-63.00 ₽
</h3>
<div
className="text-muted small mb-1"
style={{ fontSize: "0.8rem" }}
>
Transport
</div>
<div
className="text-muted small mb-1"
style={{ fontSize: "0.8rem" }}
>
Note
</div>
</div>
<div
className="p-0 m-0"
style={{ width: "100%", height: "100%" }}
>
<div
className="text-muted small mb-1 text-end"
style={{ fontSize: "0.8rem" }}
>
09:14
</div>
</div>
</div>
</ListGroup.Item>
<ListGroup.Item className="p-0">
<div className="d-flex flex-row gap-3 p-2">
<div
className="p-2 justify-content-start align-items-start d-flex flex-column"
style={{ fontSize: "30px" }}
>
<div>&#128508;</div>
</div>
<div className="d-flex flex-column p-0 justify-content-start align-items-start w-100">
<h3
className="mb-0 fw-bolder"
style={{
fontSize: "1.1rem",
fontWeight: 700,
color: "#2DBB4D",
}}
>
18000 ₽
</h3>
<div
className="text-muted small mb-1"
style={{ fontSize: "0.8rem" }}
>
Transport
</div>
<div
className="text-muted small mb-1"
style={{ fontSize: "0.8rem" }}
>
Note
</div>
</div>
<div
className="p-0 m-0"
style={{ width: "100%", height: "100%" }}
>
<div
className="text-muted small mb-1 text-end"
style={{ fontSize: "0.8rem" }}
>
09:14
</div>
</div>
</div>
</ListGroup.Item>
<ListGroup.Item className="p-0">
<div className="d-flex flex-row gap-3 p-2">
<div
className="p-2 justify-content-start align-items-start d-flex flex-column"
style={{ fontSize: "30px" }}
>
<div>&#128512;</div>
</div>
<div className="d-flex flex-column p-0 justify-content-start align-items-start w-100">
<h3
className="mb-0 fw-bolder"
style={{ fontSize: "1.1rem", fontWeight: 700 }}
>
-63.00 ₽
</h3>
<div
className="text-muted small mb-1"
style={{ fontSize: "0.8rem" }}
>
Transport
</div>
<div
className="text-muted small mb-1"
style={{ fontSize: "0.8rem" }}
>
Note
</div>
</div>
<div
className="p-0 m-0"
style={{ width: "100%", height: "100%" }}
>
<div
className="text-muted small mb-1 text-end"
style={{ fontSize: "0.8rem" }}
>
09:14
</div>
</div>
</div>
</ListGroup.Item>
</ListGroup>
<div className="d-flex m-1">
<div className="d-flex flex-column p-0 justify-content-start align-items-start w-100">
<h3
className="mb-0 fw-bolder"
style={{ fontSize: "1.1rem", fontWeight: 700 }}
>
25 Jul 2025
</h3>
<div
className="d-flex text-muted small mb-1 w-100"
style={{ fontSize: "0.8rem" }}
>
<div className="w-100">
Income: <b>0,00 ₽</b>
</div>
<div className="w-100 text-end">
Expense: <b>0,00 ₽</b>
</div>
</div>
</div>
</div>
<ListGroup className="mb-3 mt-0">
<ListGroup.Item className="p-0">
<div className="d-flex flex-row gap-3 p-2">
<div
className="p-2 justify-content-start align-items-start d-flex flex-column"
style={{ fontSize: "30px" }}
>
<div>&#128512;</div>
</div>
<div className="d-flex flex-column p-0 justify-content-start align-items-start w-100">
<h3
className="mb-0 fw-bolder"
style={{ fontSize: "1.1rem", fontWeight: 700 }}
>
-63.00 ₽
</h3>
<div
className="text-muted small mb-1"
style={{ fontSize: "0.8rem" }}
>
Transport
</div>
<div
className="text-muted small mb-1"
style={{ fontSize: "0.8rem" }}
>
Note
</div>
</div>
<div
className="p-0 m-0"
style={{ width: "100%", height: "100%" }}
>
<div
className="text-muted small mb-1 text-end"
style={{ fontSize: "0.8rem" }}
>
09:14
</div>
</div>
</div>
</ListGroup.Item>
<ListGroup.Item className="p-0">
<div className="d-flex flex-row gap-3 p-2">
<div
className="p-2 justify-content-start align-items-start d-flex flex-column"
style={{ fontSize: "30px" }}
>
<div>&#128508;</div>
</div>
<div className="d-flex flex-column p-0 justify-content-start align-items-start w-100">
<h3
className="mb-0 fw-bolder"
style={{
fontSize: "1.1rem",
fontWeight: 700,
color: "#2DBB4D",
}}
>
18000 ₽
</h3>
<div
className="text-muted small mb-1"
style={{ fontSize: "0.8rem" }}
>
Transport
</div>
<div
className="text-muted small mb-1"
style={{ fontSize: "0.8rem" }}
>
Note
</div>
</div>
<div
className="p-0 m-0"
style={{ width: "100%", height: "100%" }}
>
<div
className="text-muted small mb-1 text-end"
style={{ fontSize: "0.8rem" }}
>
09:14
</div>
</div>
</div>
</ListGroup.Item>
<ListGroup.Item className="p-0">
<div className="d-flex flex-row gap-3 p-2">
<div
className="p-2 justify-content-start align-items-start d-flex flex-column"
style={{ fontSize: "30px" }}
>
<div>&#128512;</div>
</div>
<div className="d-flex flex-column p-0 justify-content-start align-items-start w-100">
<h3
className="mb-0 fw-bolder"
style={{ fontSize: "1.1rem", fontWeight: 700 }}
>
-63.00 ₽
</h3>
<div
className="text-muted small mb-1"
style={{ fontSize: "0.8rem" }}
>
Transport
</div>
<div
className="text-muted small mb-1"
style={{ fontSize: "0.8rem" }}
>
Note
</div>
</div>
<div
className="p-0 m-0"
style={{ width: "100%", height: "100%" }}
>
<div
className="text-muted small mb-1 text-end"
style={{ fontSize: "0.8rem" }}
>
09:14
</div>
</div>
</div>
</ListGroup.Item> */}
{/* </ListGroup> */}
</div>
</Tab>
<Tab eventKey="W" title="W" className="pt-2 pb-2"></Tab>
<Tab eventKey="M" title="M" className="pt-2 pb-2"></Tab>
<Tab eventKey="Y" title="Y" className="pt-2 pb-2"></Tab>
</Tabs>
</Modal.Body>
</Modal>
</>
);
};
export default HistoryModal;
@@ -0,0 +1,10 @@
.scrollableContent {
height: calc(100vh - 220px);
overflow-y: auto;
}
@media (max-width: 768px) {
.scrollableContent {
height: calc(100vh - 240px);
}
}
@@ -0,0 +1,64 @@
import { useState } from "react";
import { useTheme } from "../../contexts/ThemeContext";
import { ListGroup, Modal, Button } from "react-bootstrap";
import ThemeToggle from "../../components/ThemeToggle";
import CategoriesModal from "../../modals/CategoriesModal/CategoriesModal";
const SettingsModal = () => {
const { theme } = useTheme();
const [show, setShow] = useState(false);
const handleClose = () => setShow(false);
const handleShow = () => setShow(true);
return (
<>
<Button
className="fw-bold p-0 m-0"
variant={theme}
style={{ borderRadius: "50%", width: "40px", height: "40px" }}
onClick={handleShow}
>
&#9881;
</Button>
<Modal show={show} onHide={handleClose} fullscreen={true}>
<Modal.Header className="d-flex align-items-center justify-content-between">
<Modal.Title>
<h1>Settings</h1>
</Modal.Title>
<Button
variant={theme}
type="button"
onClick={handleClose}
style={{
borderRadius: "50%",
width: "30px",
height: "30px",
padding: "0",
}}
>
&#10005;
</Button>
</Modal.Header>
<Modal.Body>
<h3 className="text-muted small m-1" style={{ fontSize: "0.8rem" }}>
DATA
</h3>
<ListGroup>
<ListGroup.Item className="p-0">
<CategoriesModal />
</ListGroup.Item>
</ListGroup>
<h3 className="text-muted small m-1" style={{ fontSize: "0.8rem" }}>
APPLICATION
</h3>
<ListGroup>
<ListGroup.Item>
<ThemeToggle />
</ListGroup.Item>
</ListGroup>
</Modal.Body>
</Modal>
</>
);
};
export default SettingsModal;
@@ -0,0 +1,10 @@
.scrollableContent {
height: calc(100vh - 220px);
overflow-y: auto;
}
@media (max-width: 768px) {
.scrollableContent {
height: calc(100vh - 240px);
}
}
@@ -0,0 +1,9 @@
import routes from "../routes";
const GetAllOperation = async () => {
const response = await fetch(routes.operations);
const data = await response.json();
return data;
};
export default GetAllOperation;
+110
View File
@@ -0,0 +1,110 @@
import FinancialDashboard from "../components/FinancialDashboard/FinancialDashboard";
import { Row, Col } from "react-bootstrap";
import HistoryModal from "../modals/HistoryModal/HistoryModal";
import AnalyticsModal from "../modals/AnalyticsModal/AnalyticsModal";
import BalanceBlock from "../components/BalanceBlock/BalanceBlock";
const Home = () => {
const weeklyData = [63, 63, 63, 63, 63, 63, 63];
const weeklyData1 = [20, 80, 50, 100, 1800, 60, 90];
const weeklyMaxValue = Math.max(...weeklyData, ...weeklyData1);
const chartData = {
labels: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
datasets: [
{
data: weeklyData,
backgroundColor: "#3576C3",
categoryPercentage: 0.5,
borderRadius: 3,
responsive: true,
},
{
data: weeklyData1,
backgroundColor: "#38393F",
categoryPercentage: 0.5,
borderRadius: 3,
responsive: true,
},
],
};
const chartOptions = {
responsive: true,
maintainAspectRatio: false,
scales: {
y: {
display: false,
beginAtZero: true,
max: weeklyMaxValue * 1.1,
},
x: {
grid: {
display: false,
drawBorder: false,
},
ticks: {
color: "#6b7280",
font: {
size: 12,
weight: "500",
},
},
},
},
plugins: {
legend: {
display: false,
},
tooltip: {
callbacks: {
label: function (context) {
let label = context.dataset.label || "";
if (label) {
label += ": ";
}
if (context.parsed.y !== null) {
label +=
`${weeklyData[context.dataIndex]}₽ ` +
`${weeklyData1[context.dataIndex]}₽`;
}
return label;
},
},
},
},
};
const income = 40407.17;
const expenses = 39985.23;
const LeftCardData = {
label: "Monthly Icome",
value: income,
};
const RightCardData = {
label: "Monthly Expenses",
value: expenses,
};
return (
<>
<FinancialDashboard
chartData={chartData}
chartOptions={chartOptions}
maxValue={weeklyMaxValue}
LeftCardData={LeftCardData}
RightCardData={RightCardData}
/>
<Row className="m-1">
<Col>
<AnalyticsModal />
</Col>
<Col>
<HistoryModal />
</Col>
</Row>
<BalanceBlock />
</>
);
};
export default Home;
+14
View File
@@ -0,0 +1,14 @@
import { Alert, Button } from "react-bootstrap";
import { Link } from "react-router-dom";
const NotFound = () => (
<Alert variant="danger" className="text-center">
<Alert.Heading>404 - Page Not Found</Alert.Heading>
<p>The page you're looking for doesn't exist.</p>
<Button as={Link} to="/" variant="outline-danger">
Go Home
</Button>
</Alert>
);
export default NotFound;
+13
View File
@@ -0,0 +1,13 @@
const reportWebVitals = onPerfEntry => {
if (onPerfEntry && onPerfEntry instanceof Function) {
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
getCLS(onPerfEntry);
getFID(onPerfEntry);
getFCP(onPerfEntry);
getLCP(onPerfEntry);
getTTFB(onPerfEntry);
});
}
};
export default reportWebVitals;
+7
View File
@@ -0,0 +1,7 @@
const host = window.location.origin;
const prefix = "/api";
const routes = {
categories: `${host}${prefix}/category`,
operations: `${host}${prefix}/operation`,
};
export default routes;
+5
View File
@@ -0,0 +1,5 @@
// jest-dom adds custom jest matchers for asserting on DOM nodes.
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom';