feat: tempcommit
This commit is contained in:
parent
f508f26531
commit
15f4fbd40b
12 changed files with 1036 additions and 727 deletions
|
@ -1,11 +1,13 @@
|
|||
import zod from 'zod/v4';
|
||||
import {
|
||||
emailSchema,
|
||||
firstNameSchema,
|
||||
lastNameSchema,
|
||||
newUserEmailServerSchema,
|
||||
newUserNameServerSchema,
|
||||
passwordSchema,
|
||||
timezoneSchema,
|
||||
userNameSchema,
|
||||
} from '@/app/api/user/validation';
|
||||
|
||||
// ----------------------------------------
|
||||
|
@ -22,6 +24,15 @@ export const updateUserServerSchema = zod.object({
|
|||
timezone: timezoneSchema.optional(),
|
||||
});
|
||||
|
||||
export const updateUserClientSchema = zod.object({
|
||||
name: userNameSchema.optional(),
|
||||
first_name: firstNameSchema.optional(),
|
||||
last_name: lastNameSchema.optional(),
|
||||
email: emailSchema.optional(),
|
||||
image: zod.url().optional(),
|
||||
timezone: timezoneSchema.optional(),
|
||||
});
|
||||
|
||||
export const updateUserPasswordServerSchema = zod
|
||||
.object({
|
||||
current_password: zod.string().min(1, 'Current password is required'),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import SettingsPage from '@/components/misc/settings-page';
|
||||
import SettingsPage from '@/components/settings/settings-page';
|
||||
|
||||
export default function Page() {
|
||||
return <SettingsPage />;
|
||||
|
|
14
src/auth.ts
14
src/auth.ts
|
@ -88,7 +88,19 @@ const providers: Provider[] = [
|
|||
}
|
||||
},
|
||||
}),
|
||||
process.env.AUTH_AUTHENTIK_ID && Authentik,
|
||||
process.env.AUTH_AUTHENTIK_ID &&
|
||||
Authentik({
|
||||
profile(profile) {
|
||||
return {
|
||||
id: profile.sub,
|
||||
name: profile.preferred_username,
|
||||
first_name: profile.given_name.split(' ')[0] || '',
|
||||
last_name: profile.given_name.split(' ')[1] || '',
|
||||
email: profile.email,
|
||||
image: profile.picture,
|
||||
};
|
||||
},
|
||||
}),
|
||||
].filter(Boolean) as Provider[];
|
||||
|
||||
export const providerMap = providers
|
||||
|
|
|
@ -1,725 +0,0 @@
|
|||
'use client';
|
||||
|
||||
import { useState } from 'react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardFooter,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from '@/components/ui/card';
|
||||
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { ScrollableSettingsWrapper } from '@/components/wrappers/settings-scroll';
|
||||
import { Switch } from '@/components/ui/switch';
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from '@/components/ui/select';
|
||||
import { SettingsDropdown } from '@/components/misc/settings-dropdown';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import {
|
||||
useDeleteApiUserMe,
|
||||
useGetApiUserMe,
|
||||
usePatchApiUserMePassword,
|
||||
} from '@/generated/api/user/user';
|
||||
import { ThemePicker } from './theme-picker';
|
||||
import LabeledInput from '../custom-ui/labeled-input';
|
||||
import { GroupWrapper } from '../wrappers/group-wrapper';
|
||||
|
||||
import ProfilePictureUpload from './profile-picture-upload';
|
||||
import {
|
||||
BookKey,
|
||||
CalendarArrowDown,
|
||||
CalendarArrowUp,
|
||||
CalendarCheck,
|
||||
CalendarClock,
|
||||
CalendarCog,
|
||||
CalendarPlus,
|
||||
CalendarPlus2,
|
||||
ClockAlert,
|
||||
ClockFading,
|
||||
FileKey,
|
||||
FileKey2,
|
||||
MailOpen,
|
||||
RotateCcwKey,
|
||||
UserLock,
|
||||
UserPen,
|
||||
} from 'lucide-react';
|
||||
import { IconButton } from '../buttons/icon-button';
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
DialogTrigger,
|
||||
} from '../ui/dialog';
|
||||
import useZodForm from '@/lib/hooks/useZodForm';
|
||||
import { updateUserPasswordServerSchema } from '@/app/api/user/me/validation';
|
||||
|
||||
export default function SettingsPage() {
|
||||
const router = useRouter();
|
||||
const [currentSection, setCurrentSection] = useState('general');
|
||||
const { data } = useGetApiUserMe();
|
||||
const deleteUser = useDeleteApiUserMe();
|
||||
const updatePassword = usePatchApiUserMePassword();
|
||||
|
||||
const { handleSubmit, formState, register, setError } = useZodForm(
|
||||
updateUserPasswordServerSchema,
|
||||
);
|
||||
|
||||
const onSubmit = handleSubmit(async (data) => {
|
||||
await updatePassword.mutateAsync(
|
||||
{
|
||||
data: data,
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
router.refresh();
|
||||
},
|
||||
onError: (error) => {
|
||||
if (error instanceof Error) {
|
||||
setError('root', {
|
||||
message: error.response?.data.message,
|
||||
});
|
||||
} else {
|
||||
setError('root', {
|
||||
message: 'An unknown error occurred.',
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
if (!data) {
|
||||
return (
|
||||
<div className='fixed inset-0 flex items-center justify-center p-4 bg-background/50 backdrop-blur-sm'>
|
||||
<div className='rounded-lg border bg-card text-card-foreground shadow-xl max-w-[700px] w-full h-auto max-h-[calc(100vh-2rem)] flex flex-col'>
|
||||
<div className='p-6 border-b'>
|
||||
<h1 className='text-2xl font-semibold'>Loading Settings...</h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const renderSettingsContent = () => {
|
||||
switch (currentSection) {
|
||||
case 'general':
|
||||
return (
|
||||
<Card className='h-full flex flex-col border-0 shadow-none rounded-none'>
|
||||
<ScrollableSettingsWrapper>
|
||||
<CardHeader>
|
||||
<CardTitle>Account Settings</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className='space-y-6 my-2'>
|
||||
{/*-------------------- General Settings --------------------*/}
|
||||
<GroupWrapper title='General Settings'>
|
||||
<div className='space-y-4'>
|
||||
<div>
|
||||
<LabeledInput
|
||||
type='text'
|
||||
label='First Name'
|
||||
placeholder='First Name'
|
||||
defaultValue={data.data.user.first_name ?? ''}
|
||||
></LabeledInput>
|
||||
</div>
|
||||
<div>
|
||||
<LabeledInput
|
||||
type='text'
|
||||
label='Last Name'
|
||||
placeholder='Last Name'
|
||||
defaultValue={data.data.user.last_name ?? ''}
|
||||
></LabeledInput>
|
||||
</div>
|
||||
<div className='space-y-2'>
|
||||
<LabeledInput
|
||||
type='text'
|
||||
label='Display Name'
|
||||
icon={UserPen}
|
||||
placeholder='Display Name'
|
||||
defaultValue={data.data.user.name}
|
||||
></LabeledInput>
|
||||
</div>
|
||||
<div className='space-y-2 space-b-2'>
|
||||
<LabeledInput
|
||||
type='email'
|
||||
label='Email Address'
|
||||
icon={MailOpen}
|
||||
placeholder='Your E-Mail'
|
||||
defaultValue={data.data.user.email ?? ''}
|
||||
></LabeledInput>
|
||||
|
||||
<span className='text-sm text-muted-foreground'>
|
||||
Email might be managed by your SSO provider.
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</GroupWrapper>
|
||||
{/*-------------------- General Settings --------------------*/}
|
||||
{/*-------------------- Reset Password --------------------*/}
|
||||
<GroupWrapper title='Reset Password'>
|
||||
<div className='flex flex-col items-center gap-6'>
|
||||
<form
|
||||
onSubmit={onSubmit}
|
||||
className='flex flex-col sm:flex-row gap-6 w-full'
|
||||
>
|
||||
<div className='flex-1'>
|
||||
<LabeledInput
|
||||
type='password'
|
||||
label='Current Password'
|
||||
icon={FileKey}
|
||||
{...register('current_password')}
|
||||
error={formState.errors.current_password?.message}
|
||||
/>
|
||||
</div>
|
||||
<div className='flex-1'>
|
||||
<LabeledInput
|
||||
type='password'
|
||||
label='New Password'
|
||||
icon={FileKey2}
|
||||
{...register('new_password')}
|
||||
error={formState.errors.new_password?.message}
|
||||
/>
|
||||
</div>
|
||||
<div className='flex-1'>
|
||||
<LabeledInput
|
||||
type='password'
|
||||
label='Repeat Password'
|
||||
icon={RotateCcwKey}
|
||||
{...register('confirm_new_password')}
|
||||
error={formState.errors.confirm_new_password?.message}
|
||||
/>
|
||||
</div>
|
||||
<div className='flex items-end'>
|
||||
<Button
|
||||
variant={
|
||||
formState.isValid
|
||||
? 'outline_secondary'
|
||||
: 'outline_muted'
|
||||
}
|
||||
size='icon'
|
||||
className='w-full md:size-9'
|
||||
disabled={
|
||||
!formState.isValid || formState.isSubmitting
|
||||
}
|
||||
>
|
||||
<BookKey className='h-[1.2rem] w-[1.2rem]' />
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
{formState.errors.root && (
|
||||
<p className='text-red-500 text-sm mt-1'>
|
||||
{formState.errors.root.message}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</GroupWrapper>
|
||||
{/*-------------------- Reset Password --------------------*/}
|
||||
{/*-------------------- Profile Picture --------------------*/}
|
||||
<GroupWrapper title='Profile Picture'>
|
||||
<div className='space-y-2 grid grid-cols-[1fr_auto]'>
|
||||
<ProfilePictureUpload />
|
||||
</div>
|
||||
</GroupWrapper>
|
||||
{/*-------------------- Profile Picture --------------------*/}
|
||||
{/*-------------------- Regional Settings --------------------*/}
|
||||
<GroupWrapper title='Regional Settings'>
|
||||
<div className='space-y-2 grid sm:grid-cols-[1fr_auto] sm:flex-row gap-4'>
|
||||
<div className='grid gap-1'>
|
||||
<LabeledInput
|
||||
type='text'
|
||||
label='Timezone'
|
||||
placeholder='Europe/Berlin'
|
||||
icon={CalendarClock}
|
||||
defaultValue={data?.data.user.timezone ?? ''}
|
||||
></LabeledInput>
|
||||
</div>
|
||||
<div>
|
||||
<div className='grid gap-1'>
|
||||
<Label htmlFor='language'>Language</Label>
|
||||
<Select>
|
||||
<SelectTrigger id='language'>
|
||||
<SelectValue placeholder='Select language' />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value='en'>English</SelectItem>
|
||||
<SelectItem value='de'>German</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</GroupWrapper>
|
||||
{/*-------------------- Regional Settings --------------------*/}
|
||||
{/*-------------------- DANGER ZONE --------------------*/}
|
||||
<GroupWrapper
|
||||
title='DANGER ZONE'
|
||||
className='border-destructive'
|
||||
>
|
||||
<div className='flex items-center justify-evenly sm:flex-row flex-col gap-6'>
|
||||
<Dialog>
|
||||
<DialogTrigger asChild>
|
||||
<Button variant='destructive'>Delete Account</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<div className='space-y-4'>
|
||||
<DialogTitle>Are you absolutely sure?</DialogTitle>
|
||||
<div className='space-y-4'>
|
||||
<DialogDescription>
|
||||
This action cannot be undone. This will
|
||||
permanently delete your account and remove your
|
||||
data from our servers.
|
||||
</DialogDescription>
|
||||
<Button
|
||||
variant='destructive'
|
||||
onClick={() => {
|
||||
deleteUser.mutate(undefined, {
|
||||
onSuccess: () => {
|
||||
router.push('/api/logout');
|
||||
},
|
||||
});
|
||||
}}
|
||||
>
|
||||
Confirm Delete
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</DialogHeader>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
<span className='text-sm text-muted-foreground pt-1'>
|
||||
Permanently delete your account and all associated data.
|
||||
</span>
|
||||
</div>
|
||||
</GroupWrapper>
|
||||
{/*-------------------- DANGER ZONE --------------------*/}
|
||||
</CardContent>
|
||||
</ScrollableSettingsWrapper>
|
||||
</Card>
|
||||
);
|
||||
|
||||
case 'notifications':
|
||||
return (
|
||||
<Card className='h-full flex flex-col border-0 shadow-none rounded-none'>
|
||||
<ScrollableSettingsWrapper>
|
||||
<CardHeader>
|
||||
<CardTitle>Notification Preferences</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className='space-y-6 my-2'>
|
||||
{/*-------------------- All --------------------*/}
|
||||
<GroupWrapper title='All'>
|
||||
<div className='flex items-center justify-between'>
|
||||
<Label
|
||||
htmlFor='masterEmailNotifications'
|
||||
className='font-normal'
|
||||
>
|
||||
Enable All Email Notifications
|
||||
</Label>
|
||||
<Switch id='masterEmailNotifications' />
|
||||
</div>
|
||||
</GroupWrapper>
|
||||
{/*-------------------- All --------------------*/}
|
||||
{/*-------------------- Meetings --------------------*/}
|
||||
<GroupWrapper title='Meetings'>
|
||||
<div className='space-y-4'>
|
||||
<div className='flex items-center justify-between space-x-2'>
|
||||
<Label
|
||||
htmlFor='newMeetingBookings'
|
||||
className='font-normal'
|
||||
>
|
||||
New Meeting Bookings
|
||||
</Label>
|
||||
<Switch id='newMeetingBookings' />
|
||||
</div>
|
||||
<div className='flex items-center justify-between space-x-2'>
|
||||
<Label
|
||||
htmlFor='meetingConfirmations'
|
||||
className='font-normal'
|
||||
>
|
||||
Meeting Confirmations/Cancellations
|
||||
</Label>
|
||||
<Switch id='meetingConfirmations' />
|
||||
</div>
|
||||
<div className='flex items-center justify-between space-x-2'>
|
||||
<Label
|
||||
htmlFor='enableMeetingReminders'
|
||||
className='font-normal'
|
||||
>
|
||||
Meeting Reminders
|
||||
</Label>
|
||||
<div>
|
||||
<Switch id='enableMeetingReminders' />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className='flex items-center justify-between space-x-2'>
|
||||
<Label className='font-normal' htmlFor='remindBefore'>
|
||||
Remind me before
|
||||
</Label>
|
||||
<Select>
|
||||
<SelectTrigger id='remindBefore'>
|
||||
<SelectValue placeholder='Select reminder time' />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value='15m'>15 minutes</SelectItem>
|
||||
<SelectItem value='30m'>30 minutes</SelectItem>
|
||||
<SelectItem value='1h'>1 hour</SelectItem>
|
||||
<SelectItem value='1d'>1 day</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
</GroupWrapper>
|
||||
{/*-------------------- Meetings --------------------*/}
|
||||
{/*-------------------- Social --------------------*/}
|
||||
<GroupWrapper title='Social'>
|
||||
<div className='space-y-4'>
|
||||
<div className='flex items-center justify-between space-x-2'>
|
||||
<Label htmlFor='friendRequests' className='font-normal'>
|
||||
Friend Requests
|
||||
</Label>
|
||||
<Switch id='friendRequests' />
|
||||
</div>
|
||||
<div className='flex items-center justify-between space-x-2'>
|
||||
<Label htmlFor='groupUpdates' className='font-normal'>
|
||||
Group Invitations/Updates
|
||||
</Label>
|
||||
<Switch id='groupUpdates' />
|
||||
</div>
|
||||
</div>
|
||||
</GroupWrapper>
|
||||
{/*-------------------- Social --------------------*/}
|
||||
</CardContent>
|
||||
</ScrollableSettingsWrapper>
|
||||
</Card>
|
||||
);
|
||||
|
||||
case 'calendarAvailability':
|
||||
return (
|
||||
<Card className='h-full flex flex-col border-0 shadow-none rounded-none'>
|
||||
<ScrollableSettingsWrapper>
|
||||
<CardHeader>
|
||||
<CardTitle>Calendar & Availability</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className='space-y-6 my-2'>
|
||||
{/*-------------------- Date & Time Format --------------------*/}
|
||||
<GroupWrapper title='Date & Time Format'>
|
||||
<div className='flex flex-col space-y-4'>
|
||||
<div className='grid grid-cols-1 gap-1'>
|
||||
<Label htmlFor='dateFormat'>Date Format</Label>
|
||||
<Select>
|
||||
<SelectTrigger id='dateFormat'>
|
||||
<SelectValue placeholder='Select date format' />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value='ddmmyyyy'>DD/MM/YYYY</SelectItem>
|
||||
<SelectItem value='mmddyyyy'>MM/DD/YYYY</SelectItem>
|
||||
<SelectItem value='yyyymmdd'>YYYY-MM-DD</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div className='grid grid-cols-1 gap-1'>
|
||||
<Label htmlFor='timeFormat'>Time Format</Label>
|
||||
<Select>
|
||||
<SelectTrigger id='timeFormat'>
|
||||
<SelectValue placeholder='Select time format' />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value='24h'>24-hour</SelectItem>
|
||||
<SelectItem value='12h'>12-hour</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
</GroupWrapper>
|
||||
{/*-------------------- Date & Time Format --------------------*/}
|
||||
{/*-------------------- Calendar --------------------*/}
|
||||
<GroupWrapper title='Calendar'>
|
||||
<div className='space-y-4'>
|
||||
<div className='grid grid-cols-1 gap-1'>
|
||||
<Label htmlFor='defaultCalendarView'>
|
||||
Default Calendar View
|
||||
</Label>
|
||||
<Select>
|
||||
<SelectTrigger id='defaultCalendarView'>
|
||||
<SelectValue placeholder='Select view' />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value='day'>Day</SelectItem>
|
||||
<SelectItem value='week'>Week</SelectItem>
|
||||
<SelectItem value='month'>Month</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div className='grid grid-cols-1 gap-1'>
|
||||
<Label htmlFor='weekStartsOn'>Week Starts On</Label>
|
||||
<Select>
|
||||
<SelectTrigger id='weekStartsOn'>
|
||||
<SelectValue placeholder='Select day' />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value='sunday'>Sunday</SelectItem>
|
||||
<SelectItem value='monday'>Monday</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div className='flex items-center justify-between space-x-2'>
|
||||
<Label htmlFor='showWeekends' className='font-normal'>
|
||||
Show Weekends
|
||||
</Label>
|
||||
<Switch id='showWeekends' defaultChecked />
|
||||
</div>
|
||||
</div>
|
||||
</GroupWrapper>
|
||||
{/*-------------------- Calendar --------------------*/}
|
||||
{/*-------------------- Availability --------------------*/}
|
||||
<GroupWrapper title='Availability'>
|
||||
<div className='space-y-4'>
|
||||
<div className='space-y-2'>
|
||||
<Label>Working Hours</Label>
|
||||
<span className='text-sm text-muted-foreground'>
|
||||
Define your typical available hours (e.g.,
|
||||
Monday-Friday, 9 AM - 5 PM).
|
||||
</span>
|
||||
<Button variant='outline_muted' size='sm'>
|
||||
Set Working Hours
|
||||
</Button>
|
||||
</div>
|
||||
<div className='space-y-2'>
|
||||
<LabeledInput
|
||||
type='text'
|
||||
label='Minimum Notice for Bookings'
|
||||
icon={ClockAlert}
|
||||
subtext='Min time before a booking can be made.'
|
||||
placeholder='e.g. 1h'
|
||||
defaultValue={''}
|
||||
></LabeledInput>
|
||||
</div>
|
||||
<div className='space-y-2'>
|
||||
<LabeledInput
|
||||
type='text'
|
||||
label='Booking Window (days in advance)'
|
||||
icon={ClockFading}
|
||||
subtext='Max time in advance a booking can be made.'
|
||||
placeholder='e.g. 30d'
|
||||
defaultValue={''}
|
||||
></LabeledInput>
|
||||
</div>
|
||||
</div>
|
||||
</GroupWrapper>
|
||||
{/*-------------------- Availability --------------------*/}
|
||||
{/*-------------------- iCalendar Integration --------------------*/}
|
||||
<GroupWrapper title='iCalendar Integration'>
|
||||
<div className='space-y-4'>
|
||||
<form
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
}}
|
||||
className='space-y-2'
|
||||
>
|
||||
<LabeledInput
|
||||
type='url'
|
||||
label='Import iCal Feed URL'
|
||||
icon={CalendarCheck}
|
||||
placeholder='https://calendar.example.com/feed.ics'
|
||||
defaultValue={''}
|
||||
name='icalUrl'
|
||||
required
|
||||
></LabeledInput>
|
||||
<IconButton
|
||||
type='submit'
|
||||
size='sm'
|
||||
className='mt-1'
|
||||
variant={'secondary'}
|
||||
icon={CalendarPlus}
|
||||
title='Submit iCal URL'
|
||||
>
|
||||
Add Feed
|
||||
</IconButton>
|
||||
</form>
|
||||
<div className='space-y-2'>
|
||||
<Label>Export Your Calendar</Label>
|
||||
<IconButton
|
||||
variant='outline_muted'
|
||||
size='sm'
|
||||
icon={CalendarArrowUp}
|
||||
>
|
||||
Get iCal Export URL
|
||||
</IconButton>
|
||||
<IconButton
|
||||
variant='outline_muted'
|
||||
size='sm'
|
||||
className='ml-2'
|
||||
icon={CalendarArrowDown}
|
||||
>
|
||||
Download .ics File
|
||||
</IconButton>
|
||||
</div>
|
||||
</div>
|
||||
</GroupWrapper>
|
||||
{/*-------------------- iCalendar Integration --------------------*/}
|
||||
</CardContent>
|
||||
</ScrollableSettingsWrapper>
|
||||
</Card>
|
||||
);
|
||||
|
||||
case 'sharingPrivacy':
|
||||
return (
|
||||
<Card className='h-full flex flex-col border-0 shadow-none rounded-none'>
|
||||
<ScrollableSettingsWrapper>
|
||||
<CardHeader>
|
||||
<CardTitle>Sharing & Privacy</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className='space-y-6 my-2'>
|
||||
{/*-------------------- Privacy Settigs --------------------*/}
|
||||
<GroupWrapper title='Privacy Settings'>
|
||||
<div className='flex flex-col space-y-4'>
|
||||
<div className='grid grid-cols-1 gap-1'>
|
||||
<Label htmlFor='defaultVisibility'>
|
||||
Default Calendar Visibility
|
||||
</Label>
|
||||
<span className='text-sm text-muted-foreground'>
|
||||
Default setting for new friends.
|
||||
</span>
|
||||
<Select>
|
||||
<SelectTrigger id='defaultVisibility'>
|
||||
<SelectValue placeholder='Select visibility' />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value='private'>
|
||||
Private (Only You)
|
||||
</SelectItem>
|
||||
<SelectItem value='freebusy'>Free/Busy</SelectItem>
|
||||
<SelectItem value='fulldetails'>
|
||||
Full Details
|
||||
</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div className='grid grid-cols-1 gap-1'>
|
||||
<Label htmlFor='whoCanSeeFull'>
|
||||
Who Can See Your Full Calendar Details?
|
||||
</Label>
|
||||
<span className='text-sm text-muted-foreground'>
|
||||
(Override for Default Visibility)
|
||||
<br />
|
||||
<span className='text-sm text-muted-foreground'>
|
||||
This setting will override the default visibility for
|
||||
your calendar. You can set specific friends or groups
|
||||
to see your full calendar details.
|
||||
</span>
|
||||
</span>
|
||||
<Select>
|
||||
<SelectTrigger id='whoCanSeeFull'>
|
||||
<SelectValue placeholder='Select audience' />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value='me'>Only Me</SelectItem>
|
||||
<SelectItem value='friends'>My Friends</SelectItem>
|
||||
<SelectItem value='specific'>
|
||||
Specific Friends/Groups (manage separately)
|
||||
</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div className='grid grid-cols-1 gap-1'>
|
||||
<Label htmlFor='whoCanBook'>
|
||||
Who Can Book Time With You?
|
||||
</Label>
|
||||
<Select>
|
||||
<SelectTrigger id='whoCanBook'>
|
||||
<SelectValue placeholder='Select audience' />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value='none'>No One</SelectItem>
|
||||
<SelectItem value='friends'>My Friends</SelectItem>
|
||||
<SelectItem value='specific'>
|
||||
Specific Friends/Groups (manage separately)
|
||||
</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div className='space-y-4'>
|
||||
<div className='grid grid-cols-1 gap-1'>
|
||||
<Label>Blocked Users</Label>
|
||||
<span className='text-sm text-muted-foreground'>
|
||||
Prevent specific users from seeing your calendar or
|
||||
booking time.
|
||||
</span>
|
||||
<IconButton
|
||||
variant='outline_muted'
|
||||
size='sm'
|
||||
icon={UserLock}
|
||||
>
|
||||
Manage Blocked Users
|
||||
</IconButton>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</GroupWrapper>
|
||||
{/*-------------------- Privacy Settigs --------------------*/}
|
||||
</CardContent>
|
||||
</ScrollableSettingsWrapper>
|
||||
</Card>
|
||||
);
|
||||
|
||||
case 'appearance':
|
||||
return (
|
||||
<Card className='h-full flex flex-col border-0 shadow-none rounded-none'>
|
||||
<ScrollableSettingsWrapper>
|
||||
<CardHeader>
|
||||
<CardTitle>Appearance</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className='space-y-6 my-2'>
|
||||
{/*-------------------- Change Theme --------------------*/}
|
||||
<GroupWrapper title='Change Theme'>
|
||||
<div className='space-y-2'>
|
||||
<Label htmlFor='theme'>Theme</Label>
|
||||
<ThemePicker />
|
||||
</div>
|
||||
</GroupWrapper>
|
||||
{/*-------------------- Change Theme --------------------*/}
|
||||
</CardContent>
|
||||
</ScrollableSettingsWrapper>
|
||||
</Card>
|
||||
);
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className='fixed inset-0 flex items-center justify-center p-4 bg-background/50 backdrop-blur-sm'>
|
||||
<div className='rounded-lg border bg-card text-card-foreground shadow-xl max-w-[700px] w-full h-auto max-h-[calc(100vh-2rem)] flex flex-col'>
|
||||
<div className='p-6 border-b'>
|
||||
<div className='flex items-center justify-between mb-4'>
|
||||
<h1 className='text-2xl font-semibold'>Settings</h1>
|
||||
</div>
|
||||
<SettingsDropdown
|
||||
currentSection={currentSection}
|
||||
onSectionChange={setCurrentSection}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className='flex-grow overflow-auto'>{renderSettingsContent()}</div>
|
||||
<div>
|
||||
<CardFooter className='border-t h-[60px] flex content-center justify-between'>
|
||||
<Button onClick={() => router.back()} variant='secondary'>
|
||||
Exit
|
||||
</Button>
|
||||
<Button variant='primary'>Save Changes</Button>
|
||||
</CardFooter>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
|
@ -26,6 +26,7 @@ import {
|
|||
Calendar,
|
||||
Shield,
|
||||
Palette,
|
||||
Key,
|
||||
} from 'lucide-react';
|
||||
|
||||
interface SettingsSection {
|
||||
|
@ -48,6 +49,12 @@ const settingsSections: SettingsSection[] = [
|
|||
description: 'Manage account details',
|
||||
icon: User,
|
||||
},
|
||||
{
|
||||
label: 'Password',
|
||||
value: 'password',
|
||||
description: 'Manage your password',
|
||||
icon: Key,
|
||||
},
|
||||
{
|
||||
label: 'Notifications',
|
||||
value: 'notifications',
|
59
src/components/settings/settings-page.tsx
Normal file
59
src/components/settings/settings-page.tsx
Normal file
|
@ -0,0 +1,59 @@
|
|||
'use client';
|
||||
|
||||
import { useState } from 'react';
|
||||
|
||||
import { SettingsDropdown } from '@/components/settings/settings-dropdown';
|
||||
|
||||
import AccountTab from './tabs/account';
|
||||
import NotificationsTab from './tabs/notifications';
|
||||
import CalendarTab from './tabs/calendar';
|
||||
import PrivacyTab from './tabs/privacy';
|
||||
import AppearanceTab from './tabs/appearance';
|
||||
import PasswordTab from './tabs/password';
|
||||
|
||||
export default function SettingsPage() {
|
||||
const [currentSection, setCurrentSection] = useState('general');
|
||||
|
||||
const renderSettingsContent = () => {
|
||||
switch (currentSection) {
|
||||
case 'general':
|
||||
return <AccountTab />;
|
||||
|
||||
case 'password':
|
||||
return <PasswordTab />;
|
||||
|
||||
case 'notifications':
|
||||
return <NotificationsTab />;
|
||||
|
||||
case 'calendarAvailability':
|
||||
return <CalendarTab />;
|
||||
|
||||
case 'sharingPrivacy':
|
||||
return <PrivacyTab />;
|
||||
|
||||
case 'appearance':
|
||||
return <AppearanceTab />;
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className='fixed inset-0 flex items-center justify-center p-4 bg-background/50 backdrop-blur-sm'>
|
||||
<div className='rounded-lg border bg-card text-card-foreground shadow-xl max-w-[700px] w-full max-h-[calc(100vh-2rem)] flex flex-col'>
|
||||
{/* TODO: Fix overflow */}
|
||||
<div className='p-6 border-b'>
|
||||
<div className='flex items-center justify-between mb-4'>
|
||||
<h1 className='text-2xl font-semibold'>Settings</h1>
|
||||
</div>
|
||||
<SettingsDropdown
|
||||
currentSection={currentSection}
|
||||
onSectionChange={setCurrentSection}
|
||||
/>
|
||||
</div>
|
||||
{renderSettingsContent()}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
263
src/components/settings/tabs/account.tsx
Normal file
263
src/components/settings/tabs/account.tsx
Normal file
|
@ -0,0 +1,263 @@
|
|||
'use client';
|
||||
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardFooter,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from '@/components/ui/card';
|
||||
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { ScrollableSettingsWrapper } from '@/components/wrappers/settings-scroll';
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from '@/components/ui/select';
|
||||
import {
|
||||
useDeleteApiUserMe,
|
||||
useGetApiUserMe,
|
||||
usePatchApiUserMe,
|
||||
} from '@/generated/api/user/user';
|
||||
import LabeledInput from '@/components/custom-ui/labeled-input';
|
||||
import { GroupWrapper } from '@/components/wrappers/group-wrapper';
|
||||
|
||||
import ProfilePictureUpload from '@/components/misc/profile-picture-upload';
|
||||
import { CalendarClock, MailOpen, UserPen } from 'lucide-react';
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
DialogTrigger,
|
||||
} from '@/components/ui/dialog';
|
||||
import useZodForm from '@/lib/hooks/useZodForm';
|
||||
import { updateUserClientSchema } from '@/app/api/user/me/validation';
|
||||
import { useRouter } from 'next/navigation';
|
||||
|
||||
export default function AccountTab() {
|
||||
const router = useRouter();
|
||||
const { data } = useGetApiUserMe();
|
||||
const deleteUser = useDeleteApiUserMe();
|
||||
const updateAccount = usePatchApiUserMe();
|
||||
|
||||
const { handleSubmit, formState, register, setError } = useZodForm(
|
||||
updateUserClientSchema,
|
||||
);
|
||||
|
||||
const onSubmit = handleSubmit(async (submitData) => {
|
||||
await updateAccount.mutateAsync(
|
||||
{
|
||||
data: {
|
||||
first_name:
|
||||
submitData?.first_name !== data?.data.user.first_name
|
||||
? submitData?.first_name
|
||||
: undefined,
|
||||
last_name:
|
||||
submitData?.last_name !== data?.data.user.last_name
|
||||
? submitData?.last_name
|
||||
: undefined,
|
||||
email:
|
||||
submitData?.email !== data?.data.user.email
|
||||
? submitData?.email
|
||||
: undefined,
|
||||
image:
|
||||
submitData?.image !== data?.data.user.image
|
||||
? submitData?.image
|
||||
: undefined,
|
||||
timezone:
|
||||
submitData?.timezone !== data?.data.user.timezone
|
||||
? submitData?.timezone
|
||||
: undefined,
|
||||
},
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
router.refresh();
|
||||
},
|
||||
onError: (error) => {
|
||||
if (error instanceof Error) {
|
||||
setError('root', {
|
||||
message: error.response?.data.message,
|
||||
});
|
||||
} else {
|
||||
setError('root', {
|
||||
message: 'An unknown error occurred.',
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
if (!data) {
|
||||
return (
|
||||
<div className='fixed inset-0 flex items-center justify-center p-4 bg-background/50 backdrop-blur-sm'>
|
||||
<div className='rounded-lg border bg-card text-card-foreground shadow-xl max-w-[700px] w-full h-auto max-h-[calc(100vh-2rem)] flex flex-col'>
|
||||
<div className='p-6 border-b'>
|
||||
<h1 className='text-2xl font-semibold'>Loading Settings...</h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<form onSubmit={onSubmit} className='h-full flex-grow overflow-auto'>
|
||||
<Card className='pb-0 h-full flex flex-col border-0 shadow-none rounded-none'>
|
||||
<ScrollableSettingsWrapper>
|
||||
<CardHeader>
|
||||
<CardTitle>Account Settings</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className='space-y-6 my-2'>
|
||||
{/*-------------------- General Settings --------------------*/}
|
||||
<GroupWrapper title='General Settings'>
|
||||
<div className='space-y-4'>
|
||||
<div>
|
||||
<LabeledInput
|
||||
type='text'
|
||||
label='First Name'
|
||||
placeholder='First Name'
|
||||
defaultValue={data.data.user.first_name ?? ''}
|
||||
{...register('first_name')}
|
||||
error={formState.errors.first_name?.message}
|
||||
></LabeledInput>
|
||||
</div>
|
||||
<div>
|
||||
<LabeledInput
|
||||
type='text'
|
||||
label='Last Name'
|
||||
placeholder='Last Name'
|
||||
defaultValue={data.data.user.last_name ?? ''}
|
||||
{...register('last_name')}
|
||||
error={formState.errors.last_name?.message}
|
||||
></LabeledInput>
|
||||
</div>
|
||||
<div className='space-y-2'>
|
||||
<LabeledInput
|
||||
type='text'
|
||||
label='Display Name'
|
||||
icon={UserPen}
|
||||
placeholder='Display Name'
|
||||
defaultValue={data.data.user.name}
|
||||
{...register('name')}
|
||||
error={formState.errors.name?.message}
|
||||
></LabeledInput>
|
||||
</div>
|
||||
<div className='space-y-2 space-b-2'>
|
||||
<LabeledInput
|
||||
type='email'
|
||||
label='Email Address'
|
||||
icon={MailOpen}
|
||||
placeholder='Your E-Mail'
|
||||
defaultValue={data.data.user.email ?? ''}
|
||||
{...register('email')}
|
||||
error={formState.errors.email?.message}
|
||||
></LabeledInput>
|
||||
|
||||
<span className='text-sm text-muted-foreground'>
|
||||
Email might be managed by your SSO provider.
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
{formState.errors.root && (
|
||||
<p className='text-red-500 text-sm mt-1'>
|
||||
{formState.errors.root.message}
|
||||
</p>
|
||||
)}
|
||||
</GroupWrapper>
|
||||
{/*-------------------- General Settings --------------------*/}
|
||||
{/*-------------------- Profile Picture --------------------*/}
|
||||
<GroupWrapper title='Profile Picture'>
|
||||
<div className='space-y-2 grid grid-cols-[1fr_auto]'>
|
||||
<ProfilePictureUpload />
|
||||
</div>
|
||||
</GroupWrapper>
|
||||
{/*-------------------- Profile Picture --------------------*/}
|
||||
{/*-------------------- Regional Settings --------------------*/}
|
||||
<GroupWrapper title='Regional Settings'>
|
||||
<div className='space-y-2 grid sm:grid-cols-[1fr_auto] sm:flex-row gap-4'>
|
||||
<div className='grid gap-1'>
|
||||
<LabeledInput
|
||||
type='text'
|
||||
label='Timezone'
|
||||
placeholder='Europe/Berlin'
|
||||
icon={CalendarClock}
|
||||
defaultValue={data?.data.user.timezone ?? ''}
|
||||
{...register('timezone')}
|
||||
></LabeledInput>
|
||||
</div>
|
||||
<div>
|
||||
<div className='grid gap-1'>
|
||||
<Label htmlFor='language'>Language</Label>
|
||||
<Select>
|
||||
<SelectTrigger id='language'>
|
||||
<SelectValue placeholder='Select language' />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value='en'>English</SelectItem>
|
||||
<SelectItem value='de'>German</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</GroupWrapper>
|
||||
{/*-------------------- Regional Settings --------------------*/}
|
||||
{/*-------------------- DANGER ZONE --------------------*/}
|
||||
<GroupWrapper title='DANGER ZONE' className='border-destructive'>
|
||||
<div className='flex items-center justify-evenly sm:flex-row flex-col gap-6'>
|
||||
<Dialog>
|
||||
<DialogTrigger asChild>
|
||||
<Button variant='destructive'>Delete Account</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<div className='space-y-4'>
|
||||
<DialogTitle>Are you absolutely sure?</DialogTitle>
|
||||
<div className='space-y-4'>
|
||||
<DialogDescription>
|
||||
This action cannot be undone. This will permanently
|
||||
delete your account and remove your data from our
|
||||
servers.
|
||||
</DialogDescription>
|
||||
<Button
|
||||
variant='destructive'
|
||||
onClick={() => {
|
||||
deleteUser.mutate(undefined, {
|
||||
onSuccess: () => {
|
||||
router.push('/api/logout');
|
||||
},
|
||||
});
|
||||
}}
|
||||
>
|
||||
Confirm Delete
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</DialogHeader>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
<span className='text-sm text-muted-foreground pt-1'>
|
||||
Permanently delete your account and all associated data.
|
||||
</span>
|
||||
</div>
|
||||
</GroupWrapper>
|
||||
{/*-------------------- DANGER ZONE --------------------*/}
|
||||
</CardContent>
|
||||
</ScrollableSettingsWrapper>
|
||||
<CardFooter className='border-t h-[60px] flex content-center justify-between'>
|
||||
<Button onClick={() => router.back()} variant='secondary'>
|
||||
Exit
|
||||
</Button>
|
||||
<Button variant='primary'>Save Changes</Button>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
</form>
|
||||
);
|
||||
}
|
51
src/components/settings/tabs/appearance.tsx
Normal file
51
src/components/settings/tabs/appearance.tsx
Normal file
|
@ -0,0 +1,51 @@
|
|||
'use client';
|
||||
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardFooter,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from '@/components/ui/card';
|
||||
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { ScrollableSettingsWrapper } from '@/components/wrappers/settings-scroll';
|
||||
import { GroupWrapper } from '@/components/wrappers/group-wrapper';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { ThemePicker } from '@/components/misc/theme-picker';
|
||||
|
||||
export default function AppearanceTab() {
|
||||
const router = useRouter();
|
||||
return (
|
||||
<>
|
||||
<div className='flex-grow overflow-auto'>
|
||||
<Card className='h-full flex flex-col border-0 shadow-none rounded-none'>
|
||||
<ScrollableSettingsWrapper>
|
||||
<CardHeader>
|
||||
<CardTitle>Appearance</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className='space-y-6 my-2'>
|
||||
{/*-------------------- Change Theme --------------------*/}
|
||||
<GroupWrapper title='Change Theme'>
|
||||
<div className='space-y-2'>
|
||||
<Label htmlFor='theme'>Theme</Label>
|
||||
<ThemePicker />
|
||||
</div>
|
||||
</GroupWrapper>
|
||||
{/*-------------------- Change Theme --------------------*/}
|
||||
</CardContent>
|
||||
</ScrollableSettingsWrapper>
|
||||
</Card>
|
||||
</div>
|
||||
<div>
|
||||
<CardFooter className='border-t h-[60px] flex content-center justify-between'>
|
||||
<Button onClick={() => router.back()} variant='secondary'>
|
||||
Exit
|
||||
</Button>
|
||||
<Button variant='primary'>Save Changes</Button>
|
||||
</CardFooter>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
216
src/components/settings/tabs/calendar.tsx
Normal file
216
src/components/settings/tabs/calendar.tsx
Normal file
|
@ -0,0 +1,216 @@
|
|||
'use client';
|
||||
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardFooter,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from '@/components/ui/card';
|
||||
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { ScrollableSettingsWrapper } from '@/components/wrappers/settings-scroll';
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from '@/components/ui/select';
|
||||
import { GroupWrapper } from '@/components/wrappers/group-wrapper';
|
||||
import { Switch } from '@/components/ui/switch';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import LabeledInput from '@/components/custom-ui/labeled-input';
|
||||
import {
|
||||
CalendarArrowDown,
|
||||
CalendarArrowUp,
|
||||
CalendarCheck,
|
||||
CalendarPlus,
|
||||
ClockAlert,
|
||||
ClockFading,
|
||||
} from 'lucide-react';
|
||||
import { IconButton } from '@/components/buttons/icon-button';
|
||||
|
||||
export default function CalendarTab() {
|
||||
const router = useRouter();
|
||||
return (
|
||||
<>
|
||||
<div className='flex-grow overflow-auto'>
|
||||
<Card className='h-full flex flex-col border-0 shadow-none rounded-none'>
|
||||
<ScrollableSettingsWrapper>
|
||||
<CardHeader>
|
||||
<CardTitle>Calendar & Availability</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className='space-y-6 my-2'>
|
||||
{/*-------------------- Date & Time Format --------------------*/}
|
||||
<GroupWrapper title='Date & Time Format'>
|
||||
<div className='flex flex-col space-y-4'>
|
||||
<div className='grid grid-cols-1 gap-1'>
|
||||
<Label htmlFor='dateFormat'>Date Format</Label>
|
||||
<Select>
|
||||
<SelectTrigger id='dateFormat'>
|
||||
<SelectValue placeholder='Select date format' />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value='ddmmyyyy'>DD/MM/YYYY</SelectItem>
|
||||
<SelectItem value='mmddyyyy'>MM/DD/YYYY</SelectItem>
|
||||
<SelectItem value='yyyymmdd'>YYYY-MM-DD</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div className='grid grid-cols-1 gap-1'>
|
||||
<Label htmlFor='timeFormat'>Time Format</Label>
|
||||
<Select>
|
||||
<SelectTrigger id='timeFormat'>
|
||||
<SelectValue placeholder='Select time format' />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value='24h'>24-hour</SelectItem>
|
||||
<SelectItem value='12h'>12-hour</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
</GroupWrapper>
|
||||
{/*-------------------- Date & Time Format --------------------*/}
|
||||
{/*-------------------- Calendar --------------------*/}
|
||||
<GroupWrapper title='Calendar'>
|
||||
<div className='space-y-4'>
|
||||
<div className='grid grid-cols-1 gap-1'>
|
||||
<Label htmlFor='defaultCalendarView'>
|
||||
Default Calendar View
|
||||
</Label>
|
||||
<Select>
|
||||
<SelectTrigger id='defaultCalendarView'>
|
||||
<SelectValue placeholder='Select view' />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value='day'>Day</SelectItem>
|
||||
<SelectItem value='week'>Week</SelectItem>
|
||||
<SelectItem value='month'>Month</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div className='grid grid-cols-1 gap-1'>
|
||||
<Label htmlFor='weekStartsOn'>Week Starts On</Label>
|
||||
<Select>
|
||||
<SelectTrigger id='weekStartsOn'>
|
||||
<SelectValue placeholder='Select day' />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value='sunday'>Sunday</SelectItem>
|
||||
<SelectItem value='monday'>Monday</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div className='flex items-center justify-between space-x-2'>
|
||||
<Label htmlFor='showWeekends' className='font-normal'>
|
||||
Show Weekends
|
||||
</Label>
|
||||
<Switch id='showWeekends' defaultChecked />
|
||||
</div>
|
||||
</div>
|
||||
</GroupWrapper>
|
||||
{/*-------------------- Calendar --------------------*/}
|
||||
{/*-------------------- Availability --------------------*/}
|
||||
<GroupWrapper title='Availability'>
|
||||
<div className='space-y-4'>
|
||||
<div className='space-y-2'>
|
||||
<Label>Working Hours</Label>
|
||||
<span className='text-sm text-muted-foreground'>
|
||||
Define your typical available hours (e.g., Monday-Friday,
|
||||
9 AM - 5 PM).
|
||||
</span>
|
||||
<Button variant='outline_muted' size='sm'>
|
||||
Set Working Hours
|
||||
</Button>
|
||||
</div>
|
||||
<div className='space-y-2'>
|
||||
<LabeledInput
|
||||
type='text'
|
||||
label='Minimum Notice for Bookings'
|
||||
icon={ClockAlert}
|
||||
subtext='Min time before a booking can be made.'
|
||||
placeholder='e.g. 1h'
|
||||
defaultValue={''}
|
||||
></LabeledInput>
|
||||
</div>
|
||||
<div className='space-y-2'>
|
||||
<LabeledInput
|
||||
type='text'
|
||||
label='Booking Window (days in advance)'
|
||||
icon={ClockFading}
|
||||
subtext='Max time in advance a booking can be made.'
|
||||
placeholder='e.g. 30d'
|
||||
defaultValue={''}
|
||||
></LabeledInput>
|
||||
</div>
|
||||
</div>
|
||||
</GroupWrapper>
|
||||
{/*-------------------- Availability --------------------*/}
|
||||
{/*-------------------- iCalendar Integration --------------------*/}
|
||||
<GroupWrapper title='iCalendar Integration'>
|
||||
<div className='space-y-4'>
|
||||
<form
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
}}
|
||||
className='space-y-2'
|
||||
>
|
||||
<LabeledInput
|
||||
type='url'
|
||||
label='Import iCal Feed URL'
|
||||
icon={CalendarCheck}
|
||||
placeholder='https://calendar.example.com/feed.ics'
|
||||
defaultValue={''}
|
||||
name='icalUrl'
|
||||
required
|
||||
></LabeledInput>
|
||||
<IconButton
|
||||
type='submit'
|
||||
size='sm'
|
||||
className='mt-1'
|
||||
variant={'secondary'}
|
||||
icon={CalendarPlus}
|
||||
title='Submit iCal URL'
|
||||
>
|
||||
Add Feed
|
||||
</IconButton>
|
||||
</form>
|
||||
<div className='space-y-2'>
|
||||
<Label>Export Your Calendar</Label>
|
||||
<IconButton
|
||||
variant='outline_muted'
|
||||
size='sm'
|
||||
icon={CalendarArrowUp}
|
||||
>
|
||||
Get iCal Export URL
|
||||
</IconButton>
|
||||
<IconButton
|
||||
variant='outline_muted'
|
||||
size='sm'
|
||||
className='ml-2'
|
||||
icon={CalendarArrowDown}
|
||||
>
|
||||
Download .ics File
|
||||
</IconButton>
|
||||
</div>
|
||||
</div>
|
||||
</GroupWrapper>
|
||||
{/*-------------------- iCalendar Integration --------------------*/}
|
||||
</CardContent>
|
||||
</ScrollableSettingsWrapper>
|
||||
</Card>
|
||||
</div>
|
||||
<div>
|
||||
<CardFooter className='border-t h-[60px] flex content-center justify-between'>
|
||||
<Button onClick={() => router.back()} variant='secondary'>
|
||||
Exit
|
||||
</Button>
|
||||
<Button variant='primary'>Save Changes</Button>
|
||||
</CardFooter>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
130
src/components/settings/tabs/notifications.tsx
Normal file
130
src/components/settings/tabs/notifications.tsx
Normal file
|
@ -0,0 +1,130 @@
|
|||
'use client';
|
||||
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardFooter,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from '@/components/ui/card';
|
||||
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { ScrollableSettingsWrapper } from '@/components/wrappers/settings-scroll';
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from '@/components/ui/select';
|
||||
import { GroupWrapper } from '@/components/wrappers/group-wrapper';
|
||||
import { Switch } from '@/components/ui/switch';
|
||||
import { useRouter } from 'next/navigation';
|
||||
|
||||
export default function NotificationsTab() {
|
||||
const router = useRouter();
|
||||
return (
|
||||
<>
|
||||
<div className='flex-grow overflow-auto'>
|
||||
<Card className='h-full flex flex-col border-0 shadow-none rounded-none'>
|
||||
<ScrollableSettingsWrapper>
|
||||
<CardHeader>
|
||||
<CardTitle>Notification Preferences</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className='space-y-6 my-2'>
|
||||
{/*-------------------- All --------------------*/}
|
||||
<GroupWrapper title='All'>
|
||||
<div className='flex items-center justify-between'>
|
||||
<Label
|
||||
htmlFor='masterEmailNotifications'
|
||||
className='font-normal'
|
||||
>
|
||||
Enable All Email Notifications
|
||||
</Label>
|
||||
<Switch id='masterEmailNotifications' />
|
||||
</div>
|
||||
</GroupWrapper>
|
||||
{/*-------------------- All --------------------*/}
|
||||
{/*-------------------- Meetings --------------------*/}
|
||||
<GroupWrapper title='Meetings'>
|
||||
<div className='space-y-4'>
|
||||
<div className='flex items-center justify-between space-x-2'>
|
||||
<Label htmlFor='newMeetingBookings' className='font-normal'>
|
||||
New Meeting Bookings
|
||||
</Label>
|
||||
<Switch id='newMeetingBookings' />
|
||||
</div>
|
||||
<div className='flex items-center justify-between space-x-2'>
|
||||
<Label
|
||||
htmlFor='meetingConfirmations'
|
||||
className='font-normal'
|
||||
>
|
||||
Meeting Confirmations/Cancellations
|
||||
</Label>
|
||||
<Switch id='meetingConfirmations' />
|
||||
</div>
|
||||
<div className='flex items-center justify-between space-x-2'>
|
||||
<Label
|
||||
htmlFor='enableMeetingReminders'
|
||||
className='font-normal'
|
||||
>
|
||||
Meeting Reminders
|
||||
</Label>
|
||||
<div>
|
||||
<Switch id='enableMeetingReminders' />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className='flex items-center justify-between space-x-2'>
|
||||
<Label className='font-normal' htmlFor='remindBefore'>
|
||||
Remind me before
|
||||
</Label>
|
||||
<Select>
|
||||
<SelectTrigger id='remindBefore'>
|
||||
<SelectValue placeholder='Select reminder time' />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value='15m'>15 minutes</SelectItem>
|
||||
<SelectItem value='30m'>30 minutes</SelectItem>
|
||||
<SelectItem value='1h'>1 hour</SelectItem>
|
||||
<SelectItem value='1d'>1 day</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
</GroupWrapper>
|
||||
{/*-------------------- Meetings --------------------*/}
|
||||
{/*-------------------- Social --------------------*/}
|
||||
<GroupWrapper title='Social'>
|
||||
<div className='space-y-4'>
|
||||
<div className='flex items-center justify-between space-x-2'>
|
||||
<Label htmlFor='friendRequests' className='font-normal'>
|
||||
Friend Requests
|
||||
</Label>
|
||||
<Switch id='friendRequests' />
|
||||
</div>
|
||||
<div className='flex items-center justify-between space-x-2'>
|
||||
<Label htmlFor='groupUpdates' className='font-normal'>
|
||||
Group Invitations/Updates
|
||||
</Label>
|
||||
<Switch id='groupUpdates' />
|
||||
</div>
|
||||
</div>
|
||||
</GroupWrapper>
|
||||
{/*-------------------- Social --------------------*/}
|
||||
</CardContent>
|
||||
</ScrollableSettingsWrapper>
|
||||
</Card>
|
||||
</div>
|
||||
<div>
|
||||
<CardFooter className='border-t h-[60px] flex content-center justify-between'>
|
||||
<Button onClick={() => router.back()} variant='secondary'>
|
||||
Exit
|
||||
</Button>
|
||||
<Button variant='primary'>Save Changes</Button>
|
||||
</CardFooter>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
147
src/components/settings/tabs/password.tsx
Normal file
147
src/components/settings/tabs/password.tsx
Normal file
|
@ -0,0 +1,147 @@
|
|||
'use client';
|
||||
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardFooter,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from '@/components/ui/card';
|
||||
|
||||
import { ScrollableSettingsWrapper } from '@/components/wrappers/settings-scroll';
|
||||
import {
|
||||
useGetApiUserMe,
|
||||
usePatchApiUserMePassword,
|
||||
} from '@/generated/api/user/user';
|
||||
import LabeledInput from '@/components/custom-ui/labeled-input';
|
||||
import { GroupWrapper } from '@/components/wrappers/group-wrapper';
|
||||
|
||||
import { BookKey, FileKey, FileKey2, RotateCcwKey } from 'lucide-react';
|
||||
import useZodForm from '@/lib/hooks/useZodForm';
|
||||
import { updateUserPasswordServerSchema } from '@/app/api/user/me/validation';
|
||||
import { useRouter } from 'next/navigation';
|
||||
|
||||
export default function PasswordTab() {
|
||||
const router = useRouter();
|
||||
const { data } = useGetApiUserMe();
|
||||
const updatePassword = usePatchApiUserMePassword();
|
||||
|
||||
const { handleSubmit, formState, register, setError } = useZodForm(
|
||||
updateUserPasswordServerSchema,
|
||||
);
|
||||
|
||||
const onSubmit = handleSubmit(async (data) => {
|
||||
await updatePassword.mutateAsync(
|
||||
{
|
||||
data: data,
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
router.refresh();
|
||||
},
|
||||
onError: (error) => {
|
||||
if (error instanceof Error) {
|
||||
setError('root', {
|
||||
message: error.response?.data.message,
|
||||
});
|
||||
} else {
|
||||
setError('root', {
|
||||
message: 'An unknown error occurred.',
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
if (!data) {
|
||||
return (
|
||||
<div className='fixed inset-0 flex items-center justify-center p-4 bg-background/50 backdrop-blur-sm'>
|
||||
<div className='rounded-lg border bg-card text-card-foreground shadow-xl max-w-[700px] w-full h-auto max-h-[calc(100vh-2rem)] flex flex-col'>
|
||||
<div className='p-6 border-b'>
|
||||
<h1 className='text-2xl font-semibold'>Loading Settings...</h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<form onSubmit={onSubmit}>
|
||||
<div className='flex-grow overflow-auto'>
|
||||
<Card className='h-full flex flex-col border-0 shadow-none rounded-none'>
|
||||
<ScrollableSettingsWrapper>
|
||||
<CardHeader>
|
||||
<CardTitle>Password Settings</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className='space-y-6 my-2'>
|
||||
{/*-------------------- Reset Password --------------------*/}
|
||||
<GroupWrapper title='Reset Password'>
|
||||
<div className='flex flex-col items-center gap-6'>
|
||||
<div className='flex flex-col sm:flex-row gap-6 w-full'>
|
||||
<div className='flex-1'>
|
||||
<LabeledInput
|
||||
type='password'
|
||||
label='Current Password'
|
||||
icon={FileKey}
|
||||
{...register('current_password')}
|
||||
error={formState.errors.current_password?.message}
|
||||
/>
|
||||
</div>
|
||||
<div className='flex-1'>
|
||||
<LabeledInput
|
||||
type='password'
|
||||
label='New Password'
|
||||
icon={FileKey2}
|
||||
{...register('new_password')}
|
||||
error={formState.errors.new_password?.message}
|
||||
/>
|
||||
</div>
|
||||
<div className='flex-1'>
|
||||
<LabeledInput
|
||||
type='password'
|
||||
label='Repeat Password'
|
||||
icon={RotateCcwKey}
|
||||
{...register('confirm_new_password')}
|
||||
error={formState.errors.confirm_new_password?.message}
|
||||
/>
|
||||
</div>
|
||||
<div className='flex items-end'>
|
||||
<Button
|
||||
variant={
|
||||
formState.isValid
|
||||
? 'outline_secondary'
|
||||
: 'outline_muted'
|
||||
}
|
||||
size='icon'
|
||||
className='w-full md:size-9'
|
||||
disabled={!formState.isValid || formState.isSubmitting}
|
||||
>
|
||||
<BookKey className='h-[1.2rem] w-[1.2rem]' />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
{formState.errors.root && (
|
||||
<p className='text-red-500 text-sm mt-1'>
|
||||
{formState.errors.root.message}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</GroupWrapper>
|
||||
{/*-------------------- Reset Password --------------------*/}
|
||||
</CardContent>
|
||||
</ScrollableSettingsWrapper>
|
||||
</Card>
|
||||
</div>
|
||||
<div>
|
||||
<CardFooter className='border-t h-[60px] flex content-center justify-between'>
|
||||
<Button onClick={() => router.back()} variant='secondary'>
|
||||
Exit
|
||||
</Button>
|
||||
<Button variant='primary'>Save Changes</Button>
|
||||
</CardFooter>
|
||||
</div>
|
||||
</form>
|
||||
);
|
||||
}
|
138
src/components/settings/tabs/privacy.tsx
Normal file
138
src/components/settings/tabs/privacy.tsx
Normal file
|
@ -0,0 +1,138 @@
|
|||
'use client';
|
||||
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardFooter,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from '@/components/ui/card';
|
||||
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { ScrollableSettingsWrapper } from '@/components/wrappers/settings-scroll';
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from '@/components/ui/select';
|
||||
import { GroupWrapper } from '@/components/wrappers/group-wrapper';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { IconButton } from '@/components/buttons/icon-button';
|
||||
import { UserLock } from 'lucide-react';
|
||||
|
||||
export default function PrivacyTab() {
|
||||
const router = useRouter();
|
||||
return (
|
||||
<>
|
||||
<div className='flex-grow overflow-auto'>
|
||||
<Card className='h-full flex flex-col border-0 shadow-none rounded-none'>
|
||||
<ScrollableSettingsWrapper>
|
||||
<CardHeader>
|
||||
<CardTitle>Sharing & Privacy</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className='space-y-6 my-2'>
|
||||
{/*-------------------- Privacy Settigs --------------------*/}
|
||||
<GroupWrapper title='Privacy Settings'>
|
||||
<div className='flex flex-col space-y-4'>
|
||||
<div className='grid grid-cols-1 gap-1'>
|
||||
<Label htmlFor='defaultVisibility'>
|
||||
Default Calendar Visibility
|
||||
</Label>
|
||||
<span className='text-sm text-muted-foreground'>
|
||||
Default setting for new friends.
|
||||
</span>
|
||||
<Select>
|
||||
<SelectTrigger id='defaultVisibility'>
|
||||
<SelectValue placeholder='Select visibility' />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value='private'>
|
||||
Private (Only You)
|
||||
</SelectItem>
|
||||
<SelectItem value='freebusy'>Free/Busy</SelectItem>
|
||||
<SelectItem value='fulldetails'>
|
||||
Full Details
|
||||
</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div className='grid grid-cols-1 gap-1'>
|
||||
<Label htmlFor='whoCanSeeFull'>
|
||||
Who Can See Your Full Calendar Details?
|
||||
</Label>
|
||||
<span className='text-sm text-muted-foreground'>
|
||||
(Override for Default Visibility)
|
||||
<br />
|
||||
<span className='text-sm text-muted-foreground'>
|
||||
This setting will override the default visibility for
|
||||
your calendar. You can set specific friends or groups to
|
||||
see your full calendar details.
|
||||
</span>
|
||||
</span>
|
||||
<Select>
|
||||
<SelectTrigger id='whoCanSeeFull'>
|
||||
<SelectValue placeholder='Select audience' />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value='me'>Only Me</SelectItem>
|
||||
<SelectItem value='friends'>My Friends</SelectItem>
|
||||
<SelectItem value='specific'>
|
||||
Specific Friends/Groups (manage separately)
|
||||
</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div className='grid grid-cols-1 gap-1'>
|
||||
<Label htmlFor='whoCanBook'>
|
||||
Who Can Book Time With You?
|
||||
</Label>
|
||||
<Select>
|
||||
<SelectTrigger id='whoCanBook'>
|
||||
<SelectValue placeholder='Select audience' />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value='none'>No One</SelectItem>
|
||||
<SelectItem value='friends'>My Friends</SelectItem>
|
||||
<SelectItem value='specific'>
|
||||
Specific Friends/Groups (manage separately)
|
||||
</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div className='space-y-4'>
|
||||
<div className='grid grid-cols-1 gap-1'>
|
||||
<Label>Blocked Users</Label>
|
||||
<span className='text-sm text-muted-foreground'>
|
||||
Prevent specific users from seeing your calendar or
|
||||
booking time.
|
||||
</span>
|
||||
<IconButton
|
||||
variant='outline_muted'
|
||||
size='sm'
|
||||
icon={UserLock}
|
||||
>
|
||||
Manage Blocked Users
|
||||
</IconButton>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</GroupWrapper>
|
||||
{/*-------------------- Privacy Settigs --------------------*/}
|
||||
</CardContent>
|
||||
</ScrollableSettingsWrapper>
|
||||
</Card>
|
||||
</div>
|
||||
<div>
|
||||
<CardFooter className='border-t h-[60px] flex content-center justify-between'>
|
||||
<Button onClick={() => router.back()} variant='secondary'>
|
||||
Exit
|
||||
</Button>
|
||||
<Button variant='primary'>Save Changes</Button>
|
||||
</CardFooter>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue