diff --git a/pages/index.vue b/pages/index.vue index db37ade..6e336a1 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -1,6 +1,6 @@ @@ -123,7 +136,10 @@ export default { count: 0, TIME_LIMIT: 60, sending: false, - uploadProgress: 0 + uploadProgress: 0, + snackbar: false, + snackbarText: '', + snackbarError: false } }, created() { @@ -235,10 +251,14 @@ export default { console.warn('Recording stopped') }, send() { + this.snackbar = false this.sending = true const selectedTrack = this.recordings[this.selected] const storageRef = this.$fireStorage.ref() - const audioRef = storageRef.child(`${this.name}-${selectedTrack.id}`) + const today = new Date().toLocaleDateString('es-MX').replace(/\//g, '-') + const audioRef = storageRef.child( + `${today}/${this.name}-${selectedTrack.id}` + ) const uploadTask = audioRef.put(selectedTrack.blob) @@ -250,11 +270,18 @@ export default { }, () => { // error + this.snackbar = true + this.snackbarError = true + this.snackbarText = 'There was an error, please try again 😖' }, () => { // success this.sending = false this.uploadProgress = 0 + + this.snackbar = true + this.snackbarText = + "Your audio was uploaded!
We'll make sure to add it in the next available spot in the newsletter 😎" } ) }