diff --git a/apps/csms/src/routes/transactions.ts b/apps/csms/src/routes/transactions.ts index 42f6ed2..fde8c46 100644 --- a/apps/csms/src/routes/transactions.ts +++ b/apps/csms/src/routes/transactions.ts @@ -2,6 +2,7 @@ import { Hono } from "hono"; import { and, desc, eq, isNull, isNotNull, sql } from "drizzle-orm"; import { useDrizzle } from "@/lib/db.js"; import { transaction, chargePoint, connector, idTag } from "@/db/schema.js"; +import { user } from "@/db/auth-schema.js"; import { ocppConnections } from "@/ocpp/handler.js"; import { OCPP_MESSAGE_TYPE } from "@/ocpp/types.js"; import type { HonoEnv } from "@/types/hono.ts"; @@ -47,10 +48,14 @@ app.get("/", async (c) => { transaction, chargePointIdentifier: chargePoint.chargePointIdentifier, connectorNumber: connector.connectorId, + idTagUserId: idTag.userId, + idTagUserName: user.name, }) .from(transaction) .leftJoin(chargePoint, eq(transaction.chargePointId, chargePoint.id)) .leftJoin(connector, eq(transaction.connectorId, connector.id)) + .leftJoin(idTag, eq(transaction.idTag, idTag.idTag)) + .leftJoin(user, eq(idTag.userId, user.id)) .where(whereClause) .orderBy(desc(transaction.startTimestamp)) .limit(limit) @@ -61,6 +66,8 @@ app.get("/", async (c) => { ...r.transaction, chargePointIdentifier: r.chargePointIdentifier, connectorNumber: r.connectorNumber, + idTagUserId: r.idTagUserId, + idTagUserName: r.idTagUserName, energyWh: r.transaction.stopMeterValue != null ? r.transaction.stopMeterValue - r.transaction.startMeterValue diff --git a/apps/web/app/dashboard/page.tsx b/apps/web/app/dashboard/page.tsx index ea4baac..7f23dca 100644 --- a/apps/web/app/dashboard/page.tsx +++ b/apps/web/app/dashboard/page.tsx @@ -130,10 +130,22 @@ function RecentTransactions({ txns }: { txns: Transaction[] }) { #{tx.connectorNumber} )}

-

{tx.idTag}

+

+ {tx.idTag} + {tx.idTagUserId && ( + <> + ยท + {tx.idTagUserName ?? tx.idTagUserId} + ({tx.idTagUserId.slice(0, 8)}) + + )} +

-

{kwh}

+

+ {kwh} + kWh +

{amount}

diff --git a/apps/web/lib/api.ts b/apps/web/lib/api.ts index 6365310..3941d60 100644 --- a/apps/web/lib/api.ts +++ b/apps/web/lib/api.ts @@ -101,6 +101,8 @@ export type Transaction = { connectorNumber: number | null; idTag: string; idTagStatus: string | null; + idTagUserId: string | null; + idTagUserName: string | null; startTimestamp: string; stopTimestamp: string | null; startMeterValue: number | null;