diff --git a/app/javascript/components/UserProfile/DeleteAvatarButton.tsx b/app/javascript/components/UserProfile/DeleteAvatarButton.tsx index ee9314ce..403e91f6 100644 --- a/app/javascript/components/UserProfile/DeleteAvatarButton.tsx +++ b/app/javascript/components/UserProfile/DeleteAvatarButton.tsx @@ -8,10 +8,11 @@ import Spinner from '../common/Spinner'; interface Props { deleteAvatarEndpoint: string; + userProfileUrl: string; authenticityToken: string; } -const DeleteAvatarButton = ({ deleteAvatarEndpoint, authenticityToken }: Props) => { +const DeleteAvatarButton = ({ deleteAvatarEndpoint, userProfileUrl, authenticityToken }: Props) => { const [isDeleting, setIsDeleting] = React.useState(false); const [error, setError] = React.useState(''); @@ -29,7 +30,7 @@ const DeleteAvatarButton = ({ deleteAvatarEndpoint, authenticityToken }: Props) }); if (response.ok) { - location.reload(); + window.location.href = userProfileUrl; } else { throw new Error(); } diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index c409a44c..1f292554 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -39,6 +39,7 @@ 'UserProfile/DeleteAvatarButton', { deleteAvatarEndpoint: delete_avatar_path, + userProfileUrl: edit_user_registration_path, authenticityToken: form_authenticity_token } )