fix: Closed PO list filters are wrong for manager and submitter #21

Merged
shad0w merged 1 commit from claude/issue-6 into master 2026-06-18 22:10:26 +00:00
Showing only changes of commit a37ca068c2 - Show all commits

View file

@ -15,11 +15,12 @@ export default async function MyOrdersPage() {
const { role, id: userId } = session.user;
if (!["TECHNICAL", "MANNING", "MANAGER", "SUPERUSER"].includes(role)) redirect("/dashboard");
const isManager = role === "MANAGER" || role === "SUPERUSER";
const closed = await db.purchaseOrder.findMany({
where: {
submitterId: userId,
status: { in: ["MGR_APPROVED", "SENT_FOR_PAYMENT", "PAID_DELIVERED", "CLOSED", "REJECTED"] },
},
where: isManager
? { status: "CLOSED" }
: { submitterId: userId, status: "CLOSED" },
orderBy: { updatedAt: "desc" },
include: {
vessel: { select: { name: true } },