Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Notifications for Facility Cover Image Deletion #7609

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions src/Components/Facility/CoverImageEditModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const CoverImageEditModal = ({
facility,
}: Props) => {
const [isUploading, setIsUploading] = useState(false);
const [isDeleting, setIsDeleting] = useState(false);
rithviknishad marked this conversation as resolved.
Show resolved Hide resolved
const [selectedFile, setSelectedFile] = useState<any>();
const [preview, setPreview] = useState<string>();
const [isCameraOpen, setIsCameraOpen] = useState<boolean>(false);
Expand Down Expand Up @@ -143,14 +144,16 @@ const CoverImageEditModal = ({
};

const handleDelete = async () => {
setIsDeleting(true);
const { res } = await request(routes.deleteFacilityCoverImage, {
pathParams: { id: facility.id! },
});
if (res?.ok) {
Success({ msg: "Cover image deleted" });
onDelete?.();
closeModal();
}
setIsDeleting(false);
onDelete?.();
closeModal();
};

const hasImage = !!(preview || facility.read_cover_image_url);
Expand Down Expand Up @@ -283,9 +286,19 @@ const CoverImageEditModal = ({
<ButtonV2
variant="danger"
onClick={handleDelete}
disabled={isUploading}
disabled={isDeleting}
>
{t("delete")}
{isDeleting ? (
<CareIcon
icon="l-spinner"
className="animate-spin text-lg"
/>
) : (
<CareIcon icon="l-save" className="text-lg" />
)}
<span>
{isDeleting ? `${t("Deleting")}...` : `${t("delete")}`}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we using capital key Deleting? 🤔

Copy link
Contributor Author

@AnkurPrabhu AnkurPrabhu Apr 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will change it to deleting

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we have something simlar to disabling cover that disables the entrie action on save?

Copy link
Contributor Author

@AnkurPrabhu AnkurPrabhu Apr 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i just used what we already do for upload we just wanted a re-render to happen here in order to fix the bug, should i remove it ?

</span>
</ButtonV2>
)}
<ButtonV2
Expand Down
Loading