mirror of
https://github.com/bartvdbraak/omnidash.git
synced 2025-05-01 09:21:21 +00:00
refactor: user navigation and account settings
This commit is contained in:
parent
c15f98b86e
commit
2fed4ffdf6
6 changed files with 14 additions and 58 deletions
|
@ -40,18 +40,10 @@
|
||||||
Settings
|
Settings
|
||||||
</DropdownMenu.Label>
|
</DropdownMenu.Label>
|
||||||
<DropdownMenu.Group>
|
<DropdownMenu.Group>
|
||||||
<DropdownMenu.Item href="/settings">
|
<DropdownMenu.Item href="/settings">Profile</DropdownMenu.Item>
|
||||||
Profile
|
<DropdownMenu.Item href="/settings/account">Account</DropdownMenu.Item>
|
||||||
</DropdownMenu.Item>
|
<DropdownMenu.Item href="/settings/appearance">Appearance</DropdownMenu.Item>
|
||||||
<DropdownMenu.Item href="/settings/account">
|
<DropdownMenu.Item href="/settings/notifications">Notifications</DropdownMenu.Item>
|
||||||
Account
|
|
||||||
</DropdownMenu.Item>
|
|
||||||
<DropdownMenu.Item href="/settings/appearance">
|
|
||||||
Appearance
|
|
||||||
</DropdownMenu.Item>
|
|
||||||
<DropdownMenu.Item href="/settings/notifications">
|
|
||||||
Notifications
|
|
||||||
</DropdownMenu.Item>
|
|
||||||
</DropdownMenu.Group>
|
</DropdownMenu.Group>
|
||||||
<DropdownMenu.Separator />
|
<DropdownMenu.Separator />
|
||||||
<DropdownMenu.Item href="/logout">
|
<DropdownMenu.Item href="/logout">
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
import type { PageData } from './$types';
|
import type { PageData } from './$types';
|
||||||
|
|
||||||
export let data: PageData;
|
export let data: PageData;
|
||||||
|
export let { form, user } = data;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="space-y-6">
|
<div class="space-y-6">
|
||||||
|
@ -14,5 +15,5 @@
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<Separator />
|
<Separator />
|
||||||
<AccountForm data={data.form} />
|
<AccountForm data={form} {user} />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,29 +1,13 @@
|
||||||
<script lang="ts" context="module">
|
<script lang="ts" context="module">
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
// const languages = {
|
|
||||||
// en: 'English',
|
|
||||||
// fr: 'French',
|
|
||||||
// de: 'German',
|
|
||||||
// es: 'Spanish',
|
|
||||||
// pt: 'Portuguese',
|
|
||||||
// ru: 'Russian',
|
|
||||||
// ja: 'Japanese',
|
|
||||||
// ko: 'Korean',
|
|
||||||
// zh: 'Chinese'
|
|
||||||
// } as const;
|
|
||||||
|
|
||||||
// type Language = keyof typeof languages;
|
|
||||||
|
|
||||||
export const accountFormSchema = z.object({
|
export const accountFormSchema = z.object({
|
||||||
name: z
|
name: z
|
||||||
.string({
|
.string({
|
||||||
required_error: 'Required.'
|
required_error: 'Required.'
|
||||||
})
|
})
|
||||||
.min(2, 'Name must be at least 2 characters.')
|
.min(2, 'Name must be at least 2 characters.')
|
||||||
.max(30, 'Name must not be longer than 30 characters'),
|
.max(30, 'Name must not be longer than 30 characters')
|
||||||
// Hack: https://github.com/colinhacks/zod/issues/2280
|
|
||||||
// language: z.enum(Object.keys(languages) as [Language, ...Language[]])
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export type AccountFormSchema = typeof accountFormSchema;
|
export type AccountFormSchema = typeof accountFormSchema;
|
||||||
|
@ -32,10 +16,11 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import * as Form from '$lib/components/ui/form';
|
import * as Form from '$lib/components/ui/form';
|
||||||
import type { SuperValidated } from 'sveltekit-superforms';
|
import type { SuperValidated } from 'sveltekit-superforms';
|
||||||
// import { cn } from '$lib/utils';
|
|
||||||
import { dev } from '$app/environment';
|
import { dev } from '$app/environment';
|
||||||
|
import type { LayoutData } from '../$types';
|
||||||
|
|
||||||
export let data: SuperValidated<AccountFormSchema>;
|
export let data: SuperValidated<AccountFormSchema>;
|
||||||
|
export let user: LayoutData['user'];
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Form.Root
|
<Form.Root
|
||||||
|
@ -49,33 +34,12 @@
|
||||||
<Form.Item>
|
<Form.Item>
|
||||||
<Form.Field name="name" {config}>
|
<Form.Field name="name" {config}>
|
||||||
<Form.Label>Name</Form.Label>
|
<Form.Label>Name</Form.Label>
|
||||||
<Form.Input placeholder="Your name" />
|
<Form.Input placeholder={user?.name} />
|
||||||
<Form.Description>
|
<Form.Description>
|
||||||
This is the name that will be displayed on your profile and in emails.
|
This is the name that will be displayed on your profile and in emails.
|
||||||
</Form.Description>
|
</Form.Description>
|
||||||
<Form.Validation />
|
<Form.Validation />
|
||||||
</Form.Field>
|
</Form.Field>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<!-- <Form.Item>
|
|
||||||
<Form.Field {config} name="language" let:attrs>
|
|
||||||
{@const { value } = attrs.input}
|
|
||||||
<Form.Label>Language</Form.Label>
|
|
||||||
<Form.Select selected={{ value, label: languages[value] }}>
|
|
||||||
<Form.SelectTrigger
|
|
||||||
placeholder="Select language"
|
|
||||||
class={cn('w-[200px] justify-between', !attrs.input.value && 'text-muted-foreground')}
|
|
||||||
/>
|
|
||||||
<Form.SelectContent class="h-52 overflow-y-auto">
|
|
||||||
{#each Object.entries(languages) as [value, lang]}
|
|
||||||
<Form.SelectItem {value}>
|
|
||||||
{lang}
|
|
||||||
</Form.SelectItem>
|
|
||||||
{/each}
|
|
||||||
</Form.SelectContent>
|
|
||||||
</Form.Select>
|
|
||||||
<Form.Description>This is the language that will be used in the dashboard.</Form.Description>
|
|
||||||
<Form.Validation />
|
|
||||||
</Form.Field>
|
|
||||||
</Form.Item> -->
|
|
||||||
<Form.Button>Update account</Form.Button>
|
<Form.Button>Update account</Form.Button>
|
||||||
</Form.Root>
|
</Form.Root>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
export const appearanceFormSchema = z.object({
|
export const appearanceFormSchema = z.object({
|
||||||
theme: z.enum(['light', 'dark', 'system'], {
|
theme: z.enum(['light', 'dark', 'system'], {
|
||||||
required_error: 'Please select a theme.'
|
required_error: 'Please select a theme.'
|
||||||
}),
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
export type AppearanceFormSchema = typeof appearanceFormSchema;
|
export type AppearanceFormSchema = typeof appearanceFormSchema;
|
||||||
|
|
|
@ -35,8 +35,7 @@
|
||||||
<Form.Label>Username</Form.Label>
|
<Form.Label>Username</Form.Label>
|
||||||
<Form.Input placeholder="@shadcn" />
|
<Form.Input placeholder="@shadcn" />
|
||||||
<Form.Description>
|
<Form.Description>
|
||||||
This is your public display name. It can be your real name or a pseudonym. You can only
|
This is your public display name. It can be your real name or a pseudonym.
|
||||||
change this once every 30 days.
|
|
||||||
</Form.Description>
|
</Form.Description>
|
||||||
<Form.Validation />
|
<Form.Validation />
|
||||||
</Form.Field>
|
</Form.Field>
|
||||||
|
|
Loading…
Reference in a new issue