Skip to content

Instantly share code, notes, and snippets.

@trithien98
Created August 23, 2022 09:24
Show Gist options
  • Save trithien98/bd167f8cdbb5bb4b937aecb15a8ffd0f to your computer and use it in GitHub Desktop.
Save trithien98/bd167f8cdbb5bb4b937aecb15a8ffd0f to your computer and use it in GitHub Desktop.
@action
onChangePhotoUpload = async (event) => {
const file = event?.target?.files?.[0]
if (!file) {
return
}
if (!file.type?.startsWith('image/')) {
notifyStore.error('$ERRORS.ONLY_SUPPORT_IMAGE')
return
}
const signedBlobId = await uploadFile(file)
const fileUrl = URL?.createObjectURL(file)
const image = {
id: `${TEMP_ID}_${nanoid()}`,
signedBlobId,
filename: file.name,
contentType: file.type,
fileUrl,
}
this.timesheetImages = [...this.timesheetImages, image]
this.saveFirebaseData(this.submitData.id)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment