diff --git a/app/dashboard/src/components/inbounds-card/index.tsx b/app/dashboard/src/components/inbounds-card/index.tsx new file mode 100644 index 0000000..448417f --- /dev/null +++ b/app/dashboard/src/components/inbounds-card/index.tsx @@ -0,0 +1,46 @@ +/* Inbounds Card Component + * + * - name + * - protocol + * - Nodes number +*/ + +import { FC, PropsWithChildren } from 'react' +import { ProtocolType } from 'types' +import { Text, Spacer, VStack, chakra, Flex } from '@chakra-ui/react'; +import { IconBaseStyle } from 'constants/IconBaseStyle'; +import { ServerStackIcon } from '@heroicons/react/24/outline'; +import { SystemPropertyStatus } from 'components/system-property-status'; + +type InboundCardProps = { + tag: string, + protocol: ProtocolType, + nodeName: string; +} + +const InboundsIcon = chakra(ServerStackIcon, IconBaseStyle); + +export const BadgeTag: FC = ({ children }) => { + return ( + + {children} + + ) +} + +export const InboundCard: FC = ({ tag, protocol, nodeName }) => { + return ( + + + {tag} + + + + + + {protocol} + + + + ) +} diff --git a/app/dashboard/src/pages/users/dialog/service-property-status.tsx b/app/dashboard/src/components/system-property-status/index.tsx similarity index 59% rename from app/dashboard/src/pages/users/dialog/service-property-status.tsx rename to app/dashboard/src/components/system-property-status/index.tsx index 63cd06b..4df94c6 100644 --- a/app/dashboard/src/pages/users/dialog/service-property-status.tsx +++ b/app/dashboard/src/components/system-property-status/index.tsx @@ -2,13 +2,12 @@ import { Flex } from '@chakra-ui/react'; import { FC, useState } from 'react'; import { ChakraIcon } from 'types'; - -type ServicePropertyStatusProps = { - value: number; - StatusIcon: ChakraIcon; +type SystemPropertyStatusProps = { + value: number | string; + StatusIcon: ChakraIcon; } -export const ServicePropertyStatus: FC = ({ value, StatusIcon }) => { +export const SystemPropertyStatus: FC = ({ value, StatusIcon }) => { const [valueState,] = useState(value); return ( diff --git a/app/dashboard/src/pages/services/dialog/inbounds-field.tsx b/app/dashboard/src/pages/services/dialog/inbounds-field.tsx index 32a320b..a2a2ecc 100644 --- a/app/dashboard/src/pages/services/dialog/inbounds-field.tsx +++ b/app/dashboard/src/pages/services/dialog/inbounds-field.tsx @@ -1,8 +1,9 @@ -import { FormControl, FormLabel, FormErrorMessage, Center, Spinner, Text, Spacer, Flex } from '@chakra-ui/react'; +import { FormControl, FormLabel, FormErrorMessage, Center, Spinner } from '@chakra-ui/react'; import { Inbounds, InboundType } from 'types'; import { TFunction } from 'i18next'; import { Controller } from 'react-hook-form'; import { InboundsSelectList } from './inbounds-select-list'; +import { InboundCard } from 'components/inbounds-card'; interface InboundsFieldProps { @@ -29,14 +30,7 @@ export const InboundsField = ({ form, t, inbounds }: InboundsFieldProps) => { ( - <> - - {inbound.tag} {inbound.protocol} - - - - - + )} /> ); diff --git a/app/dashboard/src/pages/services/dialog/inbounds-select-list.tsx b/app/dashboard/src/pages/services/dialog/inbounds-select-list.tsx index fd665dc..84222e9 100644 --- a/app/dashboard/src/pages/services/dialog/inbounds-select-list.tsx +++ b/app/dashboard/src/pages/services/dialog/inbounds-select-list.tsx @@ -1,12 +1,10 @@ import { - Box, - Flex, Stack, } from '@chakra-ui/react'; import { ListCheckBox } from 'components/list-check-box'; import { Inbounds, InboundType } from 'types'; -import { forwardRef, ReactNode } from 'react'; +import { forwardRef, Fragment, ReactNode } from 'react'; import { useFormContext, } from 'react-hook-form'; @@ -36,16 +34,14 @@ export const InboundsSelectList = forwardRef {list.map((inbound: InboundType) => ( - - - handleInboundToggle(inbound.id)} - value={String(inbound.id)} - renderContent={() => renderCheckboxContent(inbound)} - /> - - + + handleInboundToggle(inbound.id)} + value={String(inbound.id)} + renderContent={() => renderCheckboxContent(inbound)} + /> + ))} ); diff --git a/app/dashboard/src/pages/services/dialog/index.tsx b/app/dashboard/src/pages/services/dialog/index.tsx index c79797c..63580d1 100644 --- a/app/dashboard/src/pages/services/dialog/index.tsx +++ b/app/dashboard/src/pages/services/dialog/index.tsx @@ -130,7 +130,7 @@ export const ServiceDialog: FC = () => { const disabled = loading; return ( - + diff --git a/app/dashboard/src/pages/users/dialog/services-field.tsx b/app/dashboard/src/pages/users/dialog/services-field.tsx index e81e283..7cfd724 100644 --- a/app/dashboard/src/pages/users/dialog/services-field.tsx +++ b/app/dashboard/src/pages/users/dialog/services-field.tsx @@ -4,7 +4,7 @@ import { IconBaseStyle } from 'constants/IconBaseStyle'; import { TFunction } from 'i18next'; import { Controller } from 'react-hook-form'; import { Service } from 'types'; -import { ServicePropertyStatus } from './service-property-status'; +import { SystemPropertyStatus } from 'components/system-property-status'; import { ServicesSelectList } from './services-select-list'; const UsersServiceIcon = chakra(UsersIcon, IconBaseStyle); @@ -39,9 +39,9 @@ export const ServicesField = ({ form, t, services }: ServicesFieldProps) => { {service.name} - + / - + )} diff --git a/app/dashboard/src/types/inbounds.ts b/app/dashboard/src/types/inbounds.ts index 4e3caae..349729c 100644 --- a/app/dashboard/src/types/inbounds.ts +++ b/app/dashboard/src/types/inbounds.ts @@ -1,10 +1,12 @@ import { ProtocolType } from './protocol'; +import { NodeType } from 'stores'; export type InboundType = { id: number; tag: string; protocol: ProtocolType; network: string; + node: NodeType; tls: string; port?: number; };