This commit is contained in:
nabijonovdavronbek619@gmail.com
2026-04-06 15:43:51 +05:00
parent 89c5552c4e
commit 27b1510842
23 changed files with 1871 additions and 26 deletions

View File

@@ -0,0 +1,35 @@
'use client';
import { useState } from 'react';
import type { UserProfile } from '../types';
interface ProfileForm extends UserProfile {
currentPassword: string;
newPassword: string;
confirmPassword: string;
}
export const useProfile = (initial: UserProfile) => {
const [form, setForm] = useState<ProfileForm>({
...initial,
currentPassword: '',
newPassword: '',
confirmPassword: '',
});
const [isSaving, setIsSaving] = useState(false);
const [saved, setSaved] = useState(false);
const handleChange = (field: keyof ProfileForm, value: string) => {
setForm((prev) => ({ ...prev, [field]: value }));
setSaved(false);
};
const handleSave = async () => {
setIsSaving(true);
// TODO: replace with real API call
await new Promise((res) => setTimeout(res, 800));
setIsSaving(false);
setSaved(true);
};
return { form, isSaving, saved, handleChange, handleSave };
};