Skip to content

Commit

Permalink
fix upload image overview
Browse files Browse the repository at this point in the history
  • Loading branch information
YudhistiraA committed Jan 7, 2025
1 parent 351405a commit a432439
Showing 1 changed file with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Editor from "@/Components/Forms/Fields/BubleTextEditor/EditorV2.vue"
import { getStyles } from "@/Composables/styles"
import GalleryManagement from "@/Components/Utils/GalleryManagement/GalleryManagement.vue"
import Modal from "@/Components/Utils/Modal.vue"
import { notify } from "@kyvg/vue3-notification"
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"
import { faImage, faEdit } from "@far"
Expand Down Expand Up @@ -104,6 +105,33 @@ const onChangeImage = (image) => {
onSave()
}
const onUpload = async (files: File[], clear: Function) => {
try {
const formData = new FormData()
Array.from(files).forEach((file, index) => {
formData.append(`images[${index}]`, file)
})
const response = await axios.post(
route(props.webpageData?.images_upload_route.name, { modelHasWebBlocks: props.blockData.id }),
formData,
{
headers: {
"Content-Type": "multipart/form-data",
},
}
)
onChangeImage(response.data.data)
} catch (error) {
console.log(error)
notify({
title: "Failed",
text: "Error while uploading data",
type: "error",
})
}
}
onMounted(() => {
document.addEventListener("click", handleClickOutside)
})
Expand Down Expand Up @@ -222,6 +250,8 @@ onBeforeUnmount(() => {
},
}"
:closePopup="() => (isModalGallery = false)"
@submitSelectedImages="onChangeImage" />
@submitSelectedImages="onChangeImage"
:submitUpload="onUpload"
/>
</Modal>
</template>

0 comments on commit a432439

Please sign in to comment.