small fix

This commit is contained in:
riggraz
2025-02-06 20:56:24 +01:00
parent 3d6f8631bc
commit 03f94e3608
2 changed files with 4 additions and 2 deletions

View File

@@ -8,10 +8,11 @@ import Spinner from '../common/Spinner';
interface Props { interface Props {
deleteAvatarEndpoint: string; deleteAvatarEndpoint: string;
userProfileUrl: string;
authenticityToken: string; authenticityToken: string;
} }
const DeleteAvatarButton = ({ deleteAvatarEndpoint, authenticityToken }: Props) => { const DeleteAvatarButton = ({ deleteAvatarEndpoint, userProfileUrl, authenticityToken }: Props) => {
const [isDeleting, setIsDeleting] = React.useState(false); const [isDeleting, setIsDeleting] = React.useState(false);
const [error, setError] = React.useState(''); const [error, setError] = React.useState('');
@@ -29,7 +30,7 @@ const DeleteAvatarButton = ({ deleteAvatarEndpoint, authenticityToken }: Props)
}); });
if (response.ok) { if (response.ok) {
location.reload(); window.location.href = userProfileUrl;
} else { } else {
throw new Error(); throw new Error();
} }

View File

@@ -39,6 +39,7 @@
'UserProfile/DeleteAvatarButton', 'UserProfile/DeleteAvatarButton',
{ {
deleteAvatarEndpoint: delete_avatar_path, deleteAvatarEndpoint: delete_avatar_path,
userProfileUrl: edit_user_registration_path,
authenticityToken: form_authenticity_token authenticityToken: form_authenticity_token
} }
) )