From 50cbca3c307894c9fd55baec522b7b794d9ab805 Mon Sep 17 00:00:00 2001 From: l3wdfut4pwr Date: Mon, 27 Apr 2026 14:18:18 +0300 Subject: add description change --- src/app/profile/[username]/page.tsx | 2 +- src/components/settings/AboutMe.tsx | 60 +++++++++++++++++++++++---------- src/components/settings/ProfilePage.tsx | 33 +++--------------- src/lib/api/ChangeDescription.tsx | 45 +++++++++++++++++++++++++ 4 files changed, 93 insertions(+), 47 deletions(-) create mode 100644 src/lib/api/ChangeDescription.tsx (limited to 'src') diff --git a/src/app/profile/[username]/page.tsx b/src/app/profile/[username]/page.tsx index cb79b7b..7eab697 100644 --- a/src/app/profile/[username]/page.tsx +++ b/src/app/profile/[username]/page.tsx @@ -49,7 +49,7 @@ export default async function Profile({ params }: ProfilePageProps) {

-

{profileUser.description}

+

{profileUser.profile?.description}

{icons diff --git a/src/components/settings/AboutMe.tsx b/src/components/settings/AboutMe.tsx index 769885a..bcb6f58 100644 --- a/src/components/settings/AboutMe.tsx +++ b/src/components/settings/AboutMe.tsx @@ -1,38 +1,62 @@ import { useState } from 'react'; -import { ChangeEvent } from 'react'; -import { Input } from '@/components/ui/input'; import { Button } from '@/components/ui/button'; +import { changeDescription } from '@/lib/api/ChangeDescription'; + export default function AboutMe() { const maxLength = 250; - const [text, setText] = useState(''); - const handleChange = (e: ChangeEvent) => { - const value = e.target.value; + const [about, setAbout] = useState(''); + const [loading, setLoading] = useState(false); + const [error, setError] = useState(null); + + const handleSave = async () => { + if (loading) return; + + setLoading(true); + setError(null); + + const res = await changeDescription(about); - if (value.length <= maxLength) { - setText(value); + if (res.error) { + setError(res.error.general); } + + setLoading(false); }; return (
-

- ОБО МНЕ -

- -
- ОБО МНЕ

+ +
+