fix(participants): show Me contextually per logged-in user
Participant id=1 was named "Me" in the DB, causing Sonu and other users to see "Me" referring to Siddharth when viewing splits and shared expenses. - Rename participant id=1 from "Me" to "Siddharth" in the DB - /api/participants now substitutes "Me" for whichever participant matches the current user, so the label is always relative to the viewer - split-modal: default split uses currentUser.id instead of name === "Me" - transactions/page: filter and display logic uses participant ID not name - shared/page: split chips show "Me" when participant_id === current user Also includes add-transaction-modal tags support (pre-existing staged change).
This commit is contained in:
@@ -1,11 +1,17 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { prisma } from "@/lib/db";
|
||||
import { queryRaw } from "@/lib/db";
|
||||
import { getCurrentUser } from "@/lib/auth";
|
||||
|
||||
export async function GET() {
|
||||
export async function GET(req: NextRequest) {
|
||||
const user = await getCurrentUser(req);
|
||||
const participants = await prisma.participants.findMany({
|
||||
orderBy: { name: "asc" },
|
||||
});
|
||||
if (user) {
|
||||
return NextResponse.json(
|
||||
participants.map((p) => (p.id === user.id ? { ...p, name: "Me" } : p))
|
||||
);
|
||||
}
|
||||
return NextResponse.json(participants);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user