-
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.
feat: - added new components for routing specific states including unfinished and generic error - useCurrentApp is a new hook to work out which "app" you are on based on the route tree - removed the need for a redux reducer - added unfinished component for routes that are unfinished fix: - authentication.controller.ts handles conflicts chore: - refactored how types are handled in forge - refactored the redux reducers and redux folder
- Loading branch information
Showing
48 changed files
with
1,442 additions
and
1,370 deletions.
There are no files selected for viewing
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
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,43 +1,38 @@ | ||
import * as React from "react"; | ||
import {User} from "@ignis/types/users.ts"; | ||
import {useVerifyAuthentication} from "@/hooks/useVerifyAuthentication.tsx"; | ||
import {Loader} from "@ui/components/ui/loader.tsx"; | ||
import { User } from "@ignis/types/users.ts"; | ||
import { useVerifyAuthentication } from "@/hooks/useVerifyAuthentication.ts"; | ||
import { Loader } from "@ui/components/ui/loader.tsx"; | ||
|
||
export interface AuthContext { | ||
isAuthenticated: boolean; | ||
user: User | null; | ||
logout: () => void; | ||
isAuthenticated: boolean; | ||
user: User | null; | ||
logout: () => void; | ||
} | ||
|
||
const AuthContext = React.createContext<AuthContext | null>(null); | ||
|
||
export function AuthProvider({ children }: { children: React.ReactNode }) { | ||
const { user, loading, setUser } = useVerifyAuthentication(); | ||
const { user, loading, setUser } = useVerifyAuthentication(); | ||
|
||
if (loading) { | ||
return <Loader />; | ||
} | ||
if (loading) { | ||
return <Loader />; | ||
} | ||
|
||
const isAuthenticated = !!user; | ||
const isAuthenticated = !!user; | ||
|
||
const logout = () => { | ||
setUser(null); | ||
}; | ||
|
||
const logout = () => { | ||
setUser(null) | ||
} | ||
const contextValue = { isAuthenticated, user, logout }; | ||
|
||
const contextValue = { isAuthenticated, user, logout }; | ||
|
||
return ( | ||
<AuthContext.Provider value={contextValue}> | ||
{children} | ||
</AuthContext.Provider> | ||
); | ||
return <AuthContext.Provider value={contextValue}>{children}</AuthContext.Provider>; | ||
} | ||
|
||
export function useAuth() { | ||
const context = React.useContext(AuthContext); | ||
if (!context) { | ||
throw new Error("useAuth must be used within an AuthProvider"); | ||
} | ||
return context; | ||
const context = React.useContext(AuthContext); | ||
if (!context) { | ||
throw new Error("useAuth must be used within an AuthProvider"); | ||
} | ||
return context; | ||
} |
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,50 +1,56 @@ | ||
// appLinks.ts | ||
import {Apps} from "@/redux/app/app.types.ts"; | ||
import { Apps } from "@/types/app.ts"; | ||
|
||
export type AppLink = { | ||
app: Apps; // Identifier for the app | ||
displayName: string; // User-facing name | ||
path?: string; // Path for the link | ||
children?: AppLink[]; // Nested links, specific to the same app | ||
index?: number; // Index of the link in the navbar (PER LEVEL) | ||
id: string; // Unique identifier for the link | ||
app: Apps; // Identifier for the app | ||
displayName: string; // User-facing name | ||
path?: string; // Path for the link | ||
children?: AppLink[]; // Nested links, specific to the same app | ||
index?: number; // Index of the link in the navbar (PER LEVEL) | ||
id: string; // Unique identifier for the link | ||
}; | ||
|
||
export const appLinks: AppLink[] = [ | ||
{app: "Main", displayName: "Home", path: "/", index: 0, id: "home"}, | ||
{app: "Sign In", displayName: "Sign In Home", path: "/signin", index: 0, id: "signin_root"}, | ||
{ | ||
{ app: "Main", displayName: "Home", path: "/", index: 0, id: "home" }, | ||
{ app: "Sign In", displayName: "Sign In Home", path: "/signin", index: 0, id: "signin_root" }, | ||
{ | ||
app: "Sign In", | ||
displayName: "Agreements", | ||
path: "/signin/agreements", | ||
index: 1, | ||
id: "signin_agreements", | ||
}, | ||
{ | ||
app: "Sign In", | ||
displayName: "Actions", | ||
path: "/signin/actions", | ||
index: 2, | ||
id: "signin_actions_root", | ||
children: [ | ||
{ | ||
app: "Sign In", | ||
displayName: "Agreements", | ||
path: "/signin/agreements", | ||
index: 1, | ||
id: "signin_agreements" | ||
}, | ||
{ | ||
displayName: "Sign In", | ||
path: "/signin/actions/in", | ||
index: 0, | ||
id: "signin_actions_in", | ||
}, | ||
{ app: "Sign In", displayName: "Sign Out", path: "/signin/actions/out", id: "signin_actions_out", index: 1 }, | ||
{ | ||
app: "Sign In", | ||
displayName: "Actions", | ||
path: "/signin/actions", | ||
displayName: "Register", | ||
path: "/signin/actions/register", | ||
id: "signin_actions_register", | ||
index: 2, | ||
id: "signin_actions_root", | ||
children: [ | ||
{ | ||
app: "Sign In", | ||
displayName: "Sign In", | ||
path: "/signin/actions/in", | ||
index: 0, | ||
id: "signin_actions_in", | ||
}, | ||
{app: "Sign In", displayName: "Sign Out", path: "/signin/actions/out", id: "signin_actions_out", index: 1}, | ||
{app: "Sign In", displayName: "Register", path: "/signin/actions/register", id: "signin_actions_register", index: 2}, | ||
{ | ||
app: "Sign In", | ||
displayName: "Enqueue", | ||
path: "/signin/actions/enqueue", | ||
id: "signin_actions_enqueue", | ||
index: 3, | ||
}, | ||
] | ||
}, | ||
{app: "Sign In", displayName: "Dashboard", path: "/signin/dashboard", index: 1, id: "signin_status"}, | ||
{app: "Printing", displayName: "Printing", path: "/printing", id: "printing_root", index: 0}, | ||
]; | ||
}, | ||
{ | ||
app: "Sign In", | ||
displayName: "Enqueue", | ||
path: "/signin/actions/enqueue", | ||
id: "signin_actions_enqueue", | ||
index: 3, | ||
}, | ||
], | ||
}, | ||
{ app: "Sign In", displayName: "Dashboard", path: "/signin/dashboard", index: 1, id: "signin_status" }, | ||
{ app: "Printing", displayName: "Printing", path: "/printing", id: "printing_root", index: 0 }, | ||
]; |
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,29 +1,31 @@ | ||
// NavBar.tsx | ||
import {Link} from "@tanstack/react-router"; | ||
import {useSelector} from "react-redux"; | ||
import {AppRootState} from "@/redux/store"; | ||
import {appLinks} from "./appLinks"; | ||
import {AppLinkDropdown} from './appLinkDropdown.tsx'; | ||
import { Link } from "@tanstack/react-router"; | ||
import { appLinks } from "./appLinks"; | ||
import { AppLinkDropdown } from "./appLinkDropdown.tsx"; | ||
|
||
export default function AppNav() { | ||
const currentApp = useSelector((state: AppRootState) => state.app.current_app); | ||
const sortedAppLinks = appLinks.sort((a, b) => (a.index ?? 0) - (b.index ?? 0)); | ||
import useCurrentApp from "@/hooks/useCurrentApp.ts"; | ||
|
||
return ( | ||
<div className="p-2 flex flex-row align-middle justify-items-center justify-center"> | ||
{sortedAppLinks.map((link) => { | ||
if (link.app === currentApp) { | ||
return link.children && link.children.length > 0 ? ( | ||
<AppLinkDropdown key={link.id} link={link} /> | ||
) : ( | ||
<Link key={link.displayName} to={link.path ?? '#'} | ||
className="inline-flex items-center px-4 py-2 text-sm font-medium rounded-md text-navbar-foreground hover:bg-accent"> | ||
{link.displayName} | ||
</Link> | ||
); | ||
} | ||
return null; | ||
})} | ||
</div> | ||
); | ||
export default function AppNav() { | ||
const currentApp = useCurrentApp(); | ||
const sortedAppLinks = appLinks.sort((a, b) => (a.index ?? 0) - (b.index ?? 0)); | ||
return ( | ||
<div className="p-2 flex flex-row align-middle justify-items-center justify-center"> | ||
{sortedAppLinks.map((link) => { | ||
if (link.app === currentApp) { | ||
return link.children && link.children.length > 0 ? ( | ||
<AppLinkDropdown key={link.id} link={link} /> | ||
) : ( | ||
<Link | ||
key={link.displayName} | ||
to={link.path ?? "#"} | ||
className="inline-flex items-center px-4 py-2 text-sm font-medium rounded-md text-navbar-foreground hover:bg-accent" | ||
> | ||
{link.displayName} | ||
</Link> | ||
); | ||
} | ||
return null; | ||
})} | ||
</div> | ||
); | ||
} |
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,23 @@ | ||
import AppSwitcher from "@/components/navbar/appSwitcher"; | ||
import {ThemeSwitcher} from "@/components/navbar/themeSwitcher"; | ||
import {UserNav} from "@/components/navbar/userNav"; | ||
import { ThemeSwitcher } from "@/components/navbar/themeSwitcher"; | ||
import { UserNav } from "@/components/navbar/userNav"; | ||
import AppNav from "@/components/navbar/appNav"; | ||
|
||
export default function NavBar() { | ||
return ( | ||
<div | ||
className="flex items-center justify-between h-[60px] p-3 w-full bg-navbar backdrop-filter shadow-lg dark:shadow-none"> | ||
<div className="flex flex-1"> | ||
<AppSwitcher/> | ||
</div> | ||
<div className="flex-1 text-center"><AppNav/></div> | ||
<div className="flex flex-1 justify-end pr-1"> | ||
<div className="flex items-center space-x-4"> | ||
<ThemeSwitcher/> | ||
<UserNav/> | ||
</div> | ||
</div> | ||
return ( | ||
<div className="flex items-center justify-between h-[60px] p-3 w-full bg-navbar backdrop-filter shadow-lg dark:shadow-none"> | ||
<div className="flex flex-1"> | ||
<AppSwitcher /> | ||
</div> | ||
<div className="flex-1 text-center"> | ||
<AppNav /> | ||
</div> | ||
<div className="flex flex-1 justify-end pr-1"> | ||
<div className="flex items-center space-x-4"> | ||
<ThemeSwitcher /> | ||
<UserNav /> | ||
</div> | ||
); | ||
</div> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.