@@ -12,6 +12,7 @@ import {
1212 ModalHeader ,
1313 Select ,
1414 SelectItem ,
15+ Snippet ,
1516 Table ,
1617 TableBody ,
1718 TableCell ,
@@ -20,9 +21,10 @@ import {
2021 TableRow ,
2122 useDisclosure
2223} from '@nextui-org/react'
23- import { IconPlus , IconRefresh , IconTrash } from '@tabler/icons-react'
24+ import { IconPlus , IconQrcode , IconRefresh , IconTrash } from '@tabler/icons-react'
2425import dayjs from 'dayjs'
2526import { differenceWith } from 'lodash'
27+ import { QRCodeSVG } from 'qrcode.react'
2628import { FC , Fragment , Key , useCallback , useMemo } from 'react'
2729import { useTranslation } from 'react-i18next'
2830import {
@@ -44,6 +46,7 @@ type Node = {
4446 name : string
4547 tag ?: string | null
4648 protocol : string
49+ link : string
4750 subscriptionID ?: string | null
4851}
4952
@@ -226,6 +229,35 @@ const GroupContent: FC<{
226229 )
227230}
228231
232+ const CheckNodeQRCodeButton : FC < { name : string ; link : string } > = ( { name, link } ) => {
233+ const {
234+ isOpen : isCheckNodeQRCodeOpen ,
235+ onOpenChange : onCheckNodeQRCodeOpenChange ,
236+ onOpen : onCheckNodeQRCodeOpen
237+ } = useDisclosure ( )
238+
239+ return (
240+ < Fragment >
241+ < Button color = "primary" isIconOnly onPress = { onCheckNodeQRCodeOpen } >
242+ < IconQrcode />
243+ </ Button >
244+
245+ < Modal isOpen = { isCheckNodeQRCodeOpen } onOpenChange = { onCheckNodeQRCodeOpenChange } >
246+ < ModalContent >
247+ < ModalHeader > { name } </ ModalHeader >
248+ < ModalBody className = "flex flex-col items-center gap-8 p-8" >
249+ < QRCodeSVG className = "h-64 w-64" value = { link } />
250+
251+ < Snippet symbol = { false } variant = "bordered" >
252+ < span className = "whitespace-break-spaces break-all" > { link } </ span >
253+ </ Snippet >
254+ </ ModalBody >
255+ </ ModalContent >
256+ </ Modal >
257+ </ Fragment >
258+ )
259+ }
260+
229261const RemoveNodeButton : FC < { id : string ; name : string ; refetch : ( ) => Promise < unknown > } > = ( { id, name, refetch } ) => {
230262 const { t } = useTranslation ( )
231263
@@ -297,7 +329,13 @@ const NodeTable: FC<{
297329 return item . tag || item . name
298330
299331 case 'action' :
300- return < RemoveNodeButton id = { item . id } name = { item . tag || item . name } refetch = { refetch } />
332+ return (
333+ < div className = "flex items-center gap-2" >
334+ < CheckNodeQRCodeButton name = { item . tag || item . name } link = { item . link } />
335+
336+ < RemoveNodeButton id = { item . id } name = { item . tag || item . name } refetch = { refetch } />
337+ </ div >
338+ )
301339
302340 default :
303341 return getKeyValue ( item , columnKey )
0 commit comments