Add Notification Provider

This commit is contained in:
headlesdev
2025-05-25 00:32:16 +02:00
parent ddc88796d2
commit 6ba144b7bd
6 changed files with 153 additions and 6 deletions

View File

@@ -14,8 +14,10 @@ export async function POST(request: NextRequest) {
const body = await request.json();
const { name, type, config } = schema.parse(body);
const parsedConfig = JSON.parse(config);
const notification = await prisma.notificationProvider.create({
data: { name, type: type as NotificationType, config, tests: {} },
data: { name, type: type as NotificationType, config: parsedConfig},
});
return NextResponse.json({ notification }, { status: 201 });

View File

@@ -2,8 +2,10 @@
import Sidebar from '@/components/Sidebar';
import ErrorToast from '@/components/Error';
import SuccessToast from '@/components/Success';
import { ProfileSettings } from '@/components/cards/settings/ProfileSettings';
import { PasswordSettings } from '@/components/cards/settings/PasswordSettings';
import { NotificationSettings } from '@/components/cards/settings/NotificationSettings';
import { useState } from 'react';
interface SettingsPageProps {
@@ -14,7 +16,7 @@ interface SettingsPageProps {
export default function SettingsPage({ username, name, email }: SettingsPageProps) {
const [error, setError] = useState('');
const [success, setSuccess] = useState('');
return (
<div>
@@ -57,13 +59,14 @@ export default function SettingsPage({ username, name, email }: SettingsPageProp
<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">
test
<NotificationSettings onError={setError} onSuccess={setSuccess} />
</div>
</div>
</div>
</main>
</Sidebar>
<ErrorToast message={error} show={error !== ''} onClose={() => setError('')} />
<SuccessToast message={success} show={success !== ''} onClose={() => setSuccess('')} />
</div>
);
}