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:
+19
-1
@@ -13,6 +13,7 @@ import {
|
||||
type SplitPayment,
|
||||
} from "@/lib/hooks";
|
||||
import type { SharedTransactionRow } from "@/lib/queries";
|
||||
import { EditTransactionModal } from "@/components/edit-transaction-modal";
|
||||
|
||||
function formatDate(d: string) {
|
||||
return new Date(d).toLocaleDateString("en-AU", { day: "numeric", month: "short", year: "numeric" });
|
||||
@@ -264,6 +265,7 @@ export default function SharedPage() {
|
||||
const [addingParticipant, setAddingParticipant] = useState(false);
|
||||
const [paymentModal, setPaymentModal] = useState<{ id: number; name: string; balance: number } | null>(null);
|
||||
const [showHistory, setShowHistory] = useState<number | null>(null);
|
||||
const [editModal, setEditModal] = useState<SharedTransactionRow | null>(null);
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
@@ -352,6 +354,7 @@ export default function SharedPage() {
|
||||
<th className="text-left px-4 py-2 text-xs text-zinc-500 font-medium">Description</th>
|
||||
<th className="text-right px-4 py-2 text-xs text-zinc-500 font-medium">Amount</th>
|
||||
<th className="text-left px-4 py-2 text-xs text-zinc-500 font-medium">Splits</th>
|
||||
<th className="px-4 py-2"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -377,11 +380,19 @@ export default function SharedPage() {
|
||||
{splits.map((s) => (
|
||||
<span key={s.participant_id}
|
||||
className="inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs bg-zinc-800 text-zinc-300">
|
||||
{s.name} {s.share_percent}%
|
||||
{s.participant_id === me?.id ? "Me" : s.name} {s.share_percent}%
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</td>
|
||||
<td className="px-4 py-3">
|
||||
<button
|
||||
onClick={() => setEditModal(tx)}
|
||||
className="text-xs text-zinc-500 hover:text-zinc-200 px-2 py-0.5 rounded hover:bg-zinc-800 transition-colors"
|
||||
>
|
||||
Edit
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
@@ -399,6 +410,13 @@ export default function SharedPage() {
|
||||
onClose={() => setPaymentModal(null)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{editModal && (
|
||||
<EditTransactionModal
|
||||
transaction={editModal}
|
||||
onClose={() => setEditModal(null)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user