fixed code v2
This commit is contained in:
@@ -124,13 +124,12 @@ function ContactFields({ form, errors, onChange, onPhoneChange }) {
|
||||
}
|
||||
|
||||
// ─── Submit button ──────────────────────────────────────────────────────────
|
||||
function SubmitButton({ loading, onSubmit }) {
|
||||
function SubmitButton({ loading }) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<button
|
||||
className="f-m-submit"
|
||||
type="submit"
|
||||
onClick={onSubmit}
|
||||
disabled={loading}
|
||||
>
|
||||
<div className="f-m-submit-row">
|
||||
|
||||
@@ -69,12 +69,12 @@ export default function ProfileModal({ onClose, initialData = {} }) {
|
||||
avatar: newAvatars.length > 0 ? newAvatars[0] : (keptExisting.length > 0 ? keptExisting[0] : null),
|
||||
};
|
||||
|
||||
const updatedUser = await updateProfile(user?.id, profileData);
|
||||
|
||||
if (updatedUser) {
|
||||
updateUser(updatedUser);
|
||||
const result = await updateProfile(user?.id, profileData);
|
||||
if (result.success) {
|
||||
updateUser(result.data);
|
||||
onClose();
|
||||
}
|
||||
// при неудаче result.error уже отражена в saveError через error state хука
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -116,9 +116,9 @@ export default function ProfileModal({ onClose, initialData = {} }) {
|
||||
onPhoneChange={handlePhoneChange}
|
||||
/>
|
||||
|
||||
{saveError && <p className="f-err-msg" style={{ marginBottom: 10 }}>{saveError}</p>}
|
||||
{saveError && <p className="f-err-msg auth-form-error">{saveError}</p>}
|
||||
|
||||
<SubmitButton loading={compressing || saving} onSubmit={handleSubmit} />
|
||||
<SubmitButton loading={compressing || saving} />
|
||||
|
||||
<button
|
||||
type="button"
|
||||
|
||||
Reference in New Issue
Block a user