2026-03-16 16:56:30 +01:00
|
|
|
|
import { useCallback } from 'react';
|
2026-03-12 11:42:29 +01:00
|
|
|
|
import type { FC } from 'react';
|
|
|
|
|
|
|
2026-03-16 16:56:30 +01:00
|
|
|
|
import { FormattedMessage } from 'react-intl';
|
|
|
|
|
|
|
|
|
|
|
|
import { Button } from '@/mastodon/components/button';
|
|
|
|
|
|
import { deleteImage } from '@/mastodon/reducers/slices/profile_edit';
|
2026-03-16 12:39:52 +01:00
|
|
|
|
import type { ImageLocation } from '@/mastodon/reducers/slices/profile_edit';
|
2026-03-16 16:56:30 +01:00
|
|
|
|
import { useAppDispatch, useAppSelector } from '@/mastodon/store';
|
2026-03-16 12:39:52 +01:00
|
|
|
|
|
2026-03-12 11:42:29 +01:00
|
|
|
|
import { DialogModal } from '../../ui/components/dialog_modal';
|
|
|
|
|
|
import type { DialogModalProps } from '../../ui/components/dialog_modal';
|
|
|
|
|
|
|
|
|
|
|
|
export const ImageDeleteModal: FC<
|
|
|
|
|
|
DialogModalProps & { location: ImageLocation }
|
2026-03-16 16:56:30 +01:00
|
|
|
|
> = ({ onClose, location }) => {
|
|
|
|
|
|
const isPending = useAppSelector((state) => state.profileEdit.isPending);
|
|
|
|
|
|
const dispatch = useAppDispatch();
|
|
|
|
|
|
const handleDelete = useCallback(() => {
|
|
|
|
|
|
void dispatch(deleteImage({ location })).then(onClose);
|
|
|
|
|
|
}, [dispatch, location, onClose]);
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<DialogModal
|
|
|
|
|
|
onClose={onClose}
|
|
|
|
|
|
title={
|
|
|
|
|
|
<FormattedMessage
|
|
|
|
|
|
id='account_edit.image_delete_modal.title'
|
|
|
|
|
|
defaultMessage='Delete image?'
|
|
|
|
|
|
/>
|
|
|
|
|
|
}
|
|
|
|
|
|
buttons={
|
|
|
|
|
|
<Button dangerous onClick={handleDelete} disabled={isPending}>
|
|
|
|
|
|
<FormattedMessage
|
|
|
|
|
|
id='account_edit.image_delete_modal.delete_button'
|
|
|
|
|
|
defaultMessage='Delete'
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
}
|
|
|
|
|
|
>
|
|
|
|
|
|
<FormattedMessage
|
|
|
|
|
|
id='account_edit.image_delete_modal.confirm'
|
|
|
|
|
|
defaultMessage='Are you sure you want to delete this image? This action can’t be undone.'
|
|
|
|
|
|
tagName='p'
|
|
|
|
|
|
/>
|
|
|
|
|
|
</DialogModal>
|
|
|
|
|
|
);
|
2026-03-12 11:42:29 +01:00
|
|
|
|
};
|