added missing Settings functionality, moved ntfy setting

This commit is contained in:
PxlLoewe
2025-07-17 01:08:10 -07:00
parent 44427a1b4b
commit 11b1d8745d
9 changed files with 141 additions and 150 deletions

View File

@@ -20,9 +20,7 @@ import {
LockOpen1Icon,
} from "@radix-ui/react-icons";
import toast from "react-hot-toast";
import { UserOptionalDefaults, UserOptionalDefaultsSchema } from "@repo/db/zod";
import { Bell, CircleAlert, Plane, Trash2 } from "lucide-react";
import Link from "next/link";
import { CircleAlert, Trash2 } from "lucide-react";
import { deleteUser, sendVerificationLink } from "(app)/admin/user/action";
import { setStandardName } from "../../../../helper/discord";
@@ -458,78 +456,3 @@ export const PasswordForm = (): React.JSX.Element => {
</form>
);
};
export const PilotForm = ({ user }: { user: User }): React.JSX.Element | null => {
const [isLoading, setIsLoading] = useState(false);
const form = useForm<UserOptionalDefaults>({
defaultValues: {
...user,
emailVerified: user.emailVerified ?? undefined,
},
resolver: zodResolver(UserOptionalDefaultsSchema),
});
if (!user) return null;
return (
<form
className="card-body"
onSubmit={form.handleSubmit(async (values) => {
form.handleSubmit(async () => {
setIsLoading(true);
});
await updateUser(values);
setIsLoading(false);
form.reset(values);
toast.success("Deine Änderungen wurden gespeichert!", {
style: {
background: "var(--color-base-100)",
color: "var(--color-base-content)",
},
});
})}
>
<h2 className="card-title mb-5">
<Plane className="w-5 h-5" /> Pilot
</h2>
<div className="content-center">
<label className="floating-label w-full">
<span className="text-lg flex items-center gap-2">
<Bell /> NTFY room
</span>
<input
placeholder="Erhalte eine Benachrichtigung auf dein Handy über NTFY"
className="input input-bordered w-full"
{...form.register("settingsNtfyRoom")}
/>
</label>
<p className="label mt-2 w-full">
<Link
href="https://docs.virtualairrescue.com/docs/Leitstelle/App-Alarmierung#download"
target="_blank"
rel="noopener noreferrer"
className="link link-hover link-primary"
>
Hier
</Link>
findest du mehr Informationen!
</p>
{form.formState.errors.settingsNtfyRoom && (
<p className="text-error">{form.formState.errors.settingsNtfyRoom.message}</p>
)}
</div>
<div className="card-actions justify-center pt-6 mt-auto">
<Button
className="btn-sm btn-wide btn-outline btn-primary"
isLoading={isLoading}
disabled={!form.formState.isDirty}
role="submit"
>
<BookmarkIcon /> Speichern
</Button>
</div>
</form>
);
};

View File

@@ -1,6 +1,6 @@
import { prisma } from "@repo/db";
import { getServerSession } from "../../api/auth/[...nextauth]/auth";
import { ProfileForm, SocialForm, PasswordForm, PilotForm, DeleteForm } from "./_components/forms";
import { ProfileForm, SocialForm, PasswordForm, DeleteForm } from "./_components/forms";
import { GearIcon } from "@radix-ui/react-icons";
import { Error } from "_components/Error";
@@ -48,9 +48,6 @@ export default async function Page() {
<div className="card bg-base-200 shadow-xl mb-4 col-span-6 xl:col-span-3">
<PasswordForm />
</div>
<div className="card bg-base-200 shadow-xl mb-4 col-span-6 xl:col-span-3">
<PilotForm user={user} />
</div>
<div className="card bg-base-200 shadow-xl mb-4 col-span-6 xl:col-span-3">
<DeleteForm user={user} penaltys={userPenaltys} />
</div>