"use client"; import { useRouter } from "next/navigation"; import { useState } from "react"; import { userNameSchema } from "@/lib/schemas"; import ProfilePictureSettings from "./profile-picture"; import SubmitDialogButton from "./submit-dialog-button"; import DeleteAccount from "./delete-account"; import z from "zod"; interface Props { currentDescription: string | null | undefined; } export default function ProfileSettings({ currentDescription }: Props) { const router = useRouter(); const [description, setDescription] = useState(currentDescription); const [name, setName] = useState(""); const [descriptionChangeError, setDescriptionChangeError] = useState(undefined); const [nameChangeError, setNameChangeError] = useState(undefined); const handleSubmitDescriptionChange = async (close: () => void) => { const parsed = z.string().trim().max(256).safeParse(description); if (!parsed.success) { setDescriptionChangeError(parsed.error.issues[0].message); return; } const response = await fetch("/api/auth/about-me", { method: "PATCH", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ description }), }); if (!response.ok) { const { error } = await response.json(); setDescriptionChangeError(error); return; } close(); router.refresh(); }; const handleSubmitNameChange = async (close: () => void) => { const parsed = userNameSchema.safeParse(name); if (!parsed.success) { setNameChangeError(parsed.error.issues[0].message); return; } const response = await fetch("/api/auth/name", { method: "PATCH", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ name }), }); if (!response.ok) { const { error } = await response.json(); setNameChangeError(error); return; } close(); router.refresh(); }; return (

Profile Settings

Update your profile picture, description, name, etc.

{/* Separator */}

Account Info
{/* Profile Picture */} {/* Description */}

Write about yourself on your profile