Skip to content

Commit dbc52a6

Browse files
authored
feat(ui): conditionally display "New Note" button based on authentication status (#379)
1 parent 1fe0190 commit dbc52a6

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

packages/app-client/src/modules/ui/layouts/app.layout.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ export const Navbar: Component = () => {
8282
navigate('/');
8383
};
8484

85+
// Only show the "New Note" button if the user is authenticated or if authentication is not required
86+
const getShouldShowNewNoteButton = () => config.isAuthenticationRequired ? authStore.getIsAuthenticated() : true;
87+
8588
return (
8689
<div class="border-b border-border bg-surface">
8790
<div class="flex items-center justify-between px-6 py-3 mx-auto max-w-1200px">
@@ -96,10 +99,13 @@ export const Navbar: Component = () => {
9699
</div>
97100

98101
<div class="flex gap-2 items-center">
99-
<Button variant="secondary" onClick={newNoteClicked}>
100-
<div class="i-tabler-plus mr-1 text-muted-foreground"></div>
101-
{t('navbar.new-note')}
102-
</Button>
102+
103+
{getShouldShowNewNoteButton() && (
104+
<Button variant="secondary" onClick={newNoteClicked}>
105+
<div class="i-tabler-plus mr-1 text-muted-foreground"></div>
106+
{t('navbar.new-note')}
107+
</Button>
108+
)}
103109

104110
<Button variant="ghost" class="text-lg px-0 size-9 hidden md:inline-flex" as={A} href="https://github.com/CorentinTh/enclosed" target="_blank" rel="noopener noreferrer" aria-label={t('navbar.github-repository')}>
105111
<div class="i-tabler-brand-github"></div>

0 commit comments

Comments
 (0)