Skip to content

Commit ac13c40

Browse files
committed
feat(admin/mosques): surface submitter on pending rows
listMosquesFn now left-joins the user table so each row carries submitterEmail and submitterName alongside createdBy. The mosques list shows an amber "Submitted by …" line under the name only on pending rows so approved admin-created rows stay clean. Left join because createdBy can become null after a user account is deleted.
1 parent 4cff6ae commit ac13c40

2 files changed

Lines changed: 34 additions & 1 deletion

File tree

apps/admin/src/features/mosques/server/mosques.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { db } from "@qibla/db";
2+
import { user } from "@qibla/db/schema/auth";
23
import { mosque } from "@qibla/db/schema/mosque";
34
import { createServerFn } from "@tanstack/react-start";
45
import { and, desc, eq, ilike, or, sql } from "drizzle-orm";
@@ -34,9 +35,36 @@ export const listMosquesFn = createServerFn({ method: "GET" })
3435

3536
const where = conditions.length ? and(...conditions) : undefined;
3637

38+
// Left join the user table so the admin UI can label pending rows with
39+
// the submitter's email. Left join because admin-created mosques may
40+
// have createdBy null after the submitter account is deleted.
3741
const rows = await db
38-
.select()
42+
.select({
43+
id: mosque.id,
44+
name: mosque.name,
45+
subtitle: mosque.subtitle,
46+
about: mosque.about,
47+
address: mosque.address,
48+
street: mosque.street,
49+
area: mosque.area,
50+
city: mosque.city,
51+
lat: mosque.lat,
52+
lng: mosque.lng,
53+
rating: mosque.rating,
54+
reviewsCount: mosque.reviewsCount,
55+
open: mosque.open,
56+
tags: mosque.tags,
57+
facilities: mosque.facilities,
58+
photos: mosque.photos,
59+
status: mosque.status,
60+
createdBy: mosque.createdBy,
61+
createdAt: mosque.createdAt,
62+
updatedAt: mosque.updatedAt,
63+
submitterEmail: user.email,
64+
submitterName: user.name,
65+
})
3966
.from(mosque)
67+
.leftJoin(user, eq(mosque.createdBy, user.id))
4068
.where(where)
4169
.orderBy(desc(mosque.createdAt))
4270
.limit(pageSize)

apps/admin/src/routes/_admin/mosques/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,11 @@ function MosquesPage() {
170170
{m.subtitle}
171171
</div>
172172
)}
173+
{m.status === "pending" && m.submitterEmail && (
174+
<div className="text-xs text-amber-700">
175+
Submitted by {m.submitterName ?? m.submitterEmail}
176+
</div>
177+
)}
173178
</TableCell>
174179
<TableCell onClick={() => setEditId(m.id)}>
175180
{m.area ?? "—"}

0 commit comments

Comments
 (0)