Compare commits
3 Commits
819902eafb
...
202a18f73d
Author | SHA1 | Date | |
---|---|---|---|
|
202a18f73d | ||
b48ab86aab | |||
|
f35f469547 |
@ -20,11 +20,11 @@ import {
|
||||
} from '@mui/material'
|
||||
import { MuiFileInput } from 'mui-file-input'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { Link, useNavigate } from 'react-router-dom'
|
||||
import placeholderAvatar from '../../assets/images/nostr-logo.jpg'
|
||||
import { LoadingSpinner } from '../../components/LoadingSpinner'
|
||||
import { MetadataController, NostrController } from '../../controllers'
|
||||
import { getProfileRoute } from '../../routes'
|
||||
import { appPrivateRoutes, getProfileRoute } from '../../routes'
|
||||
import { ProfileMetadata, User, UserRole } from '../../types'
|
||||
import {
|
||||
encryptArrayBuffer,
|
||||
@ -44,7 +44,8 @@ import JSZip from 'jszip'
|
||||
import { useSelector } from 'react-redux'
|
||||
import { State } from '../../store/rootReducer'
|
||||
|
||||
export const SignPage = () => {
|
||||
export const CreatePage = () => {
|
||||
const navigate = useNavigate()
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
const [loadingSpinnerDesc, setLoadingSpinnerDesc] = useState('')
|
||||
|
||||
@ -63,6 +64,22 @@ export const SignPage = () => {
|
||||
|
||||
const nostrController = NostrController.getInstance()
|
||||
|
||||
useEffect(() => {
|
||||
if (usersPubkey) {
|
||||
setUsers((prev) => {
|
||||
const existingUserIndex = prev.findIndex(
|
||||
(user) => user.pubkey === usersPubkey
|
||||
)
|
||||
|
||||
// make logged in user the first signer by default
|
||||
if (existingUserIndex === -1)
|
||||
return [{ pubkey: usersPubkey, role: UserRole.signer }, ...prev]
|
||||
|
||||
return prev
|
||||
})
|
||||
}
|
||||
}, [usersPubkey])
|
||||
|
||||
const handleAddUser = async () => {
|
||||
setError(undefined)
|
||||
|
||||
@ -89,8 +106,6 @@ export const SignPage = () => {
|
||||
|
||||
return updatedUsers
|
||||
})
|
||||
|
||||
setUserInput('')
|
||||
}
|
||||
|
||||
if (userInput.startsWith('npub')) {
|
||||
@ -168,7 +183,7 @@ export const SignPage = () => {
|
||||
)
|
||||
}
|
||||
|
||||
const handleSign = async () => {
|
||||
const handleCreate = async () => {
|
||||
if (users.length === 0) {
|
||||
toast.error(
|
||||
'No signer/viewer is provided. At least add one signer or viewer.'
|
||||
@ -329,8 +344,13 @@ export const SignPage = () => {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
setIsLoading(false)
|
||||
|
||||
navigate(
|
||||
`${appPrivateRoutes.verify}?file=${encodeURIComponent(
|
||||
fileUrl
|
||||
)}&key=${encodeURIComponent(encryptionKey)}`
|
||||
)
|
||||
}
|
||||
|
||||
if (authUrl) {
|
||||
@ -413,8 +433,8 @@ export const SignPage = () => {
|
||||
handleRemoveUser={handleRemoveUser}
|
||||
/>
|
||||
<Box sx={{ mt: 1, display: 'flex', justifyContent: 'center' }}>
|
||||
<Button onClick={handleSign} variant="contained">
|
||||
Sign
|
||||
<Button onClick={handleCreate} variant="contained">
|
||||
Create
|
||||
</Button>
|
||||
</Box>
|
||||
</>
|
@ -9,10 +9,10 @@ export const HomePage = () => {
|
||||
return (
|
||||
<Box className={styles.container}>
|
||||
<Button
|
||||
onClick={() => navigate(appPrivateRoutes.sign)}
|
||||
onClick={() => navigate(appPrivateRoutes.create)}
|
||||
variant="contained"
|
||||
>
|
||||
Sign
|
||||
Create
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => navigate(appPrivateRoutes.verify)}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { HomePage } from '../pages/home'
|
||||
import { SignPage } from '../pages/sign'
|
||||
import { CreatePage } from '../pages/create'
|
||||
import { LandingPage } from '../pages/landing/LandingPage'
|
||||
import { Login } from '../pages/login'
|
||||
import { ProfilePage } from '../pages/profile'
|
||||
@ -8,7 +8,7 @@ import { VerifyPage } from '../pages/verify'
|
||||
|
||||
export const appPrivateRoutes = {
|
||||
homePage: '/',
|
||||
sign: '/sign',
|
||||
create: '/create',
|
||||
verify: '/verify'
|
||||
}
|
||||
|
||||
@ -45,8 +45,8 @@ export const privateRoutes = [
|
||||
element: <HomePage />
|
||||
},
|
||||
{
|
||||
path: appPrivateRoutes.sign,
|
||||
element: <SignPage />
|
||||
path: appPrivateRoutes.create,
|
||||
element: <CreatePage />
|
||||
},
|
||||
{
|
||||
path: appPrivateRoutes.verify,
|
||||
|
Loading…
Reference in New Issue
Block a user