полностью изменил структуру

This commit is contained in:
2026-07-23 17:28:23 +05:00
parent 5de29561f2
commit 6a9f00ac75
18 changed files with 1225 additions and 2542 deletions
+63 -5
View File
@@ -8,9 +8,10 @@
"name": "frontend",
"version": "0.0.0",
"dependencies": {
"lucide-react": "^1.24.0",
"lucide-react": "^1.26.0",
"react": "^19.2.7",
"react-dom": "^19.2.7"
"react-dom": "^19.2.7",
"react-router-dom": "^7.18.1"
},
"devDependencies": {
"@types/react": "^19.2.17",
@@ -727,6 +728,19 @@
}
}
},
"node_modules/cookie": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-1.1.1.tgz",
"integrity": "sha512-ei8Aos7ja0weRpFzJnEA9UHJ/7XQmqglbRwnf2ATjcB9Wq874VKH9kfjjirM6UhU2/E5fFYadylyhFldcqSidQ==",
"license": "MIT",
"engines": {
"node": ">=18"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/csstype": {
"version": "3.2.3",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",
@@ -1039,9 +1053,9 @@
}
},
"node_modules/lucide-react": {
"version": "1.24.0",
"resolved": "https://registry.npmjs.org/lucide-react/-/lucide-react-1.24.0.tgz",
"integrity": "sha512-YT6mBD8lGKkg4nM39enlm94/sfJIiW0YKUT60fBy4YK8tai31ylg1VhGNWxkpSKHo9UagfnZqwIff3HTDQwXeA==",
"version": "1.26.0",
"resolved": "https://registry.npmjs.org/lucide-react/-/lucide-react-1.26.0.tgz",
"integrity": "sha512-raglYVR2+VkMfJL158krjVmE+rV5ST2lzA/KQm1FRSjMHT4MnWaegHxoVEpmc2So3nOEhp9oGejJwAPX8MoAjg==",
"license": "ISC",
"peerDependencies": {
"react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0"
@@ -1185,6 +1199,44 @@
"react": "^19.2.7"
}
},
"node_modules/react-router": {
"version": "7.18.1",
"resolved": "https://registry.npmjs.org/react-router/-/react-router-7.18.1.tgz",
"integrity": "sha512-GDLgg3i3uM0aeJO3Fm+TCS+sDQ7gu12T6x0qdTEzcwqEfleci7JwugVNIF3U//0FWKnJT7ptG+20B2jfDqnZAg==",
"license": "MIT",
"dependencies": {
"cookie": "^1.0.1",
"set-cookie-parser": "^2.6.0"
},
"engines": {
"node": ">=20.0.0"
},
"peerDependencies": {
"react": ">=18",
"react-dom": ">=18"
},
"peerDependenciesMeta": {
"react-dom": {
"optional": true
}
}
},
"node_modules/react-router-dom": {
"version": "7.18.1",
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.18.1.tgz",
"integrity": "sha512-KaZh+X/6UtEp28x51AUYZDMg9NGoz2ja3dNHa+ta/tk40vCzKhQ/RypCWBMLbmDr6//E24Vv5uPsrqXFozdkAg==",
"license": "MIT",
"dependencies": {
"react-router": "7.18.1"
},
"engines": {
"node": ">=20.0.0"
},
"peerDependencies": {
"react": ">=18",
"react-dom": ">=18"
}
},
"node_modules/rolldown": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.1.5.tgz",
@@ -1225,6 +1277,12 @@
"integrity": "sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q==",
"license": "MIT"
},
"node_modules/set-cookie-parser": {
"version": "2.7.2",
"resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.7.2.tgz",
"integrity": "sha512-oeM1lpU/UvhTxw+g3cIfxXHyJRc/uidd3yK1P242gzHds0udQBYzs3y8j4gCCW+ZJ7ad0yctld8RYO+bdurlvw==",
"license": "MIT"
},
"node_modules/source-map-js": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
+3 -2
View File
@@ -10,9 +10,10 @@
"preview": "vite preview"
},
"dependencies": {
"lucide-react": "^1.24.0",
"lucide-react": "^1.26.0",
"react": "^19.2.7",
"react-dom": "^19.2.7"
"react-dom": "^19.2.7",
"react-router-dom": "^7.18.1"
},
"devDependencies": {
"@types/react": "^19.2.17",
+27 -1229
View File
File diff suppressed because it is too large Load Diff
+52
View File
@@ -0,0 +1,52 @@
import React from 'react';
import { Link, useLocation, useNavigate } from 'react-router-dom';
import { Home, List, CreditCard, Banknote, Settings, LogOut } from 'lucide-react';
export default function Layout({ children }) {
const location = useLocation();
const navigate = useNavigate();
const handleLogout = () => {
localStorage.removeItem('token');
localStorage.removeItem('user');
navigate('/auth');
};
const navItems = [
{ path: '/', label: 'Дашборд', icon: <Home size={20} /> },
{ path: '/transactions', label: 'Транзакции', icon: <List size={20} /> },
{ path: '/incomes', label: 'Регулярные Доходы', icon: <Banknote size={20} /> },
{ path: '/debts', label: 'Долги', icon: <CreditCard size={20} /> },
{ path: '/settings', label: 'Настройки', icon: <Settings size={20} /> },
];
return (
<div className="app-container">
<aside className="sidebar">
<div className="sidebar-header">
Finance Manager
</div>
<nav className="sidebar-nav">
{navItems.map(item => (
<Link
key={item.path}
to={item.path}
className={`nav-item ${location.pathname === item.path ? 'active' : ''}`}
>
{item.icon}
{item.label}
</Link>
))}
</nav>
<div className="sidebar-footer">
<button className="secondary" onClick={handleLogout} style={{ width: '100%', display: 'flex', alignItems: 'center', justifyContent: 'center', gap: '0.5rem' }}>
<LogOut size={18} /> Выйти
</button>
</div>
</aside>
<main className="main-content">
{children}
</main>
</div>
);
}
+156 -660
View File
@@ -1,759 +1,255 @@
/* Premium Minimalistic Dark Theme Design System */
:root {
/* Colors */
--bg-color: #090a0f;
--card-bg: #11141e;
--card-border: #1e2330;
--card-border-hover: #2d3446;
--primary: #8b5cf6;
--secondary: #06b6d4;
--income: #10b981;
--income-bg: rgba(16, 185, 129, 0.08);
--expense: #f43f5e;
--expense-bg: rgba(244, 63, 94, 0.08);
--text-primary: #f3f4f6;
--text-secondary: #9ca3af;
--text-muted: #4b5563;
--shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
/* Fonts */
--font-sans: 'Inter', system-ui, -apple-system, sans-serif;
--font-display: 'Outfit', sans-serif;
--bg-primary: #121212;
--bg-secondary: #1e1e1e;
--bg-card: #252526;
--text-primary: #e0e0e0;
--text-secondary: #a0a0a0;
--accent-color: #007acc;
--accent-hover: #0098ff;
--danger: #d32f2f;
--success: #388e3c;
--border-color: #333333;
--font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
font-family: var(--font-sans);
-webkit-tap-highlight-color: transparent;
}
body {
background: var(--bg-color);
background-color: var(--bg-primary);
color: var(--text-primary);
min-height: 100vh;
overflow-x: hidden;
font-family: var(--font-family);
-webkit-font-smoothing: antialiased;
line-height: 1.5;
}
/* Custom Scrollbar */
::-webkit-scrollbar {
width: 5px;
height: 5px;
h1, h2, h3, h4 {
font-weight: 600;
color: #ffffff;
}
::-webkit-scrollbar-track {
background: transparent;
a {
color: var(--accent-color);
text-decoration: none;
}
::-webkit-scrollbar-thumb {
background: #1f2937;
a:hover {
text-decoration: underline;
}
button {
cursor: pointer;
font-family: inherit;
border: none;
background: var(--accent-color);
color: #fff;
padding: 0.5rem 1rem;
border-radius: 4px;
font-size: 0.9rem;
font-weight: 500;
transition: background 0.2s;
}
::-webkit-scrollbar-thumb:hover {
background: var(--text-muted);
button:hover {
background: var(--accent-hover);
}
button.secondary {
background: transparent;
border: 1px solid var(--border-color);
color: var(--text-primary);
}
button.secondary:hover {
background: var(--bg-secondary);
}
button.danger {
background: var(--danger);
}
button.danger:hover {
background: #f44336;
}
input, select {
width: 100%;
padding: 0.6rem;
margin-bottom: 1rem;
background: var(--bg-card);
border: 1px solid var(--border-color);
color: var(--text-primary);
border-radius: 4px;
font-family: inherit;
}
input:focus, select:focus {
outline: none;
border-color: var(--accent-color);
}
/* Layout */
#root {
min-height: 100vh;
display: flex;
flex-direction: column;
}
.app-container {
display: flex;
min-height: 100vh;
width: 100%;
max-width: 1400px;
margin: 0 auto;
}
@media (max-width: 768px) {
.app-container {
flex-direction: column;
padding-bottom: 80px;
}
}
/* Minimalist Panels */
.glass-panel {
background: var(--card-bg);
border: 1px solid var(--card-border);
border-radius: 12px;
box-shadow: var(--shadow);
transition: border-color 0.2s ease, transform 0.2s ease;
}
.glass-panel:hover {
border-color: var(--card-border-hover);
}
.glass-panel.interactive:hover {
transform: translateY(-2px);
}
/* Sidebar Navigation */
.sidebar {
width: 250px;
padding: 35px 20px;
background-color: var(--bg-secondary);
border-right: 1px solid var(--border-color);
display: flex;
flex-direction: column;
border-right: 1px solid var(--card-border);
background: #0b0d14;
position: sticky;
top: 0;
height: 100vh;
}
.logo-container {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 40px;
padding-left: 5px;
.sidebar-header {
padding: 1.5rem;
font-size: 1.25rem;
font-weight: 700;
border-bottom: 1px solid var(--border-color);
color: #fff;
}
.logo-icon {
color: var(--primary);
display: flex;
align-items: center;
justify-content: center;
}
.logo-text {
font-family: var(--font-display);
font-size: 19px;
font-weight: 600;
letter-spacing: -0.3px;
color: #ffffff;
}
.nav-links {
.sidebar-nav {
display: flex;
flex-direction: column;
gap: 6px;
list-style: none;
padding: 1rem 0;
flex: 1;
}
.nav-link-btn {
width: 100%;
display: flex;
align-items: center;
gap: 12px;
padding: 10px 14px;
background: transparent;
border: none;
border-radius: 8px;
.nav-item {
padding: 0.75rem 1.5rem;
color: var(--text-secondary);
font-size: 14px;
font-weight: 500;
cursor: pointer;
transition: all 0.15s ease;
text-align: left;
}
.nav-link-btn:hover {
background: rgba(255, 255, 255, 0.03);
color: var(--text-primary);
}
.nav-link-btn.active {
background: rgba(255, 255, 255, 0.05);
border: 1px solid var(--card-border-hover);
color: #ffffff;
}
/* User Info Sidebar */
.user-profile {
margin-top: auto;
padding: 12px;
display: flex;
align-items: center;
gap: 10px;
border-radius: 8px;
border: 1px solid var(--card-border);
background: rgba(255, 255, 255, 0.01);
gap: 0.75rem;
text-decoration: none;
}
.user-avatar {
width: 34px;
height: 34px;
border-radius: 50%;
background: var(--card-border-hover);
display: flex;
align-items: center;
justify-content: center;
font-family: var(--font-display);
font-weight: 600;
font-size: 14px;
.nav-item:hover, .nav-item.active {
background-color: var(--bg-card);
color: var(--text-primary);
text-decoration: none;
}
.user-details {
display: flex;
flex-direction: column;
overflow: hidden;
.sidebar-footer {
padding: 1rem;
border-top: 1px solid var(--border-color);
}
.user-name {
font-weight: 500;
font-size: 13px;
color: var(--text-primary);
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
.user-role {
font-size: 11px;
color: var(--text-secondary);
}
/* Main Content */
.main-content {
flex: 1;
padding: 50px 60px;
padding: 2rem;
overflow-y: auto;
}
@media (max-width: 768px) {
.main-content {
padding: 24px 20px;
}
.sidebar {
display: none;
}
}
/* Mobile Bottom Navigation */
.mobile-nav {
display: none;
position: fixed;
bottom: 0;
left: 0;
right: 0;
height: 65px;
background: #0b0d14;
border-top: 1px solid var(--card-border);
z-index: 100;
justify-content: space-around;
align-items: center;
}
@media (max-width: 768px) {
.mobile-nav {
display: flex;
}
}
.mobile-nav-btn {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 3px;
background: transparent;
border: none;
color: var(--text-secondary);
font-size: 10px;
font-weight: 500;
cursor: pointer;
}
.mobile-nav-btn.active {
color: var(--primary);
}
.mobile-nav-btn svg {
width: 20px;
height: 20px;
}
/* Metrics Dashboard */
.metrics-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
gap: 16px;
margin-bottom: 24px;
}
.metric-card {
padding: 20px;
}
.metric-header {
.page-header {
margin-bottom: 2rem;
display: flex;
justify-content: space-between;
align-items: center;
color: var(--text-secondary);
font-size: 13px;
margin-bottom: 8px;
}
.metric-icon {
color: var(--text-muted);
/* Cards & Tables */
.card {
background: var(--bg-card);
border: 1px solid var(--border-color);
border-radius: 6px;
padding: 1.5rem;
margin-bottom: 1.5rem;
}
.metric-value {
font-family: var(--font-display);
font-size: 24px;
font-weight: 600;
letter-spacing: -0.3px;
}
/* Charts Layout */
.charts-grid {
.dashboard-grid {
display: grid;
grid-template-columns: 1.5fr 1fr;
gap: 20px;
margin-bottom: 24px;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 1.5rem;
}
@media (max-width: 1024px) {
.charts-grid {
grid-template-columns: 1fr;
}
.stat-card {
text-align: center;
}
.chart-card {
padding: 20px;
min-height: 320px;
display: flex;
flex-direction: column;
}
.chart-title {
font-family: var(--font-display);
font-size: 15px;
font-weight: 600;
color: var(--text-primary);
margin-bottom: 20px;
}
/* Minimal Buttons */
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 6px;
padding: 8px 14px;
border-radius: 6px;
font-size: 13px;
font-weight: 500;
cursor: pointer;
transition: all 0.15s ease;
border: 1px solid transparent;
outline: none;
}
.btn:active {
transform: scale(0.98);
}
.btn-primary {
background: var(--primary);
color: white;
}
.btn-primary:hover {
background: #7c3aed;
}
.btn-secondary {
background: rgba(255, 255, 255, 0.02);
border-color: var(--card-border);
color: var(--text-primary);
}
.btn-secondary:hover {
background: rgba(255, 255, 255, 0.05);
border-color: var(--card-border-hover);
}
.btn-danger {
background: var(--expense-bg);
border-color: rgba(244, 63, 94, 0.15);
color: #fb7185;
}
.btn-danger:hover {
background: rgba(244, 63, 94, 0.12);
}
.btn-success {
background: var(--income-bg);
border-color: rgba(16, 185, 129, 0.15);
color: #34d399;
}
.btn-success:hover {
background: rgba(16, 185, 129, 0.12);
}
/* Forms */
.form-group {
display: flex;
flex-direction: column;
gap: 4px;
margin-bottom: 12px;
}
.form-label {
font-size: 12px;
font-weight: 500;
.stat-card h3 {
color: var(--text-secondary);
font-size: 0.9rem;
text-transform: uppercase;
letter-spacing: 1px;
margin-bottom: 0.5rem;
}
.form-input {
width: 100%;
padding: 10px 12px;
background: #090a0f;
border: 1px solid var(--card-border);
border-radius: 6px;
color: white;
font-size: 13px;
transition: border-color 0.15s ease;
outline: none;
.stat-card .value {
font-size: 2rem;
font-weight: 700;
}
.form-input:focus {
border-color: var(--primary);
}
.stat-card .value.income { color: var(--success); }
.stat-card .value.expense { color: var(--danger); }
.form-select {
appearance: none;
background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
background-repeat: no-repeat;
background-position: right 10px center;
background-size: 14px;
padding-right: 32px;
}
/* Modal Popup */
.modal-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.6);
z-index: 1000;
display: flex;
align-items: center;
justify-content: center;
padding: 16px;
}
.modal-content {
width: 100%;
max-width: 400px;
padding: 24px;
position: relative;
}
.modal-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16px;
}
.modal-title {
font-family: var(--font-display);
font-size: 17px;
font-weight: 600;
}
.modal-close {
background: transparent;
border: none;
color: var(--text-secondary);
cursor: pointer;
display: flex;
}
.modal-close:hover {
color: white;
}
/* Tables & Lists */
.table-container {
overflow-x: auto;
}
.data-table {
table {
width: 100%;
border-collapse: collapse;
}
th, td {
padding: 1rem;
text-align: left;
border-bottom: 1px solid var(--border-color);
}
.data-table th {
padding: 10px 12px;
font-size: 11px;
font-weight: 600;
th {
color: var(--text-secondary);
border-bottom: 1px solid var(--card-border);
font-weight: 500;
font-size: 0.85rem;
text-transform: uppercase;
letter-spacing: 0.5px;
}
.data-table td {
padding: 12px 12px;
font-size: 13px;
border-bottom: 1px solid rgba(255, 255, 255, 0.02);
tr:hover {
background-color: rgba(255, 255, 255, 0.02);
}
.data-table tr:last-child td {
border-bottom: none;
}
.data-table tr:hover td {
background: rgba(255, 255, 255, 0.01);
}
/* Transaction Styles */
.tx-type-indicator {
display: inline-flex;
padding: 2px 6px;
border-radius: 4px;
font-size: 10px;
font-weight: 600;
}
.tx-type-indicator.income {
background: var(--income-bg);
color: var(--income);
}
.tx-type-indicator.expense {
background: var(--expense-bg);
color: var(--expense);
}
.tx-amount {
font-family: var(--font-display);
font-weight: 500;
}
.tx-amount.income { color: var(--income); }
.tx-amount.expense { color: var(--expense); }
/* Subscriptions */
.sub-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
gap: 16px;
}
.sub-card {
padding: 20px;
display: flex;
flex-direction: column;
position: relative;
}
.sub-card.inactive {
opacity: 0.5;
}
.sub-header {
display: flex;
justify-content: space-between;
align-items: flex-start;
margin-bottom: 12px;
}
.sub-name {
font-family: var(--font-display);
font-size: 16px;
font-weight: 500;
}
.sub-amount {
font-family: var(--font-display);
font-size: 20px;
font-weight: 600;
color: white;
margin-bottom: 8px;
}
.sub-details {
display: flex;
flex-direction: column;
gap: 4px;
margin-bottom: 16px;
font-size: 12px;
color: var(--text-secondary);
}
.sub-actions {
display: flex;
gap: 8px;
margin-top: auto;
}
/* Shopping List */
.shopping-columns {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
gap: 20px;
margin-bottom: 24px;
}
.shopping-column {
display: flex;
flex-direction: column;
gap: 12px;
}
.column-title {
font-family: var(--font-display);
font-size: 14px;
font-weight: 600;
display: flex;
align-items: center;
gap: 6px;
padding-bottom: 6px;
border-bottom: 1px solid var(--card-border);
}
.column-title.high { color: var(--expense); }
.column-title.medium { color: #eab308; }
.column-title.low { color: var(--secondary); }
.column-title.bought { color: var(--text-muted); }
.shopping-card {
padding: 12px 14px;
display: flex;
align-items: center;
justify-content: space-between;
}
.shopping-item-info {
display: flex;
flex-direction: column;
gap: 2px;
overflow: hidden;
}
.shopping-item-name {
font-weight: 500;
font-size: 14px;
color: var(--text-primary);
}
.shopping-card.bought-item .shopping-item-name {
text-decoration: line-through;
color: var(--text-muted);
}
.shopping-item-price {
font-size: 11px;
color: var(--text-secondary);
}
.shopping-item-actions {
display: flex;
align-items: center;
gap: 6px;
}
/* Alerts */
.alert {
padding: 10px 14px;
border-radius: 6px;
margin-bottom: 16px;
font-size: 13px;
display: flex;
align-items: center;
gap: 8px;
}
.alert-success {
background: var(--income-bg);
border: 1px solid rgba(16, 185, 129, 0.1);
color: #34d399;
}
.alert-error {
background: var(--expense-bg);
border: 1px solid rgba(244, 63, 94, 0.1);
color: #fb7185;
}
/* Headings */
.page-title {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 24px;
}
.page-title h1 {
font-family: var(--font-display);
font-size: 24px;
font-weight: 600;
letter-spacing: -0.4px;
color: #ffffff;
}
/* Login container */
.login-container {
/* Auth Pages */
.auth-container {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
padding: 16px;
background: var(--bg-primary);
}
.login-card {
.auth-box {
background: var(--bg-card);
padding: 2.5rem;
border-radius: 8px;
border: 1px solid var(--border-color);
width: 100%;
max-width: 380px;
padding: 30px;
max-width: 400px;
}
.auth-box h2 {
margin-bottom: 1.5rem;
text-align: center;
}
.auth-box form {
display: flex;
flex-direction: column;
align-items: center;
}
.login-icon-large {
color: var(--primary);
margin-bottom: 20px;
.auth-box .toggle-link {
margin-top: 1rem;
text-align: center;
font-size: 0.9rem;
}
.login-title {
font-family: var(--font-display);
font-size: 20px;
font-weight: 600;
margin-bottom: 8px;
.form-group {
margin-bottom: 1rem;
}
.login-subtitle {
.form-group label {
display: block;
margin-bottom: 0.5rem;
color: var(--text-secondary);
margin-bottom: 24px;
font-size: 13px;
}
.login-instruction {
background: rgba(255, 255, 255, 0.01);
border: 1px solid var(--card-border);
padding: 12px;
border-radius: 8px;
font-size: 12px;
color: var(--text-secondary);
margin-top: 20px;
line-height: 1.5;
}
.login-instruction code {
color: var(--secondary);
font-family: monospace;
background: rgba(0, 0, 0, 0.2);
padding: 1px 4px;
border-radius: 3px;
font-size: 0.85rem;
}
+69
View File
@@ -0,0 +1,69 @@
import React, { useState } from 'react';
import { useNavigate } from 'react-router-dom';
export default function Auth() {
const [isLogin, setIsLogin] = useState(true);
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [firstName, setFirstName] = useState('');
const [error, setError] = useState('');
const navigate = useNavigate();
const handleSubmit = async (e) => {
e.preventDefault();
setError('');
const url = isLogin ? '/api/auth/login' : '/api/auth/register';
const payload = isLogin ? { email, password } : { email, password, first_name: firstName };
try {
const res = await fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload)
});
const data = await res.json();
if (!res.ok) {
throw new Error(data.error || 'Ошибка авторизации');
}
localStorage.setItem('token', data.token);
localStorage.setItem('user', JSON.stringify(data.user));
navigate('/');
} catch (err) {
setError(err.message);
}
};
return (
<div className="auth-container">
<div className="auth-box">
<h2>{isLogin ? 'Вход в систему' : 'Регистрация'}</h2>
{error && <div style={{ color: 'var(--danger)', marginBottom: '1rem', textAlign: 'center' }}>{error}</div>}
<form onSubmit={handleSubmit}>
{!isLogin && (
<div className="form-group">
<label>Имя</label>
<input type="text" value={firstName} onChange={e => setFirstName(e.target.value)} required />
</div>
)}
<div className="form-group">
<label>Email</label>
<input type="email" value={email} onChange={e => setEmail(e.target.value)} required />
</div>
<div className="form-group">
<label>Пароль</label>
<input type="password" value={password} onChange={e => setPassword(e.target.value)} required />
</div>
<button type="submit">{isLogin ? 'Войти' : 'Зарегистрироваться'}</button>
</form>
<div className="toggle-link">
<a href="#" onClick={(e) => { e.preventDefault(); setIsLogin(!isLogin); }}>
{isLogin ? 'Нет аккаунта? Зарегистрироваться' : 'Уже есть аккаунт? Войти'}
</a>
</div>
</div>
</div>
);
}
+59
View File
@@ -0,0 +1,59 @@
import React, { useEffect, useState } from 'react';
import { Link } from 'react-router-dom';
export default function Dashboard() {
const [data, setData] = useState(null);
useEffect(() => {
const fetchProfile = async () => {
const token = localStorage.getItem('token');
try {
const res = await fetch('/api/user/profile', {
headers: { 'Authorization': `Bearer ${token}` }
});
if (res.ok) {
const json = await res.json();
setData(json);
}
} catch (err) {
console.error(err);
}
};
fetchProfile();
}, []);
if (!data) return <div>Загрузка...</div>;
return (
<div>
<div className="page-header">
<h1>Сводка</h1>
<p style={{ color: 'var(--text-secondary)' }}>Добро пожаловать, {data.user.first_name || data.user.email}</p>
</div>
<div className="dashboard-grid">
<div className="card stat-card">
<h3>Текущий Баланс</h3>
<div className="value">{data.balance.toFixed(2)} ₽</div>
</div>
<div className="card stat-card">
<h3>Всего Доходов</h3>
<div className="value income">+{data.totalIncome.toFixed(2)} ₽</div>
</div>
<div className="card stat-card">
<h3>Всего Расходов</h3>
<div className="value expense">-{data.totalExpense.toFixed(2)} ₽</div>
</div>
</div>
<div className="card">
<h3>Быстрые действия</h3>
<div style={{ display: 'flex', gap: '1rem', marginTop: '1rem' }}>
<Link to="/transactions"><button>Все Транзакции</button></Link>
<Link to="/debts"><button className="secondary">Мои Долги</button></Link>
<Link to="/incomes"><button className="secondary">Регулярные Доходы</button></Link>
</div>
</div>
</div>
);
}
+87
View File
@@ -0,0 +1,87 @@
import React, { useEffect, useState } from 'react';
export default function Debts() {
const [debts, setDebts] = useState([]);
const [personName, setPersonName] = useState('');
const [amount, setAmount] = useState('');
const [type, setType] = useState('owe');
const [dueDate, setDueDate] = useState('');
const fetchDebts = async () => {
const token = localStorage.getItem('token');
const res = await fetch('/api/debts', { headers: { 'Authorization': `Bearer ${token}` } });
if (res.ok) setDebts(await res.json());
};
useEffect(() => { fetchDebts(); }, []);
const handleSubmit = async (e) => {
e.preventDefault();
const token = localStorage.getItem('token');
await fetch('/api/debts', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` },
body: JSON.stringify({ person_name: personName, amount, type, due_date: dueDate })
});
setPersonName(''); setAmount(''); fetchDebts();
};
const handlePay = async (id) => {
const token = localStorage.getItem('token');
await fetch(`/api/debts/${id}/pay`, { method: 'PUT', headers: { 'Authorization': `Bearer ${token}` } });
fetchDebts();
};
return (
<div>
<div className="page-header">
<h1>Мои Долги</h1>
</div>
<div className="card">
<h3>Добавить Долг</h3>
<form onSubmit={handleSubmit} style={{ display: 'flex', gap: '1rem', flexWrap: 'wrap', marginTop: '1rem' }}>
<select value={type} onChange={e => setType(e.target.value)} style={{ width: '200px' }}>
<option value="owe">Я должен кому-то</option>
<option value="owed">Мне должны</option>
</select>
<input type="text" placeholder="Имя человека" value={personName} onChange={e => setPersonName(e.target.value)} required style={{ flex: 1 }} />
<input type="number" placeholder="Сумма" value={amount} onChange={e => setAmount(e.target.value)} required style={{ width: '150px' }} />
<input type="date" value={dueDate} onChange={e => setDueDate(e.target.value)} style={{ width: '150px' }} title="Дата возврата" />
<button type="submit">Сохранить</button>
</form>
</div>
<div className="card">
<table>
<thead>
<tr>
<th>Кто/Кому</th>
<th>Тип</th>
<th>Сумма</th>
<th>Дата возврата</th>
<th>Статус</th>
<th>Действия</th>
</tr>
</thead>
<tbody>
{debts.map(d => (
<tr key={d.id}>
<td>{d.person_name}</td>
<td>{d.type === 'owe' ? <span style={{ color: 'var(--danger)' }}>Я должен</span> : <span style={{ color: 'var(--success)' }}>Мне должны</span>}</td>
<td style={{ fontWeight: 'bold' }}>{d.amount} ₽</td>
<td>{d.due_date || 'Без срока'}</td>
<td>{d.status === 'paid' ? '✅ Оплачено' : '⏳ Ожидается'}</td>
<td>
{d.status === 'pending' && (
<button className="secondary" onClick={() => handlePay(d.id)}>Отметить оплаченным</button>
)}
</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
);
}
+77
View File
@@ -0,0 +1,77 @@
import React, { useEffect, useState } from 'react';
export default function Incomes() {
const [incomes, setIncomes] = useState([]);
const [sourceName, setSourceName] = useState('');
const [amount, setAmount] = useState('');
const [dayOfMonth, setDayOfMonth] = useState('1');
const fetchIncomes = async () => {
const token = localStorage.getItem('token');
const res = await fetch('/api/incomes', { headers: { 'Authorization': `Bearer ${token}` } });
if (res.ok) setIncomes(await res.json());
};
useEffect(() => { fetchIncomes(); }, []);
const handleSubmit = async (e) => {
e.preventDefault();
const token = localStorage.getItem('token');
await fetch('/api/incomes', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` },
body: JSON.stringify({ source_name: sourceName, amount, day_of_month: dayOfMonth })
});
setSourceName(''); setAmount(''); fetchIncomes();
};
const handleDelete = async (id) => {
const token = localStorage.getItem('token');
await fetch(`/api/incomes/${id}`, { method: 'DELETE', headers: { 'Authorization': `Bearer ${token}` } });
fetchIncomes();
};
return (
<div>
<div className="page-header">
<h1>Регулярные Доходы</h1>
</div>
<div className="card">
<h3>Добавить Зарплату / Регулярный доход</h3>
<p style={{ color: 'var(--text-secondary)', marginBottom: '1rem' }}>
Укажите день месяца, и система будет автоматически начислять эту сумму каждый месяц.
</p>
<form onSubmit={handleSubmit} style={{ display: 'flex', gap: '1rem', flexWrap: 'wrap' }}>
<input type="text" placeholder="Источник (напр. Зарплата)" value={sourceName} onChange={e => setSourceName(e.target.value)} required style={{ flex: 1 }} />
<input type="number" placeholder="Сумма" value={amount} onChange={e => setAmount(e.target.value)} required style={{ width: '150px' }} />
<input type="number" min="1" max="31" placeholder="День месяца" value={dayOfMonth} onChange={e => setDayOfMonth(e.target.value)} required style={{ width: '150px' }} title="День месяца (1-31)" />
<button type="submit">Добавить</button>
</form>
</div>
<div className="card">
<table>
<thead>
<tr>
<th>Источник</th>
<th>Сумма</th>
<th>День начисления</th>
<th>Действия</th>
</tr>
</thead>
<tbody>
{incomes.map(inc => (
<tr key={inc.id}>
<td>{inc.source_name}</td>
<td style={{ color: 'var(--success)', fontWeight: 'bold' }}>+{inc.amount} ₽</td>
<td>{inc.day_of_month} число</td>
<td><button className="danger" onClick={() => handleDelete(inc.id)}>Удалить</button></td>
</tr>
))}
</tbody>
</table>
</div>
</div>
);
}
+46
View File
@@ -0,0 +1,46 @@
import React, { useState } from 'react';
export default function Settings() {
const [code, setCode] = useState('');
const generateCode = async () => {
const token = localStorage.getItem('token');
const res = await fetch('/api/auth/generate-link-code', {
method: 'POST',
headers: { 'Authorization': `Bearer ${token}` }
});
if (res.ok) {
const data = await res.json();
setCode(data.code);
}
};
return (
<div>
<div className="page-header">
<h1>Настройки</h1>
</div>
<div className="card">
<h3>Привязка Telegram</h3>
<p style={{ color: 'var(--text-secondary)', marginBottom: '1rem', maxWidth: '600px' }}>
Чтобы получать уведомления о подписках и долгах, привяжите свой аккаунт к Telegram-боту.
Нажмите кнопку ниже, чтобы сгенерировать временный код, и отправьте его боту.
</p>
<button onClick={generateCode}>Сгенерировать код</button>
{code && (
<div style={{ marginTop: '1.5rem', padding: '1rem', background: 'rgba(0, 122, 204, 0.1)', border: '1px solid var(--accent-color)', borderRadius: '6px' }}>
<p>Ваш код привязки:</p>
<h2 style={{ letterSpacing: '2px', color: 'var(--accent-color)', margin: '0.5rem 0' }}>{code}</h2>
<p style={{ fontSize: '0.9rem', color: 'var(--text-secondary)' }}>
Скопируйте этот код и отправьте боту команду: <br/>
<code style={{ background: 'var(--bg-primary)', padding: '0.2rem 0.4rem', borderRadius: '4px', marginTop: '0.5rem', display: 'inline-block' }}>/link {code}</code>
</p>
</div>
)}
</div>
</div>
);
}
+87
View File
@@ -0,0 +1,87 @@
import React, { useEffect, useState } from 'react';
export default function Transactions() {
const [transactions, setTransactions] = useState([]);
const [type, setType] = useState('expense');
const [amount, setAmount] = useState('');
const [category, setCategory] = useState('');
const [description, setDescription] = useState('');
const [date, setDate] = useState(new Date().toISOString().slice(0, 10));
const fetchTxs = async () => {
const token = localStorage.getItem('token');
const res = await fetch('/api/transactions', { headers: { 'Authorization': `Bearer ${token}` } });
if (res.ok) setTransactions(await res.json());
};
useEffect(() => { fetchTxs(); }, []);
const handleSubmit = async (e) => {
e.preventDefault();
const token = localStorage.getItem('token');
await fetch('/api/transactions', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` },
body: JSON.stringify({ type, amount, category, description, date })
});
setAmount(''); setCategory(''); setDescription(''); fetchTxs();
};
const handleDelete = async (id) => {
const token = localStorage.getItem('token');
await fetch(`/api/transactions/${id}`, { method: 'DELETE', headers: { 'Authorization': `Bearer ${token}` } });
fetchTxs();
};
return (
<div>
<div className="page-header">
<h1>Транзакции</h1>
</div>
<div className="card">
<h3>Добавить Транзакцию</h3>
<form onSubmit={handleSubmit} style={{ display: 'flex', gap: '1rem', flexWrap: 'wrap', marginTop: '1rem' }}>
<select value={type} onChange={e => setType(e.target.value)} style={{ width: '150px' }}>
<option value="expense">Расход</option>
<option value="income">Доход</option>
</select>
<input type="number" placeholder="Сумма" value={amount} onChange={e => setAmount(e.target.value)} required style={{ width: '150px' }} />
<input type="text" placeholder="Категория" value={category} onChange={e => setCategory(e.target.value)} required style={{ width: '200px' }} />
<input type="text" placeholder="Описание (необязательно)" value={description} onChange={e => setDescription(e.target.value)} style={{ flex: 1 }} />
<input type="date" value={date} onChange={e => setDate(e.target.value)} required style={{ width: '150px' }} />
<button type="submit">Добавить</button>
</form>
</div>
<div className="card">
<table>
<thead>
<tr>
<th>Дата</th>
<th>Тип</th>
<th>Категория</th>
<th>Описание</th>
<th>Сумма</th>
<th>Действия</th>
</tr>
</thead>
<tbody>
{transactions.map(tx => (
<tr key={tx.id}>
<td>{tx.date}</td>
<td>{tx.type === 'income' ? <span style={{ color: 'var(--success)' }}>Доход</span> : <span style={{ color: 'var(--danger)' }}>Расход</span>}</td>
<td>{tx.category}</td>
<td>{tx.description}</td>
<td style={{ color: tx.type === 'income' ? 'var(--success)' : 'var(--danger)', fontWeight: 'bold' }}>
{tx.type === 'income' ? '+' : '-'}{tx.amount} ₽
</td>
<td><button className="danger" onClick={() => handleDelete(tx.id)}>Удалить</button></td>
</tr>
))}
</tbody>
</table>
</div>
</div>
);
}
+8
View File
@@ -4,4 +4,12 @@ import react from '@vitejs/plugin-react'
// https://vite.dev/config/
export default defineConfig({
plugins: [react()],
server: {
proxy: {
'/api': {
target: 'http://localhost:5000',
changeOrigin: true
}
}
}
})