Merge pull request #1 from Arrelin/feature/sidebar

fix error after changing back to /api + feature/limits
This commit is contained in:
Arrelin
2025-12-19 10:38:22 +03:00
committed by GitHub
3 changed files with 75 additions and 13 deletions

View File

@@ -199,6 +199,14 @@ export default function FamilyView() {
return Math.max(0, Math.min(100, (remaining / limit) * 100)); return Math.max(0, Math.min(100, (remaining / limit) * 100));
}; };
const getTotalLimit = () => {
return categories.reduce((sum, cat) => sum + parseFloat(cat.limit_amount.toString()), 0);
};
const getTotalRemaining = () => {
return Array.from(remainingLimits.values()).reduce((sum, val) => sum + val, 0);
};
const formatDate = (dateString: string) => { const formatDate = (dateString: string) => {
let dateStr = dateString; let dateStr = dateString;
if (!dateStr.endsWith('Z') && !dateStr.includes('+')) { if (!dateStr.endsWith('Z') && !dateStr.includes('+')) {
@@ -229,12 +237,25 @@ export default function FamilyView() {
<div className="inline-flex p-4 bg-white/20 backdrop-blur-md rounded-2xl mb-4"> <div className="inline-flex p-4 bg-white/20 backdrop-blur-md rounded-2xl mb-4">
<Wallet className="w-12 h-12 text-white" /> <Wallet className="w-12 h-12 text-white" />
</div> </div>
<h1 className="text-4xl sm:text-5xl font-bold text-white mb-2"> <h1 className="text-4xl sm:text-5xl font-bold text-white mb-6">
{selectedFamily?.name || 'Семья'} {selectedFamily?.name || 'Семья'}
</h1> </h1>
<p className="text-purple-100 text-base sm:text-lg"> <div className="max-w-2xl mx-auto glass-effect rounded-2xl shadow-lg p-5">
Управление категориями и расходами <div className="grid grid-cols-2 gap-4">
</p> <div className="text-center">
<p className="text-gray-600 font-medium text-sm mb-2">Общий лимит</p>
<p className="text-2xl sm:text-3xl font-bold text-gray-900">
{getTotalLimit().toFixed(2)}
</p>
</div>
<div className="text-center border-l-2 border-gray-300">
<p className="text-gray-600 font-medium text-sm mb-2">Общий остаток</p>
<p className="text-2xl sm:text-3xl font-bold text-gray-900">
{getTotalRemaining().toFixed(2)}
</p>
</div>
</div>
</div>
</div> </div>
</div> </div>

View File

@@ -6,15 +6,7 @@ export default defineConfig({
server: { server: {
port: 5173, port: 5173,
proxy: { proxy: {
'/families': { '/api': {
target: 'http://localhost:8080',
changeOrigin: true,
},
'/login': {
target: 'http://localhost:8080',
changeOrigin: true,
},
'/logout': {
target: 'http://localhost:8080', target: 'http://localhost:8080',
changeOrigin: true, changeOrigin: true,
} }

49
setup-ssl.ps1 Normal file
View File

@@ -0,0 +1,49 @@
# Setup SSL Certificate for Family Budget
# Run this script in PowerShell as Administrator
$ErrorActionPreference = "Stop"
$DOMAIN = "family-budget.duckdns.org"
$EMAIL = "your@email.com" # CHANGE THIS!
Write-Host "=== Setting up SSL for $DOMAIN ===" -ForegroundColor Green
# Change to project directory
Set-Location C:\deploy\family_budget
Write-Host "`n1. Stopping certbot..." -ForegroundColor Yellow
docker compose -f docker-compose.prod.yml stop certbot
Write-Host "`n2. Creating self-signed certificate..." -ForegroundColor Yellow
docker compose -f docker-compose.prod.yml run --rm --entrypoint sh certbot -c @"
mkdir -p /etc/letsencrypt/live/$DOMAIN && \
openssl req -x509 -nodes -newkey rsa:2048 -days 365 \
-keyout /etc/letsencrypt/live/$DOMAIN/privkey.pem \
-out /etc/letsencrypt/live/$DOMAIN/fullchain.pem \
-subj '/CN=$DOMAIN'
"@
Write-Host "`n3. Updating nginx configuration..." -ForegroundColor Yellow
$sslConfig = Get-Content nginx\conf.d\app-ssl.conf.template -Raw
$sslConfig = $sslConfig -replace '\$\{DOMAIN\}', $DOMAIN
$sslConfig | Out-File -FilePath nginx\conf.d\app-ssl.conf -Encoding UTF8
# Remove HTTP config
Remove-Item nginx\conf.d\app.conf -ErrorAction SilentlyContinue
Write-Host "`n4. Restarting nginx..." -ForegroundColor Yellow
docker compose -f docker-compose.prod.yml restart nginx
Write-Host "`n5. Checking nginx status..." -ForegroundColor Yellow
docker compose -f docker-compose.prod.yml ps nginx
Write-Host "`n=== HTTPS Setup Complete! ===" -ForegroundColor Green
Write-Host "`nYour site is now available at: https://$DOMAIN" -ForegroundColor Cyan
Write-Host "`nNote: This is a self-signed certificate. Browser will show a warning." -ForegroundColor Yellow
Write-Host "You can click 'Advanced' -> 'Proceed to site' to access." -ForegroundColor Yellow
Write-Host "`n=== To get a real Let's Encrypt certificate later: ===" -ForegroundColor Magenta
Write-Host "Run in Git Bash:" -ForegroundColor White
Write-Host " export DOMAIN=$DOMAIN" -ForegroundColor Gray
Write-Host " export EMAIL=$EMAIL" -ForegroundColor Gray
Write-Host " bash init-letsencrypt.sh" -ForegroundColor Gray