Skip to content

Commit

Permalink
mail sending now works via serverless function directly in firebase. …
Browse files Browse the repository at this point in the history
…we are using a template for the emails, and now it's possible to directly answer to an mail
  • Loading branch information
fellnerse committed Jun 15, 2024
1 parent 6751c1d commit 5caf9f0
Showing 1 changed file with 25 additions and 15 deletions.
40 changes: 25 additions & 15 deletions components/FeedbackBtn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"en": {
"writeUs": "Write Us!",
"cardText": "Do you have feedback for us? Did something not work? Do you have suggestions for improvement? Let us know!",
"messageReceived": "We got your message!",
"messageReceived": "We received your message!",
"name": "Name is required",
"email": "E-mail must be valid",
"rating": "Rating is required"
Expand Down Expand Up @@ -47,7 +47,7 @@
</v-card-title>

<v-card-text class="pt-4 pb-0 text-h6">
{{ $t("cardText") }}
{{ !message ? $t("cardText") : "" }}
<v-form
v-if="!message"
ref="form"
Expand Down Expand Up @@ -116,14 +116,14 @@ export default {
email: "",
emailRules: [
(v) => !!v || this.$t("email"),
(v) => /.+@.+\..+/.test(v) || this.$t("email"),
(v) => /.+@.+\..+/.test(v) || this.$t("email")
],
text: "",
starValue: 0,
starRules: [(v) => !!v || this.$t("rating")],
select: null,
dialog: false,
message: null,
message: null
};
},
Expand All @@ -132,23 +132,33 @@ export default {
const valid = this.$refs.form.validate();
if (valid) {
this.valid = false;
const mail = {
toUids: ["sebastian"],
ccUids: ["adrian", "mo", "paul"],
from: this.email,
replyTo: this.email,
template: {
name: "feedback",
data: {
name: this.name,
text: this.text,
rating: this.starValue,
locale: this.$i18n.locale,
email: this.email
},
created: this.$fireModule.firestore.FieldValue.serverTimestamp()
}
};
this.$fire.firestore
.collection("messages")
.collection("mail")
.doc()
.set({
name: this.name,
email: this.email,
text: this.text,
rating: this.starValue,
locale: this.$i18n.locale,
created: this.$fireModule.firestore.FieldValue.serverTimestamp(),
})
.set(mail)
.then(() => {
this.message = this.$t("messageReceived");
});
}
},
},
}
}
};
</script>
<style scoped>
Expand Down

0 comments on commit 5caf9f0

Please sign in to comment.