From f0813894a8e5ddf3d19d0da894bfa31a53a5a8f6 Mon Sep 17 00:00:00 2001 From: Kacper Date: Sat, 11 Jul 2026 00:51:33 +0200 Subject: [PATCH] =?UTF-8?q?v1.0.2=20Wygl=C4=85d?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/nginx.conf | 6 ++++++ frontend/src/pages/Dashboard.jsx | 13 +++++------- frontend/src/pages/Settlements.jsx | 33 ++++++++++++++++++++++-------- frontend/src/styles.css | 11 +++++++++- frontend/vite.config.js | 2 ++ 5 files changed, 48 insertions(+), 17 deletions(-) diff --git a/frontend/nginx.conf b/frontend/nginx.conf index e3fc9a2..4cf67d9 100644 --- a/frontend/nginx.conf +++ b/frontend/nginx.conf @@ -15,6 +15,12 @@ server { try_files $uri $uri/ /index.html; } + # Always revalidate the HTML shell so it never points at a stale, no-longer-existing + # hashed JS/CSS bundle after a new deploy. + location = /index.html { + add_header Cache-Control "no-cache"; + } + location ~* \.(?:js|css|png|jpg|jpeg|svg|woff2?)$ { expires 7d; add_header Cache-Control "public"; diff --git a/frontend/src/pages/Dashboard.jsx b/frontend/src/pages/Dashboard.jsx index f898a78..4725e7d 100644 --- a/frontend/src/pages/Dashboard.jsx +++ b/frontend/src/pages/Dashboard.jsx @@ -1,4 +1,5 @@ -import { useBalance, useSummary, useSettleUp } from '../api/queries.js'; +import { useNavigate } from 'react-router-dom'; +import { useBalance, useSummary } from '../api/queries.js'; import { useHouseholdContext } from '../household/HouseholdContext.jsx'; import CategoryPieChart from '../components/CategoryPieChart.jsx'; import Icon from '../components/Icon.jsx'; @@ -8,10 +9,10 @@ function memberName(members, id) { } export default function Dashboard() { + const navigate = useNavigate(); const { activeHousehold: household } = useHouseholdContext(); const { data: balance } = useBalance(); const { data: summary } = useSummary(); - const settleUp = useSettleUp(); const members = household?.members || []; const currency = household?.currency || 'PLN'; @@ -40,12 +41,8 @@ export default function Dashboard() {

))} - )} diff --git a/frontend/src/pages/Settlements.jsx b/frontend/src/pages/Settlements.jsx index a584c39..cbfa424 100644 --- a/frontend/src/pages/Settlements.jsx +++ b/frontend/src/pages/Settlements.jsx @@ -1,4 +1,4 @@ -import { useEffect, useState } from 'react'; +import { useEffect, useRef, useState } from 'react'; import { useHouseholdContext } from '../household/HouseholdContext.jsx'; import { useBalance, useSettleUp, useSettlements, useCreateManualSettlement } from '../api/queries.js'; import PayerToggle from '../components/PayerToggle.jsx'; @@ -26,12 +26,23 @@ export default function Settlements() { const [error, setError] = useState(''); const [success, setSuccess] = useState(false); const [editingSettlement, setEditingSettlement] = useState(null); + const initializedRef = useRef(false); + // Prefill the form from the first suggested transfer as soon as the balance is + // known, so the user starts from "who actually owes whom" instead of a blank guess. useEffect(() => { - if (!fromUserId && members[0]) setFromUserId(members[0].id); - if (!toUserId && members[1]) setToUserId(members[1].id); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [members.length]); + if (initializedRef.current || !balance) return; + initializedRef.current = true; + const suggestion = balance.transactions?.[0]; + if (suggestion) { + setFromUserId(suggestion.from); + setToUserId(suggestion.to); + setAmount(String(suggestion.amount)); + } else if (members[0] && members[1]) { + setFromUserId(members[0].id); + setToUserId(members[1].id); + } + }, [balance, members]); const toOptions = members.filter((m) => m.id !== fromUserId); @@ -43,6 +54,12 @@ export default function Settlements() { } } + function applySuggestion(tx) { + setFromUserId(tx.from); + setToUserId(tx.to); + setAmount(String(tx.amount)); + } + async function handleSubmit(e) { e.preventDefault(); setError(''); @@ -77,12 +94,12 @@ export default function Settlements() { ) : ( <> -

Sugerowane rozliczenie

+

Sugerowane rozliczenie (dotknij, aby wypełnić formularz poniżej)

{balance.transactions.map((tx, i) => ( -

+ ))}