diff --git a/bun.lockb b/bun.lockb index 6b1f8bf..bcb17b4 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 823cf5b..5e3b31c 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "next": "^15.1.5", "next-i18next": "^15.4.2", "next-nprogress-bar": "^2.4.3", + "qrcode.react": "^4.2.0", "react": "^19.0.0", "react-dom": "^19.0.0", "react-hook-form": "^7.54.2", diff --git a/src/pages/realms/[id].tsx b/src/pages/realms/[id].tsx index cada062..4b01fd9 100644 --- a/src/pages/realms/[id].tsx +++ b/src/pages/realms/[id].tsx @@ -14,10 +14,13 @@ import { ListItemIcon, ListItemText, Typography, + useTheme, } from '@mui/material' import { GetServerSideProps } from 'next' import { checkAuthenticatedClient, getAttachmentUrl, redirectToLogin, sni, useUserStore } from 'solar-js-sdk' -import { useEffect, useState } from 'react' +import { useEffect, useMemo, useState } from 'react' +import { useSearchParams } from 'next/navigation' +import { QRCodeSVG } from 'qrcode.react' import PublicIcon from '@mui/icons-material/Public' import ErrorIcon from '@mui/icons-material/Error' @@ -48,6 +51,10 @@ export default function Realm({ realm }: any) { const [publicChannels, setPublicChannels] = useState([]) const [checkedChannels, setCheckedChannels] = useState([]) + const searchParams = useSearchParams() + + const isShare = useMemo(() => searchParams.has('share'), [searchParams]) + function handleCheckChannel(value: string) { const currentIndex = checkedChannels.indexOf(value) const newChecked = [...checkedChannels] @@ -104,6 +111,8 @@ export default function Realm({ realm }: any) { } } + const theme = useTheme() + return ( {realm.description} - {publicChannels.length > 0 && ( - - - Public channels in this realm you can join + {isShare ? ( + + + + + Scan the QR Code above to join - - {publicChannels.map((value) => { - const labelId = `checkbox-list-label-${value}` - - return ( - - handleCheckChannel(value.alias)} - dense - > - - - - - - - ) - })} - - )} - - {realm.isCommunity && ( - - - - - A community realm, you can join it as you wish. - - - - )} - - - } severity="error"> - {error} - - - - {joined ? ( - - Joined, check it out in the app - ) : ( - + <> + {publicChannels.length > 0 && ( + + + Public channels in this realm you can join + + + {publicChannels.map((value) => { + const labelId = `checkbox-list-label-${value}` + + return ( + + handleCheckChannel(value.alias)} + dense + > + + + + + + + ) + })} + + + )} + + {realm.isCommunity && ( + + + + + A community realm, you can join it as you wish. + + + + )} + + + } severity="error"> + {error} + + + + {joined ? ( + + Joined, check it out in the app + + ) : ( + + )} + )}