mirror of
https://github.com/Buriburizaem0n/admin-frontend-domain.git
synced 2026-05-06 05:38:51 +00:00
fix: stabilize admin frontend and resolve TS build errors
This commit is contained in:
@@ -116,7 +116,7 @@ export default function AlertRulePage() {
|
||||
className="flex gap-2"
|
||||
delete={{
|
||||
fn: deleteAlertRules,
|
||||
id: s.id,
|
||||
id: s.id!,
|
||||
mutate: mutate,
|
||||
}}
|
||||
>
|
||||
@@ -147,7 +147,7 @@ export default function AlertRulePage() {
|
||||
className="flex ml-auto self-end sm:self-auto gap-2 flex-wrap shrink-0"
|
||||
delete={{
|
||||
fn: deleteAlertRules,
|
||||
id: selectedRows.map((r) => r.original.id),
|
||||
id: selectedRows.map((r) => r.original.id!),
|
||||
mutate: mutate,
|
||||
}}
|
||||
>
|
||||
|
||||
+3
-3
@@ -164,7 +164,7 @@ export default function CronPage() {
|
||||
return (
|
||||
<ActionButtonGroup
|
||||
className="flex gap-2"
|
||||
delete={{ fn: deleteCron, id: s.id, mutate: mutate }}
|
||||
delete={{ fn: deleteCron, id: s.id!, mutate: mutate }}
|
||||
>
|
||||
<>
|
||||
<IconButton
|
||||
@@ -172,7 +172,7 @@ export default function CronPage() {
|
||||
icon="play"
|
||||
onClick={async () => {
|
||||
try {
|
||||
await runCron(s.id)
|
||||
await runCron(s.id!)
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
toast(t("Error"), {
|
||||
@@ -215,7 +215,7 @@ export default function CronPage() {
|
||||
className="flex gap-2 flex-wrap shrink-0"
|
||||
delete={{
|
||||
fn: deleteCron,
|
||||
id: selectedRows.map((r) => r.original.id),
|
||||
id: selectedRows.map((r) => r.original.id!),
|
||||
mutate: mutate,
|
||||
}}
|
||||
>
|
||||
|
||||
+2
-2
@@ -121,7 +121,7 @@ export default function DDNSPage() {
|
||||
className="flex gap-2"
|
||||
delete={{
|
||||
fn: deleteDDNSProfiles,
|
||||
id: s.id,
|
||||
id: s.id!,
|
||||
mutate: mutate,
|
||||
}}
|
||||
>
|
||||
@@ -152,7 +152,7 @@ export default function DDNSPage() {
|
||||
className="flex ml-auto self-end sm:self-auto gap-2 flex-wrap shrink-0"
|
||||
delete={{
|
||||
fn: deleteDDNSProfiles,
|
||||
id: selectedRows.map((r) => r.original.id),
|
||||
id: selectedRows.map((r) => r.original.id!),
|
||||
mutate: mutate,
|
||||
}}
|
||||
>
|
||||
|
||||
+2
-2
@@ -106,7 +106,7 @@ export default function NATPage() {
|
||||
return (
|
||||
<ActionButtonGroup
|
||||
className="flex gap-2"
|
||||
delete={{ fn: deleteNAT, id: s.id, mutate: mutate }}
|
||||
delete={{ fn: deleteNAT, id: s.id!, mutate: mutate }}
|
||||
>
|
||||
<NATCard mutate={mutate} data={s} />
|
||||
</ActionButtonGroup>
|
||||
@@ -135,7 +135,7 @@ export default function NATPage() {
|
||||
className="flex ml-auto self-end sm:self-auto gap-2 flex-wrap shrink-0"
|
||||
delete={{
|
||||
fn: deleteNAT,
|
||||
id: selectedRows.map((r) => r.original.id),
|
||||
id: selectedRows.map((r) => r.original.id!),
|
||||
mutate: mutate,
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -97,7 +97,7 @@ export default function NotificationGroupPage() {
|
||||
className="flex gap-2"
|
||||
delete={{
|
||||
fn: deleteNotificationGroups,
|
||||
id: s.group.id,
|
||||
id: s.group.id!,
|
||||
mutate: mutate,
|
||||
}}
|
||||
>
|
||||
@@ -128,7 +128,7 @@ export default function NotificationGroupPage() {
|
||||
className="flex ml-auto self-end sm:self-auto gap-2 flex-wrap shrink-0"
|
||||
delete={{
|
||||
fn: deleteNotificationGroups,
|
||||
id: selectedRows.map((r) => r.original.group.id),
|
||||
id: selectedRows.map((r) => r.original.group.id!),
|
||||
mutate: mutate,
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -83,7 +83,7 @@ export default function NotificationPage() {
|
||||
accessorFn: (row) => {
|
||||
return (
|
||||
notifierGroup
|
||||
?.filter((ng) => ng.notifications?.includes(row.id))
|
||||
?.filter((ng) => ng.notifications?.includes(row.id!))
|
||||
.map((ng) => ng.group.id) || []
|
||||
)
|
||||
},
|
||||
@@ -112,7 +112,7 @@ export default function NotificationPage() {
|
||||
className="flex gap-2"
|
||||
delete={{
|
||||
fn: deleteNotification,
|
||||
id: s.id,
|
||||
id: s.id!,
|
||||
mutate: mutate,
|
||||
}}
|
||||
>
|
||||
@@ -143,7 +143,7 @@ export default function NotificationPage() {
|
||||
className="flex ml-auto self-end sm:self-auto gap-2 flex-wrap shrink-0"
|
||||
delete={{
|
||||
fn: deleteNotification,
|
||||
id: selectedRows.map((r) => r.original.id),
|
||||
id: selectedRows.map((r) => r.original.id!),
|
||||
mutate: mutate,
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -22,7 +22,7 @@ import {
|
||||
TableRow,
|
||||
} from "@/components/ui/table"
|
||||
import { useAuth } from "@/hooks/useAuth"
|
||||
import { ModelOnlineUser, ModelOnlineUserApi } from "@/types"
|
||||
import { GithubComNezhahqNezhaModelPaginatedResponseArrayModelOnlineUserModelOnlineUser, ModelOnlineUser } from "@/types"
|
||||
import { ColumnDef, flexRender, getCoreRowModel, useReactTable } from "@tanstack/react-table"
|
||||
import { useEffect, useMemo } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
@@ -40,7 +40,7 @@ export default function OnlineUserPage() {
|
||||
// 计算 offset
|
||||
const offset = (page - 1) * pageSize
|
||||
|
||||
const { data, mutate, error, isLoading } = useSWR<ModelOnlineUserApi, Error>(
|
||||
const { data, mutate, error, isLoading } = useSWR<GithubComNezhahqNezhaModelPaginatedResponseArrayModelOnlineUserModelOnlineUser, Error>(
|
||||
`/api/v1/online-user?offset=${offset}&limit=${pageSize}`,
|
||||
swrFetcher,
|
||||
)
|
||||
@@ -94,7 +94,7 @@ export default function OnlineUserPage() {
|
||||
accessorFn: (row) => row.connected_at,
|
||||
cell: ({ row }) => {
|
||||
const s = row.original
|
||||
const date = new Date(s.connected_at)
|
||||
const date = new Date(s.connected_at!)
|
||||
return <span>{date.toISOString()}</span>
|
||||
},
|
||||
},
|
||||
@@ -125,7 +125,7 @@ export default function OnlineUserPage() {
|
||||
}
|
||||
|
||||
const dataCache = useMemo(() => {
|
||||
return data?.value ?? []
|
||||
return data?.data?.value ?? []
|
||||
}, [data])
|
||||
|
||||
const table = useReactTable<ModelOnlineUser>({
|
||||
@@ -137,9 +137,9 @@ export default function OnlineUserPage() {
|
||||
const selectedRows = table.getSelectedRowModel().rows
|
||||
|
||||
const renderPagination = () => {
|
||||
if (!data?.pagination) return null
|
||||
if (!data?.data?.pagination) return null
|
||||
|
||||
const { total } = data.pagination
|
||||
const { total = 0 } = data.data.pagination
|
||||
const totalPages = Math.ceil(total / pageSize)
|
||||
|
||||
const handlePageChange = (newPage: number) => {
|
||||
|
||||
+1
-2
@@ -4,8 +4,7 @@ import { Toaster } from "@/components/ui/sonner"
|
||||
import useSetting from "@/hooks/useSetting"
|
||||
import i18n from "@/lib/i18n"
|
||||
import { InjectContext } from "@/lib/inject"
|
||||
import { DateTime } from "luxon"
|
||||
import { useEffect, useState } from "react"
|
||||
import { useEffect } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { Outlet } from "react-router-dom"
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ export default function ServerGroupPage() {
|
||||
className="flex gap-2"
|
||||
delete={{
|
||||
fn: deleteServerGroups,
|
||||
id: s.group.id,
|
||||
id: s.group.id!,
|
||||
mutate: mutate,
|
||||
}}
|
||||
>
|
||||
@@ -128,7 +128,7 @@ export default function ServerGroupPage() {
|
||||
className="flex ml-auto self-end sm:self-auto gap-2 flex-wrap shrink-0"
|
||||
delete={{
|
||||
fn: deleteServerGroups,
|
||||
id: selectedRows.map((r) => r.original.group.id),
|
||||
id: selectedRows.map((r) => r.original.group.id!),
|
||||
mutate: mutate,
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -152,7 +152,7 @@ export default function ServicePage() {
|
||||
return (
|
||||
<ActionButtonGroup
|
||||
className="flex gap-2"
|
||||
delete={{ fn: deleteService, id: s.id, mutate: mutate }}
|
||||
delete={{ fn: deleteService, id: s.id!, mutate: mutate }}
|
||||
>
|
||||
<ServiceCard mutate={mutate} data={s} />
|
||||
</ActionButtonGroup>
|
||||
@@ -181,7 +181,7 @@ export default function ServicePage() {
|
||||
className="flex gap-2 flex-wrap shrink-0"
|
||||
delete={{
|
||||
fn: deleteService,
|
||||
id: selectedRows.map((r) => r.original.id),
|
||||
id: selectedRows.map((r) => r.original.id!),
|
||||
mutate: mutate,
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -260,7 +260,7 @@ export default function SettingsPage() {
|
||||
<FormItem>
|
||||
<FormLabel>Telegram Bot Token</FormLabel>
|
||||
<FormControl>
|
||||
<Input placeholder="123456789:ABCDEF..." {...field} />
|
||||
<Input placeholder="123456789:ABCDEF..." {...field} value={field.value as string || ""} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
@@ -273,7 +273,7 @@ export default function SettingsPage() {
|
||||
<FormItem>
|
||||
<FormLabel>Telegram Admin Chat ID</FormLabel>
|
||||
<FormControl>
|
||||
<Input placeholder="12345678" {...field} />
|
||||
<Input placeholder="12345678" {...field} value={field.value as string || ""} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
|
||||
+2
-2
@@ -90,7 +90,7 @@ export default function UserPage() {
|
||||
className="flex gap-2"
|
||||
delete={{
|
||||
fn: deleteUser,
|
||||
id: s.id,
|
||||
id: s.id!,
|
||||
mutate: mutate,
|
||||
}}
|
||||
>
|
||||
@@ -121,7 +121,7 @@ export default function UserPage() {
|
||||
className="flex-2 flex gap-2 ml-auto"
|
||||
delete={{
|
||||
fn: deleteUser,
|
||||
id: selectedRows.map((r) => r.original.id),
|
||||
id: selectedRows.map((r) => r.original.id!),
|
||||
mutate: mutate,
|
||||
}}
|
||||
>
|
||||
|
||||
+3
-3
@@ -98,13 +98,13 @@ export default function WAFPage() {
|
||||
header: t("LastBlockReason"),
|
||||
accessorKey: "lastBlockReason",
|
||||
accessorFn: (row) => row.block_reason,
|
||||
cell: ({ row }) => <span>{wafBlockReasons[row.original.block_reason] || ""}</span>,
|
||||
cell: ({ row }) => <span>{wafBlockReasons[row.original.block_reason!] || ""}</span>,
|
||||
},
|
||||
{
|
||||
header: t("BlockIdentifier"),
|
||||
accessorKey: "BlockIdentifier",
|
||||
accessorFn: (row) => {
|
||||
return wafBlockIdentifiers[row.block_identifier] || row.block_identifier
|
||||
return wafBlockIdentifiers[row.block_identifier!] || row.block_identifier
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -158,7 +158,7 @@ export default function WAFPage() {
|
||||
const renderPagination = () => {
|
||||
if (!data?.pagination) return null
|
||||
|
||||
const { total } = data.pagination
|
||||
const { total = 0 } = data.pagination
|
||||
const totalPages = Math.ceil(total / pageSize)
|
||||
|
||||
const handlePageChange = (newPage: number) => {
|
||||
|
||||
Reference in New Issue
Block a user