import { ActionsMenu, type ActionMenuItem } from "@/Components/actions-menu";
import Typography from "@mui/material/Typography";
import type { Header } from "@/Components/design-elements/Table";
import { Table } from "@/Components/design-elements";
import { Pagination } from "@/Components/design-elements/Table";
import { useClientPagination } from "@/Hooks/useClientPagination";
import type { ProxyResponse } from "@/Types/Proxy";
import { useNavigate } from "react-router";
import { useTranslation } from "react-i18next";
import { useTheme } from "@mui/material";
interface ProxiesTableProps {
proxies: ProxyResponse[];
setSelectedProxy: Function;
}
export const ProxiesTable = ({ proxies, setSelectedProxy }: ProxiesTableProps) => {
const navigate = useNavigate();
const { t } = useTranslation();
const theme = useTheme();
const { pagedRows, paginationProps } = useClientPagination(proxies);
const getActions = (proxy: ProxyResponse): ActionMenuItem[] => {
return [
{
id: 1,
label: t("pages.common.monitors.actions.configure"),
action: () => {
navigate(`/proxies/configure/${proxy.id}`);
},
closeMenu: true,
},
{
id: 2,
label: (
{t("pages.common.monitors.actions.delete")}
),
action: async () => {
setSelectedProxy(proxy);
},
closeMenu: true,
},
];
};
const getHeaders = () => {
const headers: Header[] = [
{
id: "name",
content: t("common.table.headers.name"),
render: (row) => {
return {row?.name};
},
},
{
id: "protocol",
content: t("pages.proxies.table.headers.protocol"),
render: (row) => {
return {row?.protocol};
},
},
{
id: "host",
content: t("pages.proxies.table.headers.host"),
render: (row) => {
return {row?.host};
},
},
{
id: "port",
content: t("pages.proxies.table.headers.port"),
render: (row) => {
return {row?.port};
},
},
{
id: "actions",
content: t("common.table.headers.actions"),
render: (row) => {
return ;
},
},
];
return headers;
};
return (
<>
{
navigate(`/proxies/configure/${row.id}`);
}}
/>
{proxies.length > 0 && }
>
);
};