gitscope
← marzneshin / v0.6.5 / dashboard/src/modules/hosts/dialogs/settings/index.tsx
https://dev.kronoz.win/r/marzneshin.git
dashboard/src/modules/hosts/dialogs/settings/index.tsx · TypeScript
Blame Raw
 1import { type FC } from "react";
 2import {
 3    SettingsDialogProps,
 4    SettingsDialog,
 5    Table,
 6    TableBody,
 7    TableRowWithCell,
 8} from "@marzneshin/common/components";
 9import { useTranslation } from "react-i18next";
10
11interface HostWithProfileSchemaType {
12    remark: string;
13    address: string;
14    weight?: number | null;
15    port?: string | number | null;
16    host?: string;
17    path?: string;
18    sni?: string;
19    alpn?: string;
20}
21
22interface HostsSettingsDialogProps extends SettingsDialogProps {
23    onOpenChange: (state: boolean) => void;
24    onClose: () => void;
25    open: boolean;
26    entity: HostWithProfileSchemaType;
27}
28
29export const HostSettingsDialog: FC<HostsSettingsDialogProps> = ({
30    onOpenChange,
31    open,
32    entity,
33    onClose,
34}) => {
35    const { t } = useTranslation();
36
37    return (
38        <SettingsDialog open={open} onClose={onClose} onOpenChange={onOpenChange}>
39            <Table>
40                <TableBody>
41                    <TableRowWithCell label={t("remark")} value={entity.remark} />
42                    <TableRowWithCell label={t("address")} value={entity.address} />
43                    <TableRowWithCell
44                        label={t("port")}
45                        value={entity.port?.toString() ?? ""}
46                    />
47                    <TableRowWithCell
48                        label={t("host")}
49                        value={entity.host ?? ""}
50                    />
51                    <TableRowWithCell
52                        label={t("path")}
53                        value={entity.path ?? ""}
54                    />
55                    <TableRowWithCell
56                        label={t("sni")}
57                        value={entity.sni ?? ""}
58                    />
59                    <TableRowWithCell
60                        label={t("alpn")}
61                        value={entity.alpn ?? ""}
62                    />
63                </TableBody>
64            </Table>
65        </SettingsDialog>
66    );
67};