CoreControl/app/dashboard/settings/SettingsPage.tsx

88 lines
3.3 KiB
TypeScript
Raw Normal View History

2025-05-17 21:39:10 +02:00
'use client';
2025-05-17 20:17:39 +02:00
2025-05-17 21:39:10 +02:00
import Sidebar from '@/components/Sidebar';
import ErrorToast from '@/components/Error';
2025-05-25 00:32:16 +02:00
import SuccessToast from '@/components/Success';
2025-05-20 23:45:21 +02:00
import { ProfileSettings } from '@/components/cards/settings/ProfileSettings';
import { PasswordSettings } from '@/components/cards/settings/PasswordSettings';
2025-05-26 11:30:19 +02:00
import { NotificationProviderSettings } from '@/components/cards/settings/NotificationProviderSettings';
import { NotificationSettings } from '@/components/cards/settings/NotificationSettings';
2025-05-29 12:32:00 +02:00
import { MonitoringSettings } from '@/components/cards/settings/MonitoringSettings';
2025-05-17 21:39:10 +02:00
import { useState } from 'react';
2025-05-17 20:17:39 +02:00
2025-05-17 21:25:09 +02:00
interface SettingsPageProps {
2025-05-17 21:39:10 +02:00
username: string;
name: string;
email: string;
2025-05-17 20:17:39 +02:00
}
2025-05-17 21:39:10 +02:00
export default function SettingsPage({ username, name, email }: SettingsPageProps) {
const [error, setError] = useState('');
2025-05-25 00:32:16 +02:00
const [success, setSuccess] = useState('');
2025-05-24 15:40:08 +02:00
2025-05-17 21:39:10 +02:00
return (
<div>
<Sidebar
username={username}
fullName={name}
breadcrumbPath={['/', 'Dashboard', 'Settings']}
>
<main>
<h1 className="text-2xl font-bold">Settings</h1>
<p className="text-sm opacity-70">Manage your instance settings</p>
<div className="tabs tabs-border pt-8">
<input
type="radio"
2025-05-24 19:51:17 +02:00
name="settings"
2025-05-17 21:39:10 +02:00
className="tab text-primary z-10"
aria-label="User Settings"
2025-05-24 15:40:08 +02:00
defaultChecked
2025-05-17 21:39:10 +02:00
/>
<div className="tab-content relative bg-base-100 pl-4 pt-4">
<div className="absolute -top-[3px] left-6 right-0 h-[2px] bg-stone-800"></div>
2025-05-24 15:40:08 +02:00
<div className="flex flex-col gap-4">
2025-05-17 21:39:10 +02:00
<ProfileSettings
initialUsername={username}
initialName={name}
initialEmail={email}
onError={setError}
/>
2025-05-24 15:40:08 +02:00
<PasswordSettings onError={setError} />
</div>
</div>
<input
type="radio"
2025-05-24 19:51:17 +02:00
name="settings"
2025-05-24 15:40:08 +02:00
className="tab text-primary z-10"
2025-05-25 01:10:21 +02:00
aria-label="Notification Settings"
2025-05-24 15:40:08 +02:00
/>
<div className="tab-content relative bg-base-100 pl-4 pt-4">
<div className="absolute -top-[3px] left-6 right-0 h-[2px] bg-stone-800"></div>
<div className="flex flex-col gap-4">
2025-05-26 11:30:19 +02:00
<NotificationProviderSettings onError={setError} onSuccess={setSuccess} />
2025-05-25 00:32:16 +02:00
<NotificationSettings onError={setError} onSuccess={setSuccess} />
2025-05-17 21:39:10 +02:00
</div>
</div>
2025-05-29 12:32:00 +02:00
<input
type="radio"
name="settings"
className="tab text-primary z-10"
aria-label="Monitoring Settings"
/>
<div className="tab-content relative bg-base-100 pl-4 pt-4">
<div className="absolute -top-[3px] left-6 right-0 h-[2px] bg-stone-800"></div>
<div className="flex flex-col gap-4">
<MonitoringSettings onError={setError} onSuccess={setSuccess} />
</div>
</div>
2025-05-17 21:39:10 +02:00
</div>
</main>
</Sidebar>
<ErrorToast message={error} show={error !== ''} onClose={() => setError('')} />
2025-05-25 00:32:16 +02:00
<SuccessToast message={success} show={success !== ''} onClose={() => setSuccess('')} />
2025-05-17 21:39:10 +02:00
</div>
);
2025-05-17 20:17:39 +02:00
}