Reapply "Add missing admin action files and navigation links"
This reverts commit 4d515bc400.
This commit is contained in:
1 parent
96ed768f14
commit
5b4228261a
338 files changed
+28143
-5948
No files matched your search
+33
-18
@@ -27,11 +27,7 @@ export default async function AdminStaffActivities({
|
||||
let whereClause = {};
|
||||
if (q) {
|
||||
whereClause = {
|
||||
OR: [
|
||||
{ action: { contains: q } },
|
||||
{ description: { contains: q } },
|
||||
{ ipAddress: { contains: q } },
|
||||
],
|
||||
OR: [{ action: { contains: q } }, { description: { contains: q } }, { ipAddress: { contains: q } }],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -81,7 +77,9 @@ export default async function AdminStaffActivities({
|
||||
|
||||
const pages = Math.max(1, Math.ceil(total / PER_PAGE));
|
||||
|
||||
const onlineCount = activities.filter((a) => a.createdAt && new Date(a.createdAt).getTime() > Date.now() - 60000).length;
|
||||
const onlineCount = activities.filter(
|
||||
(a) => a.createdAt && new Date(a.createdAt).getTime() > Date.now() - 60000,
|
||||
).length;
|
||||
|
||||
return (
|
||||
<main>
|
||||
@@ -119,12 +117,12 @@ export default async function AdminStaffActivities({
|
||||
placeholder={t("staffId")}
|
||||
className="w-[120px]"
|
||||
/>
|
||||
<input
|
||||
name="action"
|
||||
defaultValue={action ?? ""}
|
||||
placeholder={t("actionType")}
|
||||
className="w-[160px]"
|
||||
/>
|
||||
<input
|
||||
name="action"
|
||||
defaultValue={action ?? ""}
|
||||
placeholder={t("actionType")}
|
||||
className="w-[160px]"
|
||||
/>
|
||||
|
||||
<button type="submit" className="btn btn-primary">
|
||||
{t("filter")}
|
||||
@@ -156,20 +154,33 @@ export default async function AdminStaffActivities({
|
||||
<tbody>
|
||||
{activities.map((a) => (
|
||||
<tr key={String(a.id)}>
|
||||
<td className="text-sm text-gray-500 dark:text-gray-400 whitespace-nowrap">{fromDate(a.createdAt)}</td>
|
||||
<td className="text-sm text-gray-500 dark:text-gray-400 whitespace-nowrap">{t("staffWithId", { id: Number(a.userId), name: nameById.get(Number(a.userId)) ?? "unknown" })}</td>
|
||||
<td className="text-sm text-gray-500 dark:text-gray-400 whitespace-nowrap">
|
||||
{fromDate(a.createdAt)}
|
||||
</td>
|
||||
<td className="text-sm text-gray-500 dark:text-gray-400 whitespace-nowrap">
|
||||
{t("staffWithId", {
|
||||
id: Number(a.userId),
|
||||
name: nameById.get(Number(a.userId)) ?? "unknown",
|
||||
})}
|
||||
</td>
|
||||
<td>
|
||||
<span className="inline-block text-[0.72rem] font-bold px-2 py-0.5 rounded-full bg-[var(--color-primary)]/18 text-[var(--color-text)]">{a.action}</span>
|
||||
<span className="inline-block text-[0.72rem] font-bold px-2 py-0.5 rounded-full bg-[var(--color-primary)]/18 text-[var(--color-text)]">
|
||||
{a.action}
|
||||
</span>
|
||||
</td>
|
||||
<td>{a.description}</td>
|
||||
<td>
|
||||
{a.targetType && a.targetId ? (
|
||||
<span className="text-sm text-gray-500 dark:text-gray-400">{a.targetType === "user" ? t("userPrefix") : ""}#{String(a.targetId)}</span>
|
||||
<span className="text-sm text-gray-500 dark:text-gray-400">
|
||||
{a.targetType === "user" ? t("userPrefix") : ""}#{String(a.targetId)}
|
||||
</span>
|
||||
) : (
|
||||
<span className="text-sm text-gray-500 dark:text-gray-400">—</span>
|
||||
)}
|
||||
</td>
|
||||
<td className="text-sm text-gray-500 dark:text-gray-400 whitespace-nowrap">{a.ipAddress || "—"}</td>
|
||||
<td className="text-sm text-gray-500 dark:text-gray-400 whitespace-nowrap">
|
||||
{a.ipAddress || "—"}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
@@ -183,7 +194,11 @@ export default async function AdminStaffActivities({
|
||||
{page < pages ? (
|
||||
<>
|
||||
{" · "}
|
||||
<a href={`/admin/logs?q=${encodeURIComponent(q)}&staffId=${staffId || ""}&action=${action || ""}&page=${page + 1}`}>{t("next")} →</a>
|
||||
<a
|
||||
href={`/admin/logs?q=${encodeURIComponent(q)}&staffId=${staffId || ""}&action=${action || ""}&page=${page + 1}`}
|
||||
>
|
||||
{t("next")} →
|
||||
</a>
|
||||
</>
|
||||
) : null}
|
||||
</p>
|
||||
|
||||
Reference in new issue
Block a user