import { useState } from "react";
import { Virtuoso } from "react-virtuoso";
import {
Box,
Collapse,
Divider,
IconButton,
List,
ListItem,
ListItemButton,
ListItemIcon,
ListItemText,
} from "@mui/material";
import {
SendRounded,
ExpandLessRounded,
ExpandMoreRounded,
MyLocationRounded,
NetworkCheckRounded,
CheckCircleOutlineRounded,
} from "@mui/icons-material";
import services from "../services";
import type { ProxyItem, ProxyGroupItem } from "../services/proxy";
interface ItemProps {
proxy: ProxyItem;
selected: boolean;
onClick?: (name: string) => void;
}
const Item = ({ proxy, selected, onClick }: ItemProps) => {
return (
onClick?.(proxy.name)}
sx={{ borderRadius: 1, py: 0.5 }}
>
{selected && }
);
};
interface Props {
group: ProxyGroupItem;
}
const ProxyGroup = ({ group }: Props) => {
const [open, setOpen] = useState(false);
const [now, setNow] = useState(group.now);
const proxies = group.all ?? [];
const onUpdate = async (name: string) => {
// can not call update
if (group.type !== "Selector") {
// Todo
// error Tips
return;
}
const oldValue = now;
try {
setNow(name);
await services.updateProxy(group.name, name);
} catch {
setNow(oldValue);
// Todo
// error tips
}
};
return (
<>
setOpen(!open)}>
{now}
>
}
secondaryTypographyProps={{
sx: { display: "flex", alignItems: "center" },
}}
/>
{open ? : }
{proxies.length >= 10 ? (
(
)}
/>
) : (
{proxies.map((proxy) => (
))}
)}
>
);
};
export default ProxyGroup;