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

View File

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