mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 02:31:12 -05:00
Refactor: Add button feedback
This commit is contained in:
@@ -525,6 +525,8 @@ export default function Profile() {
|
||||
setFormErrors({});
|
||||
return true;
|
||||
};
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
|
||||
const handleSaveProfile = async () => {
|
||||
if (!profile || !currentUser) return;
|
||||
if (!validateForm()) return;
|
||||
@@ -533,6 +535,8 @@ export default function Profile() {
|
||||
setShowUsernameDialog(true);
|
||||
return;
|
||||
}
|
||||
|
||||
setIsSaving(true);
|
||||
try {
|
||||
const updateData: any = {
|
||||
display_name: editForm.display_name,
|
||||
@@ -572,6 +576,8 @@ export default function Profile() {
|
||||
title: "Error updating profile",
|
||||
description: getErrorMessage(error)
|
||||
});
|
||||
} finally {
|
||||
setIsSaving(false);
|
||||
}
|
||||
};
|
||||
const confirmUsernameChange = () => {
|
||||
@@ -730,7 +736,14 @@ export default function Profile() {
|
||||
</div>
|
||||
|
||||
<div className="flex gap-2">
|
||||
<Button onClick={handleSaveProfile} size="sm" disabled={usernameValidation.isChecking || editForm.username !== profile?.username && !usernameValidation.isValid}>
|
||||
<Button
|
||||
onClick={handleSaveProfile}
|
||||
size="sm"
|
||||
loading={isSaving}
|
||||
loadingText="Saving..."
|
||||
disabled={usernameValidation.isChecking || editForm.username !== profile?.username && !usernameValidation.isValid}
|
||||
trackingLabel="save-profile-changes"
|
||||
>
|
||||
<Save className="w-4 h-4 mr-2" />
|
||||
Save Changes
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user