🎉 feat: initialization
This commit is contained in:
@@ -0,0 +1,108 @@
|
||||
"use client";
|
||||
|
||||
import { useSearch } from "@tanstack/react-router";
|
||||
import { Badge } from "@workspace/ui/components/badge";
|
||||
import { ProTable } from "@workspace/ui/composed/pro-table/pro-table";
|
||||
import { filterBalanceLog } from "@workspace/ui/services/admin/log";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Display } from "@/components/display";
|
||||
import { OrderLink } from "@/components/order-link";
|
||||
import { UserDetail } from "@/sections/user/user-detail";
|
||||
import { formatDate } from "@/utils/common";
|
||||
|
||||
export default function BalanceLogPage() {
|
||||
const { t } = useTranslation("log");
|
||||
const sp = useSearch({ strict: false }) as Record<string, string | undefined>;
|
||||
|
||||
const today = new Date().toISOString().split("T")[0];
|
||||
|
||||
// i18n type declarations for extraction
|
||||
// t("type.231", "Auto Reset")
|
||||
// t("type.232", "Advance Reset")
|
||||
// t("type.233", "Paid Reset")
|
||||
// t("type.321", "Recharge")
|
||||
// t("type.322", "Withdraw")
|
||||
// t("type.323", "Payment")
|
||||
// t("type.324", "Refund")
|
||||
// t("type.325", "Reward")
|
||||
// t("type.326", "Admin Adjust")
|
||||
// t("type.331", "Purchase")
|
||||
// t("type.332", "Renewal")
|
||||
// t("type.333", "Refund")
|
||||
// t("type.334", "Withdraw")
|
||||
// t("type.335", "Admin Adjust")
|
||||
// t("type.341", "Increase")
|
||||
// t("type.342", "Reduce")
|
||||
|
||||
const getBalanceTypeText = (type: number) => {
|
||||
const typeText = t(`type.${type}`, { defaultValue: "" });
|
||||
if (!typeText) {
|
||||
return `${t("unknown", "Unknown")} (${type})`;
|
||||
}
|
||||
return typeText;
|
||||
};
|
||||
|
||||
const initialFilters = {
|
||||
date: sp.date || today,
|
||||
user_id: sp.user_id ? Number(sp.user_id) : undefined,
|
||||
};
|
||||
return (
|
||||
<ProTable<API.BalanceLog, { search?: string }>
|
||||
columns={[
|
||||
{
|
||||
accessorKey: "user",
|
||||
header: t("column.user", "User"),
|
||||
cell: ({ row }) => <UserDetail id={Number(row.original.user_id)} />,
|
||||
},
|
||||
{
|
||||
accessorKey: "amount",
|
||||
header: t("column.amount", "Amount"),
|
||||
cell: ({ row }) => (
|
||||
<Display type="currency" value={row.original.amount} />
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "order_no",
|
||||
header: t("column.orderNo", "Order No."),
|
||||
cell: ({ row }) => <OrderLink orderId={row.original.order_no} />,
|
||||
},
|
||||
{
|
||||
accessorKey: "balance",
|
||||
header: t("column.balance", "Balance"),
|
||||
cell: ({ row }) => (
|
||||
<Display type="currency" value={row.original.balance} />
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "type",
|
||||
header: t("column.type", "Type"),
|
||||
cell: ({ row }) => (
|
||||
<Badge>{getBalanceTypeText(row.original.type)}</Badge>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "timestamp",
|
||||
header: t("column.time", "Time"),
|
||||
cell: ({ row }) => formatDate(row.original.timestamp),
|
||||
},
|
||||
]}
|
||||
header={{ title: t("title.balance", "Balance Log") }}
|
||||
initialFilters={initialFilters}
|
||||
params={[
|
||||
{ key: "date", type: "date" },
|
||||
{ key: "user_id", placeholder: t("column.userId", "User ID") },
|
||||
]}
|
||||
request={async (pagination, filter) => {
|
||||
const { data } = await filterBalanceLog({
|
||||
page: pagination.page,
|
||||
size: pagination.size,
|
||||
date: (filter as any)?.date,
|
||||
user_id: (filter as any)?.user_id,
|
||||
});
|
||||
const list = (data?.data?.list || []) as any[];
|
||||
const total = Number(data?.data?.total || list.length);
|
||||
return { list, total };
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
"use client";
|
||||
|
||||
import { useSearch } from "@tanstack/react-router";
|
||||
import { Badge } from "@workspace/ui/components/badge";
|
||||
import { ProTable } from "@workspace/ui/composed/pro-table/pro-table";
|
||||
import { filterCommissionLog } from "@workspace/ui/services/admin/log";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Display } from "@/components/display";
|
||||
import { OrderLink } from "@/components/order-link";
|
||||
import { UserDetail } from "@/sections/user/user-detail";
|
||||
import { formatDate } from "@/utils/common";
|
||||
|
||||
export default function CommissionLogPage() {
|
||||
const { t } = useTranslation("log");
|
||||
const sp = useSearch({ strict: false }) as Record<string, string | undefined>;
|
||||
|
||||
const today = new Date().toISOString().split("T")[0];
|
||||
|
||||
const getCommissionTypeText = (type: number) => {
|
||||
const typeText = t(`type.${type}`, { defaultValue: "" });
|
||||
if (!typeText) {
|
||||
return `${t("unknown", "Unknown")} (${type})`;
|
||||
}
|
||||
return typeText;
|
||||
};
|
||||
|
||||
const initialFilters = {
|
||||
date: sp.date || today,
|
||||
user_id: sp.user_id ? Number(sp.user_id) : undefined,
|
||||
};
|
||||
return (
|
||||
<ProTable<API.CommissionLog, { search?: string }>
|
||||
columns={[
|
||||
{
|
||||
accessorKey: "user",
|
||||
header: t("column.user", "User"),
|
||||
cell: ({ row }) => <UserDetail id={Number(row.original.user_id)} />,
|
||||
},
|
||||
{
|
||||
accessorKey: "amount",
|
||||
header: t("column.amount", "Amount"),
|
||||
cell: ({ row }) => (
|
||||
<Display type="currency" value={row.original.amount} />
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "order_no",
|
||||
header: t("column.orderNo", "Order No."),
|
||||
cell: ({ row }) => <OrderLink orderId={row.original.order_no} />,
|
||||
},
|
||||
{
|
||||
accessorKey: "type",
|
||||
header: t("column.type", "Type"),
|
||||
cell: ({ row }) => (
|
||||
<Badge>{getCommissionTypeText(row.original.type)}</Badge>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "timestamp",
|
||||
header: t("column.time", "Time"),
|
||||
cell: ({ row }) => formatDate(row.original.timestamp),
|
||||
},
|
||||
]}
|
||||
header={{ title: t("title.commission", "Commission Log") }}
|
||||
initialFilters={initialFilters}
|
||||
params={[
|
||||
{ key: "date", type: "date" },
|
||||
{ key: "user_id", placeholder: t("column.userId", "User ID") },
|
||||
]}
|
||||
request={async (pagination, filter) => {
|
||||
const { data } = await filterCommissionLog({
|
||||
page: pagination.page,
|
||||
size: pagination.size,
|
||||
date: (filter as any)?.date,
|
||||
user_id: (filter as any)?.user_id,
|
||||
});
|
||||
const list = (data?.data?.list || []) as any[];
|
||||
const total = Number(data?.data?.total || list.length);
|
||||
return { list, total };
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
"use client";
|
||||
|
||||
import { useSearch } from "@tanstack/react-router";
|
||||
import { Badge } from "@workspace/ui/components/badge";
|
||||
import { ProTable } from "@workspace/ui/composed/pro-table/pro-table";
|
||||
import { filterEmailLog } from "@workspace/ui/services/admin/log";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { formatDate } from "@/utils/common";
|
||||
|
||||
export default function EmailLogPage() {
|
||||
const { t } = useTranslation("log");
|
||||
const sp = useSearch({ strict: false }) as Record<string, string | undefined>;
|
||||
|
||||
const today = new Date().toISOString().split("T")[0];
|
||||
|
||||
const initialFilters = {
|
||||
search: sp.search || undefined,
|
||||
date: sp.date || today,
|
||||
};
|
||||
return (
|
||||
<ProTable<API.MessageLog, { search?: string }>
|
||||
columns={[
|
||||
{
|
||||
accessorKey: "platform",
|
||||
header: t("column.platform", "Platform"),
|
||||
cell: ({ row }) => <Badge>{row.getValue("platform")}</Badge>,
|
||||
},
|
||||
{ accessorKey: "to", header: t("column.to", "To") },
|
||||
{ accessorKey: "subject", header: t("column.subject", "Subject") },
|
||||
{
|
||||
accessorKey: "content",
|
||||
header: t("column.content", "Content"),
|
||||
cell: ({ row }) => (
|
||||
<pre className="wrap-break-word max-w-[480px] overflow-auto whitespace-pre-wrap text-xs">
|
||||
{JSON.stringify(row.original.content || {}, null, 2)}
|
||||
</pre>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "status",
|
||||
header: t("column.status", "Status"),
|
||||
cell: ({ row }) => {
|
||||
const status = row.original.status;
|
||||
const getStatusVariant = (status: any) => {
|
||||
if (status === 1) {
|
||||
return "default";
|
||||
}
|
||||
if (status === 0) {
|
||||
return "destructive";
|
||||
}
|
||||
return "outline";
|
||||
};
|
||||
|
||||
const getStatusText = (status: any) => {
|
||||
if (status === 1) return t("sent", "Sent");
|
||||
if (status === 0) return t("failed", "Failed");
|
||||
return t("unknown", "Unknown");
|
||||
};
|
||||
|
||||
return (
|
||||
<Badge variant={getStatusVariant(status)}>
|
||||
{getStatusText(status)}
|
||||
</Badge>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "created_at",
|
||||
header: t("column.time", "Time"),
|
||||
cell: ({ row }) => formatDate(row.original.created_at),
|
||||
},
|
||||
]}
|
||||
header={{ title: t("title.email", "Email Log") }}
|
||||
initialFilters={initialFilters}
|
||||
params={[{ key: "search" }, { key: "date", type: "date" }]}
|
||||
request={async (pagination, filter) => {
|
||||
const { data } = await filterEmailLog({
|
||||
page: pagination.page,
|
||||
size: pagination.size,
|
||||
search: filter?.search,
|
||||
date: (filter as any)?.date,
|
||||
});
|
||||
const list = ((data?.data?.list || []) as API.MessageLog[]) || [];
|
||||
const total = Number(data?.data?.total || list.length);
|
||||
return { list, total };
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
"use client";
|
||||
|
||||
import { useSearch } from "@tanstack/react-router";
|
||||
import { Badge } from "@workspace/ui/components/badge";
|
||||
import { ProTable } from "@workspace/ui/composed/pro-table/pro-table";
|
||||
import { filterGiftLog } from "@workspace/ui/services/admin/log";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Display } from "@/components/display";
|
||||
import { OrderLink } from "@/components/order-link";
|
||||
import { UserDetail, UserSubscribeDetail } from "@/sections/user/user-detail";
|
||||
import { formatDate } from "@/utils/common";
|
||||
|
||||
export default function GiftLogPage() {
|
||||
const { t } = useTranslation("log");
|
||||
const sp = useSearch({ strict: false }) as Record<string, string | undefined>;
|
||||
|
||||
const today = new Date().toISOString().split("T")[0];
|
||||
|
||||
const getGiftTypeText = (type: number) => {
|
||||
const typeText = t(`type.${type}`, { defaultValue: "" });
|
||||
if (!typeText) {
|
||||
return `${t("unknown", "Unknown")} (${type})`;
|
||||
}
|
||||
return typeText;
|
||||
};
|
||||
|
||||
const initialFilters = {
|
||||
date: sp.date || today,
|
||||
user_id: sp.user_id ? Number(sp.user_id) : undefined,
|
||||
};
|
||||
return (
|
||||
<ProTable<API.GiftLog, { search?: string }>
|
||||
columns={[
|
||||
{
|
||||
accessorKey: "user",
|
||||
header: t("column.user", "User"),
|
||||
cell: ({ row }) => <UserDetail id={Number(row.original.user_id)} />,
|
||||
},
|
||||
{
|
||||
accessorKey: "subscribe_id",
|
||||
header: t("column.subscribe", "Subscribe"),
|
||||
cell: ({ row }) => (
|
||||
<UserSubscribeDetail
|
||||
enabled
|
||||
hoverCard
|
||||
id={Number(row.original.subscribe_id)}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "order_no",
|
||||
header: t("column.orderNo", "Order No."),
|
||||
cell: ({ row }) => <OrderLink orderId={row.original.order_no} />,
|
||||
},
|
||||
{
|
||||
accessorKey: "amount",
|
||||
header: t("column.amount", "Amount"),
|
||||
cell: ({ row }) => (
|
||||
<Display type="currency" value={row.original.amount} />
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "balance",
|
||||
header: t("column.balance", "Balance"),
|
||||
cell: ({ row }) => (
|
||||
<Display type="currency" value={row.original.balance} />
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "type",
|
||||
header: t("column.type", "Type"),
|
||||
cell: ({ row }) => (
|
||||
<Badge>{getGiftTypeText(row.original.type)}</Badge>
|
||||
),
|
||||
},
|
||||
{ accessorKey: "remark", header: t("column.remark", "Remark") },
|
||||
{
|
||||
accessorKey: "timestamp",
|
||||
header: t("column.time", "Time"),
|
||||
cell: ({ row }) => formatDate(row.original.timestamp),
|
||||
},
|
||||
]}
|
||||
header={{ title: t("title.gift", "Gift Log") }}
|
||||
initialFilters={initialFilters}
|
||||
params={[
|
||||
{ key: "date", type: "date" },
|
||||
{ key: "user_id", placeholder: t("column.userId", "User ID") },
|
||||
]}
|
||||
request={async (pagination, filter) => {
|
||||
const { data } = await filterGiftLog({
|
||||
page: pagination.page,
|
||||
size: pagination.size,
|
||||
date: (filter as any)?.date,
|
||||
user_id: (filter as any)?.user_id,
|
||||
});
|
||||
const list = (data?.data?.list || []) as any[];
|
||||
const total = Number(data?.data?.total || list.length);
|
||||
return { list, total };
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
"use client";
|
||||
|
||||
import { useSearch } from "@tanstack/react-router";
|
||||
import { Badge } from "@workspace/ui/components/badge";
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipProvider,
|
||||
TooltipTrigger,
|
||||
} from "@workspace/ui/components/tooltip";
|
||||
import { ProTable } from "@workspace/ui/composed/pro-table/pro-table";
|
||||
import { filterLoginLog } from "@workspace/ui/services/admin/log";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { IpLink } from "@/components/ip-link";
|
||||
import { UserDetail } from "@/sections/user/user-detail";
|
||||
import { formatDate } from "@/utils/common";
|
||||
|
||||
export default function LoginLogPage() {
|
||||
const { t } = useTranslation("log");
|
||||
const sp = useSearch({ strict: false }) as Record<string, string | undefined>;
|
||||
|
||||
const today = new Date().toISOString().split("T")[0];
|
||||
|
||||
const initialFilters = {
|
||||
date: sp.date || today,
|
||||
user_id: sp.user_id ? Number(sp.user_id) : undefined,
|
||||
};
|
||||
return (
|
||||
<ProTable<API.LoginLog, { date?: string; user_id?: number }>
|
||||
columns={[
|
||||
{
|
||||
accessorKey: "user",
|
||||
header: t("column.user", "User"),
|
||||
cell: ({ row }) => (
|
||||
<div>
|
||||
<Badge className="capitalize">{row.original.method}</Badge>{" "}
|
||||
<UserDetail id={Number(row.original.user_id)} />
|
||||
</div>
|
||||
),
|
||||
},
|
||||
|
||||
{
|
||||
accessorKey: "login_ip",
|
||||
header: t("column.ip", "IP"),
|
||||
cell: ({ row }) => (
|
||||
<IpLink ip={String((row.original as any).login_ip || "")} />
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "user_agent",
|
||||
header: t("column.userAgent", "User Agent"),
|
||||
cell: ({ row }) => {
|
||||
const userAgent = String(row.original.user_agent || "");
|
||||
return (
|
||||
<TooltipProvider>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<div className="max-w-48 cursor-help truncate">
|
||||
{userAgent}
|
||||
</div>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
<p className="wrap-break-word max-w-md">{userAgent}</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "success",
|
||||
header: t("column.success", "Success"),
|
||||
cell: ({ row }) => (
|
||||
<Badge variant={row.original.success ? "default" : "destructive"}>
|
||||
{row.original.success
|
||||
? t("success", "Success")
|
||||
: t("failed", "Failed")}
|
||||
</Badge>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "timestamp",
|
||||
header: t("column.time", "Time"),
|
||||
cell: ({ row }) => formatDate(row.original.timestamp),
|
||||
},
|
||||
]}
|
||||
header={{ title: t("title.login", "Login Log") }}
|
||||
initialFilters={initialFilters}
|
||||
params={[
|
||||
{ key: "date", type: "date" },
|
||||
{ key: "user_id", placeholder: t("column.userId", "User ID") },
|
||||
]}
|
||||
request={async (pagination, filter) => {
|
||||
const { data } = await filterLoginLog({
|
||||
page: pagination.page,
|
||||
size: pagination.size,
|
||||
date: (filter as any)?.date,
|
||||
user_id: (filter as any)?.user_id,
|
||||
});
|
||||
const list = ((data?.data?.list || []) as API.LoginLog[]) || [];
|
||||
const total = Number(data?.data?.total || list.length);
|
||||
return { list, total };
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
"use client";
|
||||
|
||||
import { useSearch } from "@tanstack/react-router";
|
||||
import { Badge } from "@workspace/ui/components/badge";
|
||||
import { ProTable } from "@workspace/ui/composed/pro-table/pro-table";
|
||||
import { filterMobileLog } from "@workspace/ui/services/admin/log";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { formatDate } from "@/utils/common";
|
||||
|
||||
export default function MobileLogPage() {
|
||||
const { t } = useTranslation("log");
|
||||
const sp = useSearch({ strict: false }) as Record<string, string | undefined>;
|
||||
|
||||
const today = new Date().toISOString().split("T")[0];
|
||||
|
||||
const initialFilters = {
|
||||
search: sp.search || undefined,
|
||||
date: sp.date || today,
|
||||
};
|
||||
return (
|
||||
<ProTable<API.MessageLog, { search?: string }>
|
||||
columns={[
|
||||
{
|
||||
accessorKey: "platform",
|
||||
header: t("column.platform", "Platform"),
|
||||
cell: ({ row }) => <Badge>{row.getValue("platform")}</Badge>,
|
||||
},
|
||||
{ accessorKey: "to", header: t("column.to", "To") },
|
||||
{ accessorKey: "subject", header: t("column.subject", "Subject") },
|
||||
{
|
||||
accessorKey: "content",
|
||||
header: t("column.content", "Content"),
|
||||
cell: ({ row }) => (
|
||||
<pre className="wrap-break-word max-w-[480px] overflow-auto whitespace-pre-wrap text-xs">
|
||||
{JSON.stringify(row.original.content || {}, null, 2)}
|
||||
</pre>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "status",
|
||||
header: t("column.status", "Status"),
|
||||
cell: ({ row }) => {
|
||||
const status = row.original.status;
|
||||
const getStatusVariant = (status: any) => {
|
||||
if (status === 1) {
|
||||
return "default";
|
||||
}
|
||||
if (status === 0) {
|
||||
return "destructive";
|
||||
}
|
||||
return "outline";
|
||||
};
|
||||
|
||||
const getStatusText = (status: any) => {
|
||||
if (status === 1) return t("sent", "Sent");
|
||||
if (status === 0) return t("failed", "Failed");
|
||||
return t("unknown", "Unknown");
|
||||
};
|
||||
|
||||
return (
|
||||
<Badge variant={getStatusVariant(status)}>
|
||||
{getStatusText(status)}
|
||||
</Badge>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "created_at",
|
||||
header: t("column.time", "Time"),
|
||||
cell: ({ row }) => formatDate(row.original.created_at),
|
||||
},
|
||||
]}
|
||||
header={{ title: t("title.mobile", "SMS Log") }}
|
||||
initialFilters={initialFilters}
|
||||
params={[{ key: "search" }, { key: "date", type: "date" }]}
|
||||
request={async (pagination, filter) => {
|
||||
const { data } = await filterMobileLog({
|
||||
page: pagination.page,
|
||||
size: pagination.size,
|
||||
search: filter?.search,
|
||||
date: (filter as any)?.date,
|
||||
});
|
||||
const list = ((data?.data?.list || []) as API.MessageLog[]) || [];
|
||||
const total = Number(data?.data?.total || list.length);
|
||||
return { list, total };
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
"use client";
|
||||
|
||||
import { useSearch } from "@tanstack/react-router";
|
||||
import { Badge } from "@workspace/ui/components/badge";
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipProvider,
|
||||
TooltipTrigger,
|
||||
} from "@workspace/ui/components/tooltip";
|
||||
import { ProTable } from "@workspace/ui/composed/pro-table/pro-table";
|
||||
import { filterRegisterLog } from "@workspace/ui/services/admin/log";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { IpLink } from "@/components/ip-link";
|
||||
import { UserDetail } from "@/sections/user/user-detail";
|
||||
import { formatDate } from "@/utils/common";
|
||||
|
||||
export default function RegisterLogPage() {
|
||||
const { t } = useTranslation("log");
|
||||
const sp = useSearch({ strict: false }) as Record<string, string | undefined>;
|
||||
|
||||
const today = new Date().toISOString().split("T")[0];
|
||||
|
||||
const initialFilters = {
|
||||
date: sp.date || today,
|
||||
user_id: sp.user_id ? Number(sp.user_id) : undefined,
|
||||
};
|
||||
return (
|
||||
<ProTable<API.RegisterLog, { date?: string; user_id?: number }>
|
||||
columns={[
|
||||
{
|
||||
accessorKey: "user",
|
||||
header: t("column.user", "User"),
|
||||
cell: ({ row }) => <UserDetail id={Number(row.original.user_id)} />,
|
||||
},
|
||||
{
|
||||
accessorKey: "auth_method",
|
||||
header: t("column.identifier", "Identifier"),
|
||||
cell: ({ row }) => (
|
||||
<div className="flex items-center">
|
||||
<Badge className="capitalize">{row.original.auth_method}</Badge>
|
||||
<span className="ml-1 text-sm">{row.original.identifier}</span>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "register_ip",
|
||||
header: t("column.ip", "IP"),
|
||||
cell: ({ row }) => (
|
||||
<IpLink ip={String((row.original as any).register_ip || "")} />
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "user_agent",
|
||||
header: t("column.userAgent", "User Agent"),
|
||||
cell: ({ row }) => {
|
||||
const userAgent = String(row.original.user_agent || "");
|
||||
return (
|
||||
<TooltipProvider>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<div className="max-w-48 cursor-help truncate">
|
||||
{userAgent}
|
||||
</div>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
<p className="wrap-break-word max-w-md">{userAgent}</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "timestamp",
|
||||
header: t("column.time", "Time"),
|
||||
cell: ({ row }) => formatDate(row.original.timestamp),
|
||||
},
|
||||
]}
|
||||
header={{ title: t("title.register", "Register Log") }}
|
||||
initialFilters={initialFilters}
|
||||
params={[
|
||||
{ key: "date", type: "date" },
|
||||
{ key: "user_id", placeholder: t("column.userId", "User ID") },
|
||||
]}
|
||||
request={async (pagination, filter) => {
|
||||
const { data } = await filterRegisterLog({
|
||||
page: pagination.page,
|
||||
size: pagination.size,
|
||||
date: (filter as any)?.date,
|
||||
user_id: (filter as any)?.user_id,
|
||||
});
|
||||
const list = (data?.data?.list || []) as any[];
|
||||
const total = Number(data?.data?.total || list.length);
|
||||
return { list, total };
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
"use client";
|
||||
|
||||
import { useSearch } from "@tanstack/react-router";
|
||||
import { Badge } from "@workspace/ui/components/badge";
|
||||
import { ProTable } from "@workspace/ui/composed/pro-table/pro-table";
|
||||
import { filterResetSubscribeLog } from "@workspace/ui/services/admin/log";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { OrderLink } from "@/components/order-link";
|
||||
import { UserDetail, UserSubscribeDetail } from "@/sections/user/user-detail";
|
||||
import { formatDate } from "@/utils/common";
|
||||
|
||||
export default function ResetSubscribeLogPage() {
|
||||
const { t } = useTranslation("log");
|
||||
const sp = useSearch({ strict: false }) as Record<string, string | undefined>;
|
||||
|
||||
const today = new Date().toISOString().split("T")[0];
|
||||
|
||||
const getResetSubscribeTypeText = (type: number) => {
|
||||
const typeText = t(`type.${type}`, { defaultValue: "" });
|
||||
if (!typeText) {
|
||||
return `${t("unknown", "Unknown")} (${type})`;
|
||||
}
|
||||
return typeText;
|
||||
};
|
||||
|
||||
const initialFilters = {
|
||||
date: sp.date || today,
|
||||
user_subscribe_id: sp.user_subscribe_id
|
||||
? Number(sp.user_subscribe_id)
|
||||
: undefined,
|
||||
};
|
||||
return (
|
||||
<ProTable<
|
||||
API.ResetSubscribeLog,
|
||||
{ date?: string; user_subscribe_id?: number }
|
||||
>
|
||||
columns={[
|
||||
{
|
||||
accessorKey: "user",
|
||||
header: t("column.user", "User"),
|
||||
cell: ({ row }) => <UserDetail id={Number(row.original.user_id)} />,
|
||||
},
|
||||
{
|
||||
accessorKey: "user_subscribe_id",
|
||||
header: t("column.subscribeId", "Subscribe ID"),
|
||||
cell: ({ row }) => (
|
||||
<UserSubscribeDetail
|
||||
enabled
|
||||
hoverCard
|
||||
id={Number(row.original.user_subscribe_id)}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "type",
|
||||
header: t("column.type", "Type"),
|
||||
cell: ({ row }) => (
|
||||
<Badge>{getResetSubscribeTypeText(row.original.type)}</Badge>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "order_no",
|
||||
header: t("column.orderNo", "Order No."),
|
||||
cell: ({ row }) => <OrderLink orderId={row.original.order_no} />,
|
||||
},
|
||||
{
|
||||
accessorKey: "timestamp",
|
||||
header: t("column.time", "Time"),
|
||||
cell: ({ row }) => formatDate(row.original.timestamp),
|
||||
},
|
||||
]}
|
||||
header={{ title: t("title.resetSubscribe", "Reset Subscribe Log") }}
|
||||
initialFilters={initialFilters}
|
||||
params={[
|
||||
{ key: "date", type: "date" },
|
||||
{
|
||||
key: "user_subscribe_id",
|
||||
placeholder: t("column.subscribeId", "Subscribe ID"),
|
||||
},
|
||||
]}
|
||||
request={async (pagination, filter) => {
|
||||
const { data } = await filterResetSubscribeLog({
|
||||
page: pagination.page,
|
||||
size: pagination.size,
|
||||
date: (filter as any)?.date,
|
||||
user_subscribe_id: (filter as any)?.user_subscribe_id,
|
||||
});
|
||||
const list = (data?.data?.list || []) as any[];
|
||||
const total = Number(data?.data?.total || list.length);
|
||||
return { list, total };
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
"use client";
|
||||
|
||||
import { Link, useSearch } from "@tanstack/react-router";
|
||||
import { Badge } from "@workspace/ui/components/badge";
|
||||
import { Button } from "@workspace/ui/components/button";
|
||||
import { ProTable } from "@workspace/ui/composed/pro-table/pro-table";
|
||||
import { filterServerTrafficLog } from "@workspace/ui/services/admin/log";
|
||||
import { formatBytes } from "@workspace/ui/utils/formatting";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useServer } from "@/stores/server";
|
||||
|
||||
export default function ServerTrafficLogPage() {
|
||||
const { t } = useTranslation("log");
|
||||
const sp = useSearch({ strict: false }) as Record<string, string | undefined>;
|
||||
const { getServerName } = useServer();
|
||||
|
||||
const today = new Date().toISOString().split("T")[0];
|
||||
|
||||
const initialFilters = {
|
||||
date: sp.date || today,
|
||||
server_id: sp.server_id ? Number(sp.server_id) : undefined,
|
||||
};
|
||||
return (
|
||||
<ProTable<API.ServerTrafficLog, { date?: string; server_id?: number }>
|
||||
actions={{
|
||||
render: (row) => [
|
||||
<Button asChild key="detail">
|
||||
<Link
|
||||
search={{ date: row.date, server_id: row.server_id }}
|
||||
to="/dashboard/log/traffic-details"
|
||||
>
|
||||
{t("detail", "Detail")}
|
||||
</Link>
|
||||
</Button>,
|
||||
],
|
||||
}}
|
||||
columns={[
|
||||
{
|
||||
accessorKey: "server_id",
|
||||
header: t("column.server", "Server"),
|
||||
cell: ({ row }) => (
|
||||
<div className="flex items-center gap-2">
|
||||
<Badge>{row.original.server_id}</Badge>
|
||||
<span>{getServerName(row.original.server_id)}</span>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "upload",
|
||||
header: t("column.upload", "Upload"),
|
||||
cell: ({ row }) => formatBytes(row.original.upload),
|
||||
},
|
||||
{
|
||||
accessorKey: "download",
|
||||
header: t("column.download", "Download"),
|
||||
cell: ({ row }) => formatBytes(row.original.download),
|
||||
},
|
||||
{
|
||||
accessorKey: "total",
|
||||
header: t("column.total", "Total"),
|
||||
cell: ({ row }) => formatBytes(row.original.total),
|
||||
},
|
||||
{ accessorKey: "date", header: t("column.date", "Date") },
|
||||
]}
|
||||
header={{ title: t("title.serverTraffic", "Server Traffic Log") }}
|
||||
initialFilters={initialFilters}
|
||||
params={[
|
||||
{ key: "date", type: "date" },
|
||||
{ key: "server_id", placeholder: t("column.serverId", "Server ID") },
|
||||
]}
|
||||
request={async (pagination, filter) => {
|
||||
const { data } = await filterServerTrafficLog({
|
||||
page: pagination.page,
|
||||
size: pagination.size,
|
||||
date: (filter as any)?.date,
|
||||
server_id: (filter as any)?.server_id,
|
||||
});
|
||||
const list = (data?.data?.list || []) as any[];
|
||||
const total = Number(data?.data?.total || list.length);
|
||||
return { list, total };
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
"use client";
|
||||
|
||||
import { Link, useSearch } from "@tanstack/react-router";
|
||||
import { Button } from "@workspace/ui/components/button";
|
||||
import { ProTable } from "@workspace/ui/composed/pro-table/pro-table";
|
||||
import { filterUserSubscribeTrafficLog } from "@workspace/ui/services/admin/log";
|
||||
import { formatBytes } from "@workspace/ui/utils/formatting";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { UserDetail, UserSubscribeDetail } from "@/sections/user/user-detail";
|
||||
|
||||
export default function SubscribeTrafficLogPage() {
|
||||
const { t } = useTranslation("log");
|
||||
const sp = useSearch({ strict: false }) as Record<string, string | undefined>;
|
||||
|
||||
const today = new Date().toISOString().split("T")[0];
|
||||
|
||||
const initialFilters = {
|
||||
date: sp.date || today,
|
||||
user_id: sp.user_id ? Number(sp.user_id) : undefined,
|
||||
user_subscribe_id: sp.user_subscribe_id
|
||||
? Number(sp.user_subscribe_id)
|
||||
: undefined,
|
||||
};
|
||||
return (
|
||||
<ProTable<
|
||||
API.UserSubscribeTrafficLog,
|
||||
{ date?: string; user_id?: number; user_subscribe_id?: number }
|
||||
>
|
||||
actions={{
|
||||
render: (row) => [
|
||||
<Button asChild key="detail">
|
||||
<Link
|
||||
search={{
|
||||
date: row.date,
|
||||
user_id: row.user_id,
|
||||
subscribe_id: row.subscribe_id,
|
||||
}}
|
||||
to="/dashboard/log/traffic-details"
|
||||
>
|
||||
{t("detail", "Detail")}
|
||||
</Link>
|
||||
</Button>,
|
||||
],
|
||||
}}
|
||||
columns={[
|
||||
{
|
||||
accessorKey: "user",
|
||||
header: t("column.user", "User"),
|
||||
cell: ({ row }) => <UserDetail id={Number(row.original.user_id)} />,
|
||||
},
|
||||
{
|
||||
accessorKey: "subscribe_id",
|
||||
header: t("column.subscribe", "Subscribe"),
|
||||
cell: ({ row }) => (
|
||||
<UserSubscribeDetail
|
||||
enabled
|
||||
hoverCard
|
||||
id={Number(row.original.subscribe_id)}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "upload",
|
||||
header: t("column.upload", "Upload"),
|
||||
cell: ({ row }) => formatBytes(row.original.upload),
|
||||
},
|
||||
{
|
||||
accessorKey: "download",
|
||||
header: t("column.download", "Download"),
|
||||
cell: ({ row }) => formatBytes(row.original.download),
|
||||
},
|
||||
{
|
||||
accessorKey: "total",
|
||||
header: t("column.total", "Total"),
|
||||
cell: ({ row }) => formatBytes(row.original.total),
|
||||
},
|
||||
{
|
||||
accessorKey: "date",
|
||||
header: t("column.date", "Date"),
|
||||
},
|
||||
]}
|
||||
header={{ title: t("title.subscribeTraffic", "Subscribe Traffic Log") }}
|
||||
initialFilters={initialFilters}
|
||||
params={[
|
||||
{ key: "date", type: "date" },
|
||||
{ key: "user_id", placeholder: t("column.userId", "User ID") },
|
||||
{
|
||||
key: "user_subscribe_id",
|
||||
placeholder: t("column.subscribeId", "Subscribe ID"),
|
||||
},
|
||||
]}
|
||||
request={async (pagination, filter) => {
|
||||
const { data } = await filterUserSubscribeTrafficLog({
|
||||
page: pagination.page,
|
||||
size: pagination.size,
|
||||
date: (filter as any)?.date,
|
||||
user_id: (filter as any)?.user_id,
|
||||
user_subscribe_id: (filter as any)?.user_subscribe_id,
|
||||
});
|
||||
const list =
|
||||
((data?.data?.list || []) as API.UserSubscribeTrafficLog[]) || [];
|
||||
const total = Number(data?.data?.total || list.length);
|
||||
return { list, total };
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
"use client";
|
||||
|
||||
import { useSearch } from "@tanstack/react-router";
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipProvider,
|
||||
TooltipTrigger,
|
||||
} from "@workspace/ui/components/tooltip";
|
||||
import { ProTable } from "@workspace/ui/composed/pro-table/pro-table";
|
||||
import { filterSubscribeLog } from "@workspace/ui/services/admin/log";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { IpLink } from "@/components/ip-link";
|
||||
import { UserDetail, UserSubscribeDetail } from "@/sections/user/user-detail";
|
||||
import { formatDate } from "@/utils/common";
|
||||
|
||||
export default function SubscribeLogPage() {
|
||||
const { t } = useTranslation("log");
|
||||
const sp = useSearch({ strict: false }) as Record<string, string | undefined>;
|
||||
|
||||
const today = new Date().toISOString().split("T")[0];
|
||||
|
||||
const initialFilters = {
|
||||
date: sp.date || today,
|
||||
user_id: sp.user_id ? Number(sp.user_id) : undefined,
|
||||
user_subscribe_id: sp.user_subscribe_id
|
||||
? Number(sp.user_subscribe_id)
|
||||
: undefined,
|
||||
};
|
||||
return (
|
||||
<ProTable<API.SubscribeLog, { date?: string; user_id?: number }>
|
||||
columns={[
|
||||
{
|
||||
accessorKey: "user",
|
||||
header: t("column.user", "User"),
|
||||
cell: ({ row }) => <UserDetail id={Number(row.original.user_id)} />,
|
||||
},
|
||||
{
|
||||
accessorKey: "user_subscribe_id",
|
||||
header: t("column.subscribe", "Subscribe"),
|
||||
cell: ({ row }) => (
|
||||
<UserSubscribeDetail
|
||||
enabled
|
||||
hoverCard
|
||||
id={Number(row.original.user_subscribe_id)}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "client_ip",
|
||||
header: t("column.ip", "IP"),
|
||||
cell: ({ row }) => (
|
||||
<IpLink ip={String((row.original as any).client_ip || "")} />
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "user_agent",
|
||||
header: t("column.userAgent", "User Agent"),
|
||||
cell: ({ row }) => {
|
||||
const userAgent = String(row.original.user_agent || "");
|
||||
return (
|
||||
<TooltipProvider>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<div className="max-w-48 cursor-help truncate">
|
||||
{userAgent}
|
||||
</div>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
<p className="wrap-break-word max-w-md">{userAgent}</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "timestamp",
|
||||
header: t("column.time", "Time"),
|
||||
cell: ({ row }) => formatDate(row.original.timestamp),
|
||||
},
|
||||
]}
|
||||
header={{ title: t("title.subscribe", "Subscribe Log") }}
|
||||
initialFilters={initialFilters}
|
||||
params={[
|
||||
{ key: "date", type: "date" },
|
||||
{ key: "user_id", placeholder: t("column.userId", "User ID") },
|
||||
{
|
||||
key: "user_subscribe_id",
|
||||
placeholder: t("column.subscribeId", "Subscribe ID"),
|
||||
},
|
||||
]}
|
||||
request={async (pagination, filter) => {
|
||||
const { data } = await filterSubscribeLog({
|
||||
page: pagination.page,
|
||||
size: pagination.size,
|
||||
date: (filter as any)?.date,
|
||||
user_id: (filter as any)?.user_id,
|
||||
user_subscribe_id: (filter as any)?.user_subscribe_id,
|
||||
});
|
||||
const list = (data?.data?.list || []) as any[];
|
||||
const total = Number(data?.data?.total || list.length);
|
||||
return { list, total };
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
"use client";
|
||||
|
||||
import { useSearch } from "@tanstack/react-router";
|
||||
import { ProTable } from "@workspace/ui/composed/pro-table/pro-table";
|
||||
import { filterTrafficLogDetails } from "@workspace/ui/services/admin/log";
|
||||
import { formatBytes } from "@workspace/ui/utils/formatting";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { UserDetail, UserSubscribeDetail } from "@/sections/user/user-detail";
|
||||
import { useServer } from "@/stores/server";
|
||||
import { formatDate } from "@/utils/common";
|
||||
|
||||
export default function TrafficDetailsPage() {
|
||||
const { t } = useTranslation("log");
|
||||
const sp = useSearch({ strict: false }) as Record<string, string | undefined>;
|
||||
const { getServerName } = useServer();
|
||||
|
||||
const today = new Date().toISOString().split("T")[0];
|
||||
|
||||
const initialFilters = {
|
||||
date: sp.date || today,
|
||||
server_id: sp.server_id ? Number(sp.server_id) : undefined,
|
||||
user_id: sp.user_id ? Number(sp.user_id) : undefined,
|
||||
subscribe_id: sp.subscribe_id ? Number(sp.subscribe_id) : undefined,
|
||||
};
|
||||
return (
|
||||
<ProTable<API.TrafficLogDetails, { search?: string }>
|
||||
columns={[
|
||||
{
|
||||
accessorKey: "server_id",
|
||||
header: t("column.server", "Server"),
|
||||
cell: ({ row }) => (
|
||||
<span>
|
||||
{getServerName(row.original.server_id)} ({row.original.server_id})
|
||||
</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "user_id",
|
||||
header: t("column.user", "User"),
|
||||
cell: ({ row }) => <UserDetail id={Number(row.original.user_id)} />,
|
||||
},
|
||||
{
|
||||
accessorKey: "subscribe_id",
|
||||
header: t("column.subscribe", "Subscribe"),
|
||||
cell: ({ row }) => (
|
||||
<UserSubscribeDetail
|
||||
enabled
|
||||
hoverCard
|
||||
id={Number(row.original.subscribe_id)}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "upload",
|
||||
header: t("column.upload", "Upload"),
|
||||
cell: ({ row }) => formatBytes(row.original.upload),
|
||||
},
|
||||
{
|
||||
accessorKey: "download",
|
||||
header: t("column.download", "Download"),
|
||||
cell: ({ row }) => formatBytes(row.original.download),
|
||||
},
|
||||
{
|
||||
accessorKey: "timestamp",
|
||||
header: t("column.time", "Time"),
|
||||
cell: ({ row }) => formatDate(row.original.timestamp),
|
||||
},
|
||||
]}
|
||||
header={{ title: t("title.trafficDetails", "Traffic Details") }}
|
||||
initialFilters={initialFilters}
|
||||
params={[
|
||||
{ key: "date", type: "date" },
|
||||
{ key: "server_id", placeholder: t("column.serverId", "Server ID") },
|
||||
{ key: "user_id", placeholder: t("column.userId", "User ID") },
|
||||
{
|
||||
key: "subscribe_id",
|
||||
placeholder: t("column.subscribeId", "Subscribe ID"),
|
||||
},
|
||||
]}
|
||||
request={async (pagination, filter) => {
|
||||
const { data } = await filterTrafficLogDetails({
|
||||
page: pagination.page,
|
||||
size: pagination.size,
|
||||
date: (filter as any)?.date,
|
||||
server_id: (filter as any)?.server_id,
|
||||
user_id: (filter as any)?.user_id,
|
||||
subscribe_id: (filter as any)?.subscribe_id,
|
||||
});
|
||||
const list = (data?.data?.list || []) as any[];
|
||||
const total = Number(data?.data?.total || list.length);
|
||||
return { list, total };
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user