fix: delete image preview after modal close (#511)

This commit is contained in:
Aaryan Khandelwal 2023-03-23 22:55:12 +05:30 committed by GitHub
parent 6962d7718f
commit 19434342d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View File

@ -14,7 +14,7 @@ import { PrimaryButton, SecondaryButton } from "components/ui";
// icons
import { UserCircleIcon } from "components/icons";
type TImageUploadModalProps = {
type Props = {
value?: string | null;
onClose: () => void;
isOpen: boolean;
@ -22,7 +22,7 @@ type TImageUploadModalProps = {
userImage?: boolean;
};
export const ImageUploadModal: React.FC<TImageUploadModalProps> = ({
export const ImageUploadModal: React.FC<Props> = ({
value,
onSuccess,
isOpen,
@ -59,6 +59,7 @@ export const ImageUploadModal: React.FC<TImageUploadModalProps> = ({
const imageUrl = res.asset;
onSuccess(imageUrl);
setIsImageUploading(false);
setImage(null);
})
.catch((err) => {
console.error(err);
@ -70,6 +71,7 @@ export const ImageUploadModal: React.FC<TImageUploadModalProps> = ({
const imageUrl = res.asset;
onSuccess(imageUrl);
setIsImageUploading(false);
setImage(null);
})
.catch((err) => {
console.error(err);
@ -77,6 +79,7 @@ export const ImageUploadModal: React.FC<TImageUploadModalProps> = ({
};
const handleClose = () => {
setImage(null);
onClose();
};

View File

@ -19,14 +19,14 @@ export const LinearProgressIndicator: React.FC<Props> = ({ data }) => {
return (
<Tooltip key={item.id} tooltipContent={`${item.name} ${Math.round(item.value)}%`}>
<div className="bar" style={style} />
<div style={style} />
</Tooltip>
);
});
return (
<div className="flex h-1 w-full items-center justify-between gap-1">
{total === 0 ? " - 0%" : <div className="flex h-full w-full gap-1 rounded-md">{bars}</div>}
<div className="flex h-1 w-full items-center justify-between gap-1">
{total === 0 ? " - 0%" : <div className="flex h-full w-full gap-1">{bars}</div>}
</div>
);
};