-
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: create custom 404 pages and create roles + hide/show UI accordi…
…ngly (#82) * feat: create custom 404 pages * feat: add user count in sidenav * feat: create roles for request/history + hide/show UI related components
- Loading branch information
Showing
33 changed files
with
473 additions
and
139 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
16 changes: 14 additions & 2 deletions
16
...281636e5f3168e10d18f8267cc7913ec5738.json → ...1ac865eb628e6aee419ecb58c8cd8802bcc5.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,4 +1,4 @@ | ||
reset-db: | ||
db-reset: | ||
./scripts/reset_db.sh && make gen-types | ||
|
||
gen-types: | ||
|
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
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Link, LinkProps } from "@tanstack/react-router"; | ||
import { useAtomValue } from "jotai"; | ||
|
||
import { userAtom } from "@/atoms/auth"; | ||
import { userHasRoles } from "@/lib/auth"; | ||
|
||
interface Props | ||
extends LinkProps, | ||
Pick<React.HTMLAttributes<HTMLAnchorElement>, "title"> { | ||
roles?: string[]; | ||
} | ||
|
||
const AuthLink: React.FC<Props> = ({ roles = [], ...props }) => { | ||
const user = useAtomValue(userAtom); | ||
|
||
if (user && !userHasRoles(user, roles)) { | ||
return <>{props.children}</>; | ||
} | ||
|
||
return <Link {...props} />; | ||
}; | ||
|
||
export default AuthLink; |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { useAtomValue } from "jotai"; | ||
|
||
import { userAtom } from "@/atoms/auth"; | ||
import { userHasRoles } from "@/lib/auth"; | ||
|
||
interface Props { | ||
roles: string[]; | ||
} | ||
|
||
const AuthVisible: React.FC<React.PropsWithChildren<Props>> = ({ | ||
roles, | ||
children, | ||
}) => { | ||
const user = useAtomValue(userAtom); | ||
|
||
if (user && !userHasRoles(user, roles)) { | ||
return null; | ||
} | ||
|
||
return children; | ||
}; | ||
|
||
export default AuthVisible; |
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
Oops, something went wrong.