fix(shared): tag filter SQL precedence, balance cards filter by tag
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user