mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-03 09:38:54 +00:00
fix(costs): tell the phone when the settlement did not load
The mobile Costs tab swallowed a failed settlement request, and the final budget card then filled every traveler's row from the empty fallback: "0.00" for everyone, which reads as "the trip cost nobody anything". The desktop panel already keeps a settlementError flag and prints its notice instead of a number; the mobile tab now does the same in the final budget card.
This commit is contained in:
@@ -58,8 +58,13 @@ export default function MCostsTab({ planner, shell }: MTabScreenProps) {
|
||||
const ctx: CostsCtx = useMemo(() => ({ me, tripCurrency, convert }), [me, tripCurrency, convert])
|
||||
|
||||
const [settlement, setSettlement] = useState<CostsSettlementResponse | null>(null)
|
||||
// A failed settlement read leaves `settlement` null, and the final budget would
|
||||
// read that as "the trip cost nobody anything", a claim we cannot make.
|
||||
const [settlementError, setSettlementError] = useState(false)
|
||||
const loadSettlement = useCallback(() => {
|
||||
budgetApi.settlement(tripId, base).then(setSettlement).catch(() => {})
|
||||
budgetApi.settlement(tripId, base)
|
||||
.then(s => { setSettlement(s); setSettlementError(false) })
|
||||
.catch(() => setSettlementError(true))
|
||||
}, [tripId, base])
|
||||
|
||||
// Mirrors CostsPanel.tsx: items reload on trip change, settlement reloads on
|
||||
@@ -312,7 +317,9 @@ export default function MCostsTab({ planner, shell }: MTabScreenProps) {
|
||||
{/* Final budget — what the trip costs each traveler; the arithmetic opens on tap */}
|
||||
<div className="mt-2 rounded-2xl border border-[color:var(--m-rowbr)] bg-m-card p-[13px]">
|
||||
<div className="font-geist text-[0.625rem] font-bold uppercase tracking-[.09em] text-m-faint">{t('costs.finalBudget')}</div>
|
||||
{tripMembers.map(p => {
|
||||
{settlementError ? (
|
||||
<p className="py-[14px] text-center font-geist text-[0.71875rem] text-m-muted">{t('common.unknownError')}</p>
|
||||
) : tripMembers.map(p => {
|
||||
const row = finalBudgetFor(settlement?.finalBudgets || [], p)
|
||||
const open = expandedFinalId === p.id
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user