Skip to content

Commit

Permalink
Image null bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mwlt68 committed Mar 11, 2023
1 parent 2f93cf1 commit 67295a9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/ui/image-picker/ImagePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import AddPhotoAlternateIcon from "@mui/icons-material/AddPhotoAlternate";
import RemoveCircleIcon from "@mui/icons-material/RemoveCircle";
import PhotoIcon from "@mui/icons-material/Photo";

export type ImageUrlHandleFunction = () => string | null;
export type ImageUrlHandleFunction = () => string | undefined;
export type ImageChangeHandleFunction = (file: File | undefined) => void;
export type ImageOperationProps = {
imageUrlHandle: ImageUrlHandleFunction;
Expand Down
7 changes: 3 additions & 4 deletions src/pages/product/ProductPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,12 @@ export default function ProductPage() {
setPickedImage(file);
}

const getImageUrl = (): string | null => {
debugger;
const getImageUrl = (): string | undefined => {
if (pickedImage != null) return URL.createObjectURL(pickedImage);
else
return product.image != null
return product.image != null && product.image.length > 0
? "data:image/png;base64," + product.image
: null;
: undefined;
};

return (
Expand Down

0 comments on commit 67295a9

Please sign in to comment.