generated from cepdnaclk/eYY-3yp-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New Features: Inventory editor and authentication page # Sidebar shows available items in the store when inventory editor is opened # Items can be dragged and dropped to a shelf # Layouts are stored in the local storage
- Loading branch information
1 parent
2fa05b8
commit 99261ef
Showing
29 changed files
with
2,399 additions
and
284 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,56 @@ | ||
// App.tsx | ||
import React from "react"; | ||
import LayoutEditor from "./features/editor/LayoutEditor"; | ||
import { BrowserRouter, Routes, Route, Navigate } from "react-router-dom"; | ||
import { FixtureProvider } from "./context/FixtureContext"; | ||
import { EdgeProvider } from "./context/EdgeContext"; | ||
import { NodeProvider } from "./context/NodeContext"; | ||
import { SidebarProvider } from "./context/SidebarContext"; | ||
import Main from "./components/Main"; | ||
import AuthPage from "./AuthPage"; | ||
|
||
// Simple authentication check | ||
const useAuth = () => { | ||
// In a real app, you would check localStorage/sessionStorage or a state management store | ||
// This is just a simple example for demonstration | ||
const isAuthenticated = localStorage.getItem("isAuthenticated") === "true"; | ||
return { isAuthenticated }; | ||
}; | ||
|
||
// Protected route component | ||
const ProtectedRoute = ({ children }: { children: React.ReactNode }) => { | ||
const { isAuthenticated } = useAuth(); | ||
|
||
if (!isAuthenticated) { | ||
return <Navigate to="/" replace />; | ||
} | ||
|
||
return <>{children}</>; | ||
}; | ||
|
||
const App: React.FC = () => { | ||
return ( | ||
<div> | ||
<FixtureProvider> | ||
<EdgeProvider> | ||
<NodeProvider> | ||
<LayoutEditor /> | ||
</NodeProvider> | ||
</EdgeProvider> | ||
</FixtureProvider> | ||
</div> | ||
<BrowserRouter> | ||
<SidebarProvider> | ||
<FixtureProvider> | ||
<EdgeProvider> | ||
<NodeProvider> | ||
<Routes> | ||
<Route path="/" element={<AuthPage />} /> | ||
<Route | ||
path="/editor" | ||
element={ | ||
<ProtectedRoute> | ||
<Main /> | ||
</ProtectedRoute> | ||
} | ||
/> | ||
<Route path="*" element={<Navigate to="/" replace />} /> | ||
</Routes> | ||
</NodeProvider> | ||
</EdgeProvider> | ||
</FixtureProvider> | ||
</SidebarProvider> | ||
</BrowserRouter> | ||
); | ||
}; | ||
|
||
export default App; | ||
export default App; |
Oops, something went wrong.