Skip to content

Commit

Permalink
upload image on profile view
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Lopes committed Aug 26, 2020
1 parent 6ea5c7e commit 927782e
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions src/views/public/Register.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</v-btn>
<v-col class="d-flex justify-center align-center">
<v-avatar color="orange" size="62">
<v-icon @click="onFileSelected" v-if="!src" dark>mdi-account-circle</v-icon>
<v-icon class="cp" @click="onFileSelected" v-if="!src" dark>mdi-account-circle</v-icon>
<img v-else :src="src" alt="avatar">
<input @change="onFilePicked" type="file" class="hiden-input" ref="fileInput" accept="image/*">
</v-avatar>
Expand Down Expand Up @@ -45,6 +45,7 @@ import {
mapActions
} from 'vuex'
import uploadImageToFirebase from '../../util/firebase'
import axios from 'axios';
export default {
Expand All @@ -55,6 +56,9 @@ export default {
switch1: false,
uploadUrl:process.env.VUE_APP_UPLOAD_URL,
form: {
name: null,
Expand Down Expand Up @@ -89,12 +93,6 @@ export default {
const files = event.target.files
this.targetFile = event.target.files[0]
// const imgFirebaseURL = await uploadImageToFirebase(targetFile)
// console.log('uploadddddddddddddddddddddddddddddddd')
// console.log(imgFirebaseURL)
const fileReader = new FileReader()
fileReader.addEventListener('load', () => { this.src = fileReader.result })
fileReader.readAsDataURL(files[0])
Expand All @@ -110,20 +108,18 @@ export default {
this.validation()
const imgFirebaseURL = await uploadImageToFirebase(this.targetFile)
console.log('uploadddddddddddddddddddddddddddddddd')
console.log(imgFirebaseURL) // ESTÁ DANDO VAZIO POIS NÃO ESTÁ ESPERANDO O RETORNO DA URL DA FUNÇÃO "uploadImageToFirebase()"
this.form.avatar = imgFirebaseURL
this.loading = true
const fd = new FormData();
fd.append('photo', this.targetFile);
const uploadedFile = await axios.post(this.uploadUrl + '/upload/image', fd).then(resp => { this.form.avatar = resp.data })
this.form.avatar = uploadedFile
// this.loading = true
this.$toast.info('Estamos fazendo seu registo.', 'Hey', {
position: "topCenter"
})
const imgURL = await uploadImageToFirebase(this.form.avatar)
})
this.form.avatar = imgURL
console.log(this.form)
const register = await this.register(this.form)
Expand Down

0 comments on commit 927782e

Please sign in to comment.