diff --git a/src/Router.tsx b/src/Router.tsx index b97a50b58..c2836581d 100644 --- a/src/Router.tsx +++ b/src/Router.tsx @@ -48,7 +48,7 @@ const createRouter = isDesktop() ? createHashRouter : createBrowserRouter const router = createRouter([ { id: PATHS.INDEX, - element: , + element: , children: [ { path: PATHS.INDEX, diff --git a/src/components/Providers/SystemIOProviderDesktop.tsx b/src/components/Providers/SystemIOProviderDesktop.tsx index 42148b0a8..3686d1144 100644 --- a/src/components/Providers/SystemIOProviderDesktop.tsx +++ b/src/components/Providers/SystemIOProviderDesktop.tsx @@ -9,8 +9,6 @@ import { import { SystemIOMachineEvents } from '@src/machines/systemIO/utils' import { useEffect } from 'react' import { useNavigate } from 'react-router-dom' -import { projectsCommandBarConfig } from '@src/lib/commandBarConfigs/projectsCommandConfig' -import useStateMachineCommands from '@src/hooks/useStateMachineCommands' export function SystemIOMachineLogicListener() { const requestedProjectName = useRequestedProjectName() diff --git a/src/machines/systemIO/systemIOMachine.ts b/src/machines/systemIO/systemIOMachine.ts index cf8433232..cf4654d53 100644 --- a/src/machines/systemIO/systemIOMachine.ts +++ b/src/machines/systemIO/systemIOMachine.ts @@ -8,6 +8,7 @@ import { SystemIOMachineEvents, SystemIOMachineStates, } from '@src/machines/systemIO/utils' +import toast from 'react-hot-toast' import { assertEvent, assign, fromPromise, setup } from 'xstate' /** @@ -101,6 +102,28 @@ export const systemIOMachine = setup({ return event.data.requestedDefaultProjectFolderName }, }), + [SystemIOMachineActions.toastSuccess]: ({ event }) => { + toast.success( + ('data' in event && typeof event.data === 'string' && event.data) || + ('output' in event && + 'message' in event.output && + typeof event.output.message === 'string' && + event.output.message) || + '' + ) + }, + [SystemIOMachineActions.toastError]: ({ event }) => { + toast.error( + ('data' in event && typeof event.data === 'string' && event.data) || + ('output' in event && + typeof event.output === 'string' && + event.output) || + ('error' in event && + event.error instanceof Error && + event.error.message) || + '' + ) + }, }, actors: { [SystemIOMachineActors.readFoldersFromProjectDirectory]: fromPromise( @@ -143,8 +166,7 @@ export const systemIOMachine = setup({ requestedProjectName: string requestedFileName: string requestedCode: string - -} + } }) => {} ), }, @@ -227,9 +249,11 @@ export const systemIOMachine = setup({ }, onDone: { target: SystemIOMachineStates.readingFolders, + actions: [SystemIOMachineActions.toastSuccess], }, onError: { target: SystemIOMachineStates.idle, + actions: [SystemIOMachineActions.toastError], }, }, }, diff --git a/src/machines/systemIO/systemIOMachineDesktop.ts b/src/machines/systemIO/systemIOMachineDesktop.ts index 1f23b4fea..804106979 100644 --- a/src/machines/systemIO/systemIOMachineDesktop.ts +++ b/src/machines/systemIO/systemIOMachineDesktop.ts @@ -76,6 +76,10 @@ export const systemIOMachineDesktop = systemIOMachine.provide({ const requestedProjectName = input.requestedProjectName const uniqueName = getUniqueProjectName(requestedProjectName, folders) await createNewProjectDirectory(uniqueName) + return { + message: `Successfully created "${uniqueName}"`, + name: uniqueName, + } } ), [SystemIOMachineActors.renameProject]: fromPromise( diff --git a/src/machines/systemIO/utils.ts b/src/machines/systemIO/utils.ts index 8baaee263..1c4309a0e 100644 --- a/src/machines/systemIO/utils.ts +++ b/src/machines/systemIO/utils.ts @@ -41,6 +41,8 @@ export enum SystemIOMachineActions { setRequestedProjectName = 'set requested project name', setRequestedFileName = 'set requested file name', setDefaultProjectFolderName = 'set default project folder name', + toastSuccess = 'toastSuccess', + toastError = 'toastError', } export const NO_PROJECT_DIRECTORY = ''