fix(payment): participantId stuck as empty string when participants load async

This commit is contained in:
2026-03-14 21:33:25 +11:00
parent d53d3106f2
commit ef73a9cea0
+6
View File
@@ -221,6 +221,12 @@ function MarkAsPaymentModal({
const others = participants.filter((p) => p.name !== "Me"); const others = participants.filter((p) => p.name !== "Me");
const [participantId, setParticipantId] = useState<number | "">(others[0]?.id ?? ""); const [participantId, setParticipantId] = useState<number | "">(others[0]?.id ?? "");
useEffect(() => {
if (participantId === "" && others.length > 0) {
setParticipantId(others[0].id);
}
}, [others]);
// For credits/refunds the default direction is "they paid me" // For credits/refunds the default direction is "they paid me"
const [direction, setDirection] = useState<"received" | "sent">( const [direction, setDirection] = useState<"received" | "sent">(
SPEND_TYPES.has(transaction.transaction_type) ? "sent" : "received" SPEND_TYPES.has(transaction.transaction_type) ? "sent" : "received"