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)
 | 
					    setIsNewProjectModalOpen(false)
 | 
				
			||||||
    setCanPopoverBeOpen(true)
 | 
					    setCanPopoverBeOpen(true)
 | 
				
			||||||
    createNewProject(projectName)
 | 
					    await createNewProject(projectName)
 | 
				
			||||||
    setSelectedMainPage(mainPages.WORKSPACE)
 | 
					    setSelectedMainPage(mainPages.WORKSPACE)
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -3,23 +3,27 @@ import { useProject } from '../../context/Project/provider'
 | 
				
			|||||||
import { EnvelopeIcon } from '@heroicons/react/24/outline'
 | 
					import { EnvelopeIcon } from '@heroicons/react/24/outline'
 | 
				
			||||||
import UserAvatar from '../utils/UserAvatar'
 | 
					import UserAvatar from '../utils/UserAvatar'
 | 
				
			||||||
import { useRef, useState } from 'react'
 | 
					import { useRef, useState } from 'react'
 | 
				
			||||||
 | 
					import { useNavigation } from '../../context/Navigation/provider'
 | 
				
			||||||
 | 
					import { mainPages } from '../../context/Navigation/types'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const User = () => {
 | 
					const User = () => {
 | 
				
			||||||
  const { currentSession, requestUpdateCurrentUser, requestChooseUserAvatar } = useProject()
 | 
					  const { currentSession, requestUpdateCurrentUser, requestChooseUserAvatar } = useProject()
 | 
				
			||||||
 | 
					  const { setSelectedMainPage } = useNavigation()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const firstNameRef = useRef<HTMLInputElement>(null)
 | 
					  const firstNameRef = useRef<HTMLInputElement>(null)
 | 
				
			||||||
  const lastNameRef = useRef<HTMLInputElement>(null)
 | 
					  const lastNameRef = useRef<HTMLInputElement>(null)
 | 
				
			||||||
  const emailRef = useRef<HTMLInputElement>(null)
 | 
					  const emailRef = useRef<HTMLInputElement>(null)
 | 
				
			||||||
  const [avatarPath, setAvatarPath] = useState(currentSession?.user?.avatarPath || '')
 | 
					  const [avatarPath, setAvatarPath] = useState(currentSession?.user?.avatarPath || '')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const onSaveButtonClickHandler = () => {
 | 
					  const onSaveButtonClickHandler = async () => {
 | 
				
			||||||
    requestUpdateCurrentUser({
 | 
					    await requestUpdateCurrentUser({
 | 
				
			||||||
      localId: currentSession?.user.localId,
 | 
					      localId: currentSession?.user?.localId,
 | 
				
			||||||
      firstName: firstNameRef?.current?.value,
 | 
					      firstName: firstNameRef?.current?.value,
 | 
				
			||||||
      lastName: lastNameRef?.current?.value,
 | 
					      lastName: lastNameRef?.current?.value,
 | 
				
			||||||
      email: emailRef?.current?.value,
 | 
					      email: emailRef?.current?.value,
 | 
				
			||||||
      avatarPath: avatarPath || ''
 | 
					      avatarPath: avatarPath || ''
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
 | 
					    setSelectedMainPage(mainPages.WORKSPACE)
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const onAvatarSelectButtonClickHandler = async () => {
 | 
					  const onAvatarSelectButtonClickHandler = async () => {
 | 
				
			||||||
@ -42,7 +46,9 @@ const User = () => {
 | 
				
			|||||||
              <div className="space-y-1">
 | 
					              <div className="space-y-1">
 | 
				
			||||||
                <h3 className="text-lg font-medium leading-6 text-gray-900">Profile</h3>
 | 
					                <h3 className="text-lg font-medium leading-6 text-gray-900">Profile</h3>
 | 
				
			||||||
                <p className="max-w-2xl text-sm text-gray-500">
 | 
					                <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>
 | 
					                </p>
 | 
				
			||||||
              </div>
 | 
					              </div>
 | 
				
			||||||
              <div className="mt-6">
 | 
					              <div className="mt-6">
 | 
				
			||||||
 | 
				
			|||||||
@ -13,7 +13,7 @@ export function useNavigation() {
 | 
				
			|||||||
type Props = { children: ReactNode, navigationProps: NavigationProps }
 | 
					type Props = { children: ReactNode, navigationProps: NavigationProps }
 | 
				
			||||||
export function NavigationProvidor({ children, navigationProps }: Props) {
 | 
					export function NavigationProvidor({ children, navigationProps }: Props) {
 | 
				
			||||||
  const [selectedWorkspace, setSelectedWorkspace] = useState<workspaces>(navigationProps.selectedWorkspace)
 | 
					  const [selectedWorkspace, setSelectedWorkspace] = useState<workspaces>(navigationProps.selectedWorkspace)
 | 
				
			||||||
  const [selectedMainPage, setSelectedMainPage] = useState<mainPages>(mainPages.SELECTPROJECT)
 | 
					  const [selectedMainPage, setSelectedMainPage] = useState<mainPages>(navigationProps.selectedMainPage)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const value = {
 | 
					  const value = {
 | 
				
			||||||
    selectedWorkspace,
 | 
					    selectedWorkspace,
 | 
				
			||||||
 | 
				
			|||||||
@ -87,7 +87,6 @@ export function ProjectProvider({ children, projectProps }: Props) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  const getUserMarkdownByDocumentId = async (documentId: string): Promise<ipc.UserMarkdown> => {
 | 
					  const getUserMarkdownByDocumentId = async (documentId: string): Promise<ipc.UserMarkdown> => {
 | 
				
			||||||
    let response: ipc.UserMarkdown = new ipc.UserMarkdown({})
 | 
					    let response: ipc.UserMarkdown = new ipc.UserMarkdown({})
 | 
				
			||||||
    console.log(documentId)
 | 
					 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
      response = await GetUserMarkdownByDocumentId(documentId)
 | 
					      response = await GetUserMarkdownByDocumentId(documentId)
 | 
				
			||||||
    } catch (err) {
 | 
					    } catch (err) {
 | 
				
			||||||
 | 
				
			|||||||
@ -6,7 +6,7 @@ import '../styles/globals.css'
 | 
				
			|||||||
import { ipc } from '../wailsjs/wailsjs/go/models'
 | 
					import { ipc } from '../wailsjs/wailsjs/go/models'
 | 
				
			||||||
import '../styles/globals.css'
 | 
					import '../styles/globals.css'
 | 
				
			||||||
import { NavigationProvidor } from '../context/Navigation/provider'
 | 
					import { NavigationProvidor } from '../context/Navigation/provider'
 | 
				
			||||||
import { workspaces } from '../context/Navigation/types'
 | 
					import { mainPages, workspaces } from '../context/Navigation/types'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const initialProjectProps = {
 | 
					const initialProjectProps = {
 | 
				
			||||||
  id: '',
 | 
					  id: '',
 | 
				
			||||||
@ -15,7 +15,8 @@ const initialProjectProps = {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const initialNavigationProps = {
 | 
					const initialNavigationProps = {
 | 
				
			||||||
  selectedWorkspace: workspaces.PROCESSOR
 | 
					  selectedWorkspace: workspaces.PROCESSOR,
 | 
				
			||||||
 | 
					  selectedMainPage: mainPages.EDITUSER
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default function MainAppLayout({ Component, pageProps }: AppProps) {
 | 
					export default function MainAppLayout({ Component, pageProps }: AppProps) {
 | 
				
			||||||
 | 
				
			|||||||
@ -1,4 +1,5 @@
 | 
				
			|||||||
import { NextPage } from 'next'
 | 
					import { NextPage } from 'next'
 | 
				
			||||||
 | 
					import { useEffect } from 'react'
 | 
				
			||||||
import MainHead from '../components/head'
 | 
					import MainHead from '../components/head'
 | 
				
			||||||
import MainProject from '../components/project/Main'
 | 
					import MainProject from '../components/project/Main'
 | 
				
			||||||
import User from '../components/settings/User'
 | 
					import User from '../components/settings/User'
 | 
				
			||||||
@ -11,7 +12,12 @@ import { useProject } from '../context/Project/provider'
 | 
				
			|||||||
const Home: NextPage = () => {
 | 
					const Home: NextPage = () => {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const { currentSession } = useProject()
 | 
					  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 = () => {
 | 
					  const renderSelectedMainPage = () => {
 | 
				
			||||||
    if (selectedMainPage === mainPages.SELECTPROJECT) return <MainProject />
 | 
					    if (selectedMainPage === mainPages.SELECTPROJECT) return <MainProject />
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user