feat: streamline startup navigation
This commit is contained in:
parent
5639b01998
commit
290bc8481d
@ -43,10 +43,10 @@ const MainProject = () => {
|
||||
},
|
||||
]
|
||||
|
||||
const onCreateNewProjectHandler = (projectName: string) => {
|
||||
const onCreateNewProjectHandler = async (projectName: string) => {
|
||||
setIsNewProjectModalOpen(false)
|
||||
setCanPopoverBeOpen(true)
|
||||
createNewProject(projectName)
|
||||
await createNewProject(projectName)
|
||||
setSelectedMainPage(mainPages.WORKSPACE)
|
||||
}
|
||||
|
||||
|
@ -3,23 +3,27 @@ import { useProject } from '../../context/Project/provider'
|
||||
import { EnvelopeIcon } from '@heroicons/react/24/outline'
|
||||
import UserAvatar from '../utils/UserAvatar'
|
||||
import { useRef, useState } from 'react'
|
||||
import { useNavigation } from '../../context/Navigation/provider'
|
||||
import { mainPages } from '../../context/Navigation/types'
|
||||
|
||||
const User = () => {
|
||||
const { currentSession, requestUpdateCurrentUser, requestChooseUserAvatar } = useProject()
|
||||
const { setSelectedMainPage } = useNavigation()
|
||||
|
||||
const firstNameRef = useRef<HTMLInputElement>(null)
|
||||
const lastNameRef = useRef<HTMLInputElement>(null)
|
||||
const emailRef = useRef<HTMLInputElement>(null)
|
||||
const [avatarPath, setAvatarPath] = useState(currentSession?.user?.avatarPath || '')
|
||||
|
||||
const onSaveButtonClickHandler = () => {
|
||||
requestUpdateCurrentUser({
|
||||
localId: currentSession?.user.localId,
|
||||
const onSaveButtonClickHandler = async () => {
|
||||
await requestUpdateCurrentUser({
|
||||
localId: currentSession?.user?.localId,
|
||||
firstName: firstNameRef?.current?.value,
|
||||
lastName: lastNameRef?.current?.value,
|
||||
email: emailRef?.current?.value,
|
||||
avatarPath: avatarPath || ''
|
||||
})
|
||||
setSelectedMainPage(mainPages.WORKSPACE)
|
||||
}
|
||||
|
||||
const onAvatarSelectButtonClickHandler = async () => {
|
||||
@ -42,7 +46,9 @@ const User = () => {
|
||||
<div className="space-y-1">
|
||||
<h3 className="text-lg font-medium leading-6 text-gray-900">Profile</h3>
|
||||
<p className="max-w-2xl text-sm text-gray-500">
|
||||
This information will be stored in a database if connected to a hosted account, so be careful what you share.
|
||||
This information will be stored in a database if connected to a hosted account.
|
||||
<br />
|
||||
<em className='text-xs'>For a local user on this machine, you may save without adding any user details.</em>
|
||||
</p>
|
||||
</div>
|
||||
<div className="mt-6">
|
||||
|
@ -13,7 +13,7 @@ export function useNavigation() {
|
||||
type Props = { children: ReactNode, navigationProps: NavigationProps }
|
||||
export function NavigationProvidor({ children, navigationProps }: Props) {
|
||||
const [selectedWorkspace, setSelectedWorkspace] = useState<workspaces>(navigationProps.selectedWorkspace)
|
||||
const [selectedMainPage, setSelectedMainPage] = useState<mainPages>(mainPages.SELECTPROJECT)
|
||||
const [selectedMainPage, setSelectedMainPage] = useState<mainPages>(navigationProps.selectedMainPage)
|
||||
|
||||
const value = {
|
||||
selectedWorkspace,
|
||||
|
@ -87,7 +87,6 @@ export function ProjectProvider({ children, projectProps }: Props) {
|
||||
|
||||
const getUserMarkdownByDocumentId = async (documentId: string): Promise<ipc.UserMarkdown> => {
|
||||
let response: ipc.UserMarkdown = new ipc.UserMarkdown({})
|
||||
console.log(documentId)
|
||||
try {
|
||||
response = await GetUserMarkdownByDocumentId(documentId)
|
||||
} catch (err) {
|
||||
|
@ -6,7 +6,7 @@ import '../styles/globals.css'
|
||||
import { ipc } from '../wailsjs/wailsjs/go/models'
|
||||
import '../styles/globals.css'
|
||||
import { NavigationProvidor } from '../context/Navigation/provider'
|
||||
import { workspaces } from '../context/Navigation/types'
|
||||
import { mainPages, workspaces } from '../context/Navigation/types'
|
||||
|
||||
const initialProjectProps = {
|
||||
id: '',
|
||||
@ -15,7 +15,8 @@ const initialProjectProps = {
|
||||
}
|
||||
|
||||
const initialNavigationProps = {
|
||||
selectedWorkspace: workspaces.PROCESSOR
|
||||
selectedWorkspace: workspaces.PROCESSOR,
|
||||
selectedMainPage: mainPages.EDITUSER
|
||||
}
|
||||
|
||||
export default function MainAppLayout({ Component, pageProps }: AppProps) {
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { NextPage } from 'next'
|
||||
import { useEffect } from 'react'
|
||||
import MainHead from '../components/head'
|
||||
import MainProject from '../components/project/Main'
|
||||
import User from '../components/settings/User'
|
||||
@ -11,7 +12,12 @@ import { useProject } from '../context/Project/provider'
|
||||
const Home: NextPage = () => {
|
||||
|
||||
const { currentSession } = useProject()
|
||||
const { selectedMainPage } = useNavigation()
|
||||
const { selectedMainPage, setSelectedMainPage } = useNavigation()
|
||||
|
||||
useEffect(() => {
|
||||
if (!currentSession?.user?.localId) setSelectedMainPage(mainPages.EDITUSER)
|
||||
else if (!currentSession?.project?.id) setSelectedMainPage(mainPages.SELECTPROJECT)
|
||||
},)
|
||||
|
||||
const renderSelectedMainPage = () => {
|
||||
if (selectedMainPage === mainPages.SELECTPROJECT) return <MainProject />
|
||||
|
Loading…
x
Reference in New Issue
Block a user