fix(shared): tag filter SQL precedence, balance cards filter by tag

This commit is contained in:
2026-03-14 21:30:33 +11:00
parent 02ac136e19
commit d53d3106f2
4 changed files with 27 additions and 14 deletions
+3 -1
View File
@@ -6,6 +6,8 @@ export async function GET(req: NextRequest) {
const user = await getCurrentUser(req);
if (!user) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
const balances = await getParticipantBalances(user.id);
const tagParam = req.nextUrl.searchParams.get("tag_ids");
const tagIds = tagParam ? tagParam.split(",").map(Number).filter(Boolean) : undefined;
const balances = await getParticipantBalances(user.id, tagIds);
return NextResponse.json(balances);
}
+1 -1
View File
@@ -259,7 +259,7 @@ function PaymentHistory({ participantId, currentUserId }: { participantId: numbe
export default function SharedPage() {
const [tagIds, setTagIds] = useState<string[]>([]);
const { data: transactions = [], isLoading: txLoading } = useSharedTransactions(tagIds);
const { data: balances = [], isLoading: balLoading } = useParticipantBalances();
const { data: balances = [], isLoading: balLoading } = useParticipantBalances(tagIds);
const { data: me } = useCurrentUser();
const [addingParticipant, setAddingParticipant] = useState(false);
const [paymentModal, setPaymentModal] = useState<{ id: number; name: string; balance: number } | null>(null);