fix: enforce public contrast and audit rank errors
This commit is contained in:
1 parent
e1381c0f40
commit
b695a33ead
12 files changed
+184
-29
No files matched your search
+10
-24
@@ -2,6 +2,7 @@ import { getTranslations } from "next-intl/server";
|
||||
import { ScrollText } from "lucide-react";
|
||||
import { StatusCard } from "@/components/admin/dashboard";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { buildStaffActivityWhere } from "@/lib/admin/log-filters";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
@@ -14,7 +15,7 @@ function fromDate(d: Date | null | undefined): string {
|
||||
export default async function AdminStaffActivities({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: Promise<{ q?: string; page?: string; staffId?: string; action?: string }>;
|
||||
searchParams: Promise<{ q?: string; page?: string; staffId?: string; action?: string; authorization?: string }>;
|
||||
}) {
|
||||
const t = await getTranslations("pages.admin.logs");
|
||||
|
||||
@@ -23,27 +24,8 @@ export default async function AdminStaffActivities({
|
||||
const page = Math.max(1, Number(sp.page ?? "1") || 1);
|
||||
const staffId = sp.staffId ? Number(sp.staffId) : null;
|
||||
const action = sp.action ?? null;
|
||||
|
||||
let whereClause = {};
|
||||
if (q) {
|
||||
whereClause = {
|
||||
OR: [{ action: { contains: q } }, { description: { contains: q } }, { ipAddress: { contains: q } }],
|
||||
};
|
||||
}
|
||||
|
||||
if (staffId) {
|
||||
whereClause = {
|
||||
...whereClause,
|
||||
userId: BigInt(staffId),
|
||||
};
|
||||
}
|
||||
|
||||
if (action) {
|
||||
whereClause = {
|
||||
...whereClause,
|
||||
action: { contains: action },
|
||||
};
|
||||
}
|
||||
const authorizationOnly = sp.authorization === "1";
|
||||
const whereClause = buildStaffActivityWhere({ q, staffId, action, authorizationOnly });
|
||||
|
||||
const activities = await prisma.staffActivities
|
||||
.findMany({
|
||||
@@ -111,6 +93,10 @@ export default async function AdminStaffActivities({
|
||||
placeholder={t("searchPlaceholder")}
|
||||
className="flex-1 min-w-[200px]"
|
||||
/>
|
||||
<label className="flex items-center gap-2 text-sm">
|
||||
<input type="checkbox" name="authorization" value="1" defaultChecked={authorizationOnly} />
|
||||
Authorization errors
|
||||
</label>
|
||||
<input
|
||||
name="staffId"
|
||||
defaultValue={staffId?.toString()}
|
||||
@@ -127,7 +113,7 @@ export default async function AdminStaffActivities({
|
||||
<button type="submit" className="btn btn-primary">
|
||||
{t("filter")}
|
||||
</button>
|
||||
{(q || staffId || action) && (
|
||||
{(q || staffId || action || authorizationOnly) && (
|
||||
<a href="/admin/logs" className="btn btn-outline">
|
||||
{t("clearFilters")}
|
||||
</a>
|
||||
@@ -195,7 +181,7 @@ export default async function AdminStaffActivities({
|
||||
<>
|
||||
{" · "}
|
||||
<a
|
||||
href={`/admin/logs?q=${encodeURIComponent(q)}&staffId=${staffId || ""}&action=${action || ""}&page=${page + 1}`}
|
||||
href={`/admin/logs?q=${encodeURIComponent(q)}&staffId=${staffId || ""}&action=${action || ""}&authorization=${authorizationOnly ? "1" : ""}&page=${page + 1}`}
|
||||
>
|
||||
{t("next")} →
|
||||
</a>
|
||||
|
||||
+9
-2
@@ -56,6 +56,7 @@
|
||||
--button-danger-hover-color: #dc2626;
|
||||
--button-outline-color: #eeb425;
|
||||
--button-outline-text-color: #1a1a2e;
|
||||
--button-outline-text-color-readable: #1a1a2e;
|
||||
--button-outline-hover-color: #d4a01f;
|
||||
--border-radius: 12px;
|
||||
--border-color: #eeb425;
|
||||
@@ -73,6 +74,11 @@
|
||||
--link-hover-color: #d4a01f;
|
||||
--link-color-readable: #000000;
|
||||
--link-hover-color-readable: #000000;
|
||||
--color-surface-text-readable: #0f172a;
|
||||
--color-dropdown-text-readable: #0f172a;
|
||||
--color-pill-text-readable: #0f172a;
|
||||
--color-badge-text-readable: #000000;
|
||||
--color-overlay-text-readable: #ffffff;
|
||||
--input-border-color: #d1d5db;
|
||||
--input-focus-color: #eeb425;
|
||||
--navbar-height: 56px;
|
||||
@@ -164,7 +170,7 @@ body {
|
||||
}
|
||||
.dropdown-item {
|
||||
@apply block py-2.5 px-4 text-sm font-semibold transition-all duration-100 rounded-lg mx-1;
|
||||
color: var(--color-text-readable, var(--color-text));
|
||||
color: var(--color-dropdown-text-readable, var(--color-text-readable));
|
||||
}
|
||||
.dropdown-item:hover {
|
||||
background-color: color-mix(in srgb, var(--color-primary) 12%, transparent);
|
||||
@@ -324,7 +330,7 @@ a:hover {
|
||||
.btn-outline {
|
||||
background: transparent;
|
||||
border-color: var(--button-outline-color);
|
||||
color: #8a6a05;
|
||||
color: var(--button-outline-text-color-readable, var(--button-outline-text-color));
|
||||
}
|
||||
input,
|
||||
select,
|
||||
@@ -385,6 +391,7 @@ tbody tr:hover {
|
||||
border-radius: 999px;
|
||||
background: #f8fafc;
|
||||
border: 1px solid color-mix(in srgb, var(--color-text-muted) 15%, transparent);
|
||||
color: var(--color-pill-text-readable, var(--color-text-readable));
|
||||
}
|
||||
.currency .coin {
|
||||
width: 22px;
|
||||
|
||||
Reference in new issue
Block a user