feat: added nsecbunker setting page
All checks were successful
Release / build_and_release (push) Successful in 51s

This commit is contained in:
Sabir Hassan 2024-03-22 12:46:57 +05:00
parent 4973721608
commit b2a8cff907
5 changed files with 103 additions and 5 deletions

View File

@ -17,7 +17,11 @@ import Username from '../username'
import { Link, useNavigate } from 'react-router-dom' import { Link, useNavigate } from 'react-router-dom'
import nostrichAvatar from '../../assets/images/avatar.png' import nostrichAvatar from '../../assets/images/avatar.png'
import nostrichLogo from '../../assets/images/nostr-logo.jpg' import nostrichLogo from '../../assets/images/nostr-logo.jpg'
import { appPublicRoutes, getProfileRoute } from '../../routes' import {
appPrivateRoutes,
appPublicRoutes,
getProfileRoute
} from '../../routes'
import { import {
clearAuthToken, clearAuthToken,
saveNsecBunkerDelegatedKey, saveNsecBunkerDelegatedKey,
@ -25,6 +29,7 @@ import {
} from '../../utils' } from '../../utils'
import styles from './style.module.scss' import styles from './style.module.scss'
import { NostrController } from '../../controllers' import { NostrController } from '../../controllers'
import { LoginMethods } from '../../store/auth/types'
export const AppBar = () => { export const AppBar = () => {
const navigate = useNavigate() const navigate = useNavigate()
@ -142,6 +147,16 @@ export const AppBar = () => {
> >
Profile Profile
</MenuItem> </MenuItem>
{authState.loginMethod === LoginMethods.nsecBunker && (
<MenuItem
onClick={() => navigate(appPrivateRoutes.nsecbunker)}
sx={{
justifyContent: 'center'
}}
>
Nsecbunker
</MenuItem>
)}
<Link <Link
to={appPublicRoutes.help} to={appPublicRoutes.help}
target='_blank' target='_blank'

View File

@ -184,6 +184,7 @@ export const Login = () => {
dispatch(updateLoginMethod(LoginMethods.nsecBunker)) dispatch(updateLoginMethod(LoginMethods.nsecBunker))
dispatch(updateNsecbunkerPubkey(pubkey)) dispatch(updateNsecbunkerPubkey(pubkey))
dispatch(updateNsecbunkerRelay(relays![0]))
setLoadingSpinnerDesc('Authenticating and finding metadata') setLoadingSpinnerDesc('Authenticating and finding metadata')

View File

@ -0,0 +1,69 @@
import {
IconButton,
InputAdornment,
List,
ListItem,
ListSubheader,
TextField
} from '@mui/material'
import { ContentCopy } from '@mui/icons-material'
import { useSelector } from 'react-redux'
import { State } from '../../store/rootReducer'
import styles from './style.module.scss'
import { toast } from 'react-toastify'
export const Nsecbunker = () => {
const authState = useSelector((state: State) => state.auth)
const nsecbunkerConnectionString = `bunker://${authState?.nsecBunkerPubkey}?relay=${authState?.nsecbunkerRelay}`
return (
<List
sx={{
bgcolor: 'background.paper',
marginTop: 2
}}
subheader={
<ListSubheader
sx={{
paddingBottom: 1,
paddingTop: 1,
fontSize: '1.5rem'
}}
className={styles.subHeader}
>
Nsecbunker Setting
</ListSubheader>
}
>
<ListItem sx={{ marginTop: 1 }}>
<TextField
label='Nsecbunker connection string'
variant='outlined'
size='small'
className={styles.textField}
value={nsecbunkerConnectionString}
disabled
InputProps={{
endAdornment: (
<InputAdornment position='end'>
<IconButton
aria-label='copy value icon button'
onClick={() => {
navigator.clipboard.writeText(nsecbunkerConnectionString)
toast.success('Copied to clipboard', {
autoClose: 1000,
hideProgressBar: true
})
}}
>
<ContentCopy />
</IconButton>
</InputAdornment>
)
}}
/>
</ListItem>
</List>
)
}

View File

@ -0,0 +1,7 @@
.textField {
width: 100%;
}
.subHeader {
border-bottom: 0.5px solid;
}

View File

@ -1,8 +1,14 @@
import { LandingPage } from '../pages/landing/LandingPage' import { LandingPage } from '../pages/landing/LandingPage'
import { Login } from '../pages/login' import { Login } from '../pages/login'
import { Nsecbunker } from '../pages/nsecbunker'
import { ProfilePage } from '../pages/profile' import { ProfilePage } from '../pages/profile'
import { hexToNpub } from '../utils' import { hexToNpub } from '../utils'
export const appPrivateRoutes = {
homePage: '/',
nsecbunker: '/nsecbunker'
}
export const appPublicRoutes = { export const appPublicRoutes = {
profile: '/profile/:npub', profile: '/profile/:npub',
login: '/login', login: '/login',
@ -12,10 +18,6 @@ export const appPublicRoutes = {
export const getProfileRoute = (hexKey: string) => export const getProfileRoute = (hexKey: string) =>
appPublicRoutes.profile.replace(':npub', hexToNpub(hexKey)) appPublicRoutes.profile.replace(':npub', hexToNpub(hexKey))
export const appPrivateRoutes = {
homePage: '/'
}
export const publicRoutes = [ export const publicRoutes = [
{ {
path: appPublicRoutes.login, path: appPublicRoutes.login,
@ -32,5 +34,9 @@ export const privateRoutes = [
{ {
path: appPrivateRoutes.homePage, path: appPrivateRoutes.homePage,
element: <LandingPage /> element: <LandingPage />
},
{
path: appPrivateRoutes.nsecbunker,
element: <Nsecbunker />
} }
] ]