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: lead image preview issue in apps overview #1255

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
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
15 changes: 14 additions & 1 deletion src/components/pages/AppOverview/ChangeImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default function ChangeImage() {
const { state } = useLocation()
const items = state
const [cardImage, setCardImage] = useState('')
const [previewLocalCardImage, setPreviewLocalCardImage] = useState('')
const [enableImageUpload, setEnableImageUpload] = useState(false)
const [updateImageData] = useUpdateImageDataMutation()
const [fetchDocumentById] = useFetchDocumentByIdMutation()
Expand Down Expand Up @@ -134,6 +135,15 @@ export default function ChangeImage() {
}
}

const cardImageData: string | null = getValues().uploadLeadImage

useEffect(() => {
if (cardImageData) {
const blobFile = new Blob([cardImageData], { type: 'image/png' })
setPreviewLocalCardImage(URL.createObjectURL(blobFile))
}
}, [cardImageData])

return (
<main className="change-image-main">
<PageHeader title={app?.[0]?.title} headerHeight={200} topPage={true} />
Expand All @@ -155,7 +165,7 @@ export default function ChangeImage() {
<Box sx={{ width: '40%' }}>
<Card
image={{
src: cardImage,
src: previewLocalCardImage || cardImage,
}}
title={app[0]?.title || ''}
subtitle={app[0]?.provider}
Expand All @@ -178,6 +188,9 @@ export default function ChangeImage() {
name="uploadLeadImage"
isRequired={false}
size="small"
handleDelete={() => {
setPreviewLocalCardImage('')
}}
/>
</Box>
) : (
Expand Down
Loading