feat(form): Ask a Question mode on bug report

This commit is contained in:
SabreCat
2023-06-02 15:58:24 -05:00
parent 9c7f1ae630
commit f4e8bf9c2e
7 changed files with 42 additions and 41 deletions

View File

@@ -8,23 +8,15 @@
slot="modal-header" slot="modal-header"
class="bug-report-modal-header" class="bug-report-modal-header"
> >
<h2 v-once> <h2>
{{ $t('reportBug') }} {{ question ? $t('askQuestion') : $t('reportBug') }}
</h2> </h2>
<div class="report-bug-header-describe">
<div {{ question ? $t('askQuestionHeaderDescribe') : $t('reportBugHeaderDescribe') }}
v-once
class="report-bug-header-describe"
>
{{ $t('reportBugHeaderDescribe') }}
</div>
<div class="dialog-close">
<close-icon
:purple="true"
@click="close()"
/>
</div> </div>
<close-x
@click="close()"
/>
</div> </div>
<div> <div>
<form <form
@@ -40,11 +32,8 @@
> >
{{ $t('email') }} {{ $t('email') }}
</label> </label>
<div <div class="mb-2 description-label">
v-once {{ question ? $t('questionEmailText') : $t('reportEmailText') }}
class="mb-2 description-label"
>
{{ $t('reportEmailText') }}
</div> </div>
<input <input
id="emailInput" id="emailInput"
@@ -64,21 +53,18 @@
</div> </div>
</div> </div>
<label v-once> <label>
{{ $t('reportDescription') }} {{ question ? $t('question') : $t('reportDescription') }}
</label> </label>
<div <div class="mb-2 description-label">
v-once {{ question ? $t('questionDescriptionText') : $t('reportDescriptionText') }}
class="mb-2 description-label"
>
{{ $t('reportDescriptionText') }}
</div> </div>
<textarea <textarea
v-model="message" v-model="message"
class="form-control" class="form-control"
rows="5" rows="5"
:required="true" :required="true"
:placeholder="$t('reportDescriptionPlaceholder')" :placeholder="question ? $t('questionPlaceholder') : $t('reportDescriptionPlaceholder')"
:class="{'input-invalid': messageInvalid && this.message.length === 0}" :class="{'input-invalid': messageInvalid && this.message.length === 0}"
> >
@@ -89,7 +75,7 @@
type="submit" type="submit"
:disabled="!message || !emailValid" :disabled="!message || !emailValid"
> >
{{ $t('submitBugReport') }} {{ question ? $t('submitQuestion') : $t('submitBugReport') }}
</button> </button>
</form> </form>
</div> </div>
@@ -141,7 +127,7 @@ h2 {
.bug-report-modal-header { .bug-report-modal-header {
color: $white; color: $white;
width: 100%; width: 100%;
padding: 2rem 3rem 1.5rem 1.5rem; padding: 1.5rem 3rem 1.5rem 1.5rem;
background-image: linear-gradient(288deg, #{$purple-200}, #{$purple-300}); background-image: linear-gradient(288deg, #{$purple-200}, #{$purple-300});
} }
@@ -182,13 +168,13 @@ label {
<script> <script>
import axios from 'axios'; import axios from 'axios';
import isEmail from 'validator/lib/isEmail'; import isEmail from 'validator/lib/isEmail';
import closeIcon from '@/components/shared/closeIcon'; import closeX from '@/components/ui/closeX';
import { mapState } from '@/libs/store'; import { mapState } from '@/libs/store';
import { MODALS } from '@/libs/consts'; import { MODALS } from '@/libs/consts';
export default { export default {
components: { components: {
closeIcon, closeX,
}, },
data () { data () {
return { return {
@@ -211,6 +197,7 @@ export default {
await axios.post('/api/v4/bug-report', { await axios.post('/api/v4/bug-report', {
message: this.message, message: this.message,
email: this.email, email: this.email,
question: this.question,
}); });
this.message = ''; this.message = '';
@@ -233,6 +220,9 @@ export default {
if (this.email.length <= 3) return false; if (this.email.length <= 3) return false;
return !this.emailValid; return !this.emailValid;
}, },
question () {
return this.$store.state.bugReportOptions.question;
},
}, },
mounted () { mounted () {
const { user } = this; const { user } = this;

View File

@@ -312,12 +312,13 @@
> >
{{ $t('reportBug') }} {{ $t('reportBug') }}
</a> </a>
<router-link <a
class="topbar-dropdown-item dropdown-item" class="topbar-dropdown-item dropdown-item"
to="/groups/guild/5481ccf3-5d2d-48a9-a871-70a7380cee5a" target="_blank"
@click.prevent="openBugReportModal(true)"
> >
{{ $t('askQuestion') }} {{ $t('askQuestion') }}
</router-link> </a>
<a <a
class="topbar-dropdown-item dropdown-item" class="topbar-dropdown-item dropdown-item"
href="https://docs.google.com/forms/d/e/1FAIpQLScPhrwq_7P1C6PTrI3lbvTsvqGyTNnGzp1ugi1Ml0PFee_p5g/viewform?usp=sf_link" href="https://docs.google.com/forms/d/e/1FAIpQLScPhrwq_7P1C6PTrI3lbvTsvqGyTNnGzp1ugi1Ml0PFee_p5g/viewform?usp=sf_link"

View File

@@ -2,7 +2,8 @@ import { MODALS } from '@/libs/consts';
export default { export default {
methods: { methods: {
openBugReportModal () { openBugReportModal (questionMode = false) {
this.$store.state.bugReportOptions.question = questionMode;
this.$root.$emit('bv::show::modal', MODALS.BUG_REPORT); this.$root.$emit('bv::show::modal', MODALS.BUG_REPORT);
}, },
}, },

View File

@@ -148,6 +148,9 @@ export default function () {
egg: '', egg: '',
hatchingPotion: '', hatchingPotion: '',
}, },
bugReportOptions: {
question: false,
},
}, },
}); });

View File

@@ -216,5 +216,11 @@
"refreshList": "Refresh List", "refreshList": "Refresh List",
"leaveHabitica": "You are about to leave Habitica.com", "leaveHabitica": "You are about to leave Habitica.com",
"leaveHabiticaText": "Habitica is not responsible for the content of any linked website that is not owned or operated by HabitRPG.<br>Please note that these websites' practices may differ from Habiticas community guidelines.", "leaveHabiticaText": "Habitica is not responsible for the content of any linked website that is not owned or operated by HabitRPG.<br>Please note that these websites' practices may differ from Habiticas community guidelines.",
"skipExternalLinkModal": "Hold CTRL (Windows) or Command (Mac) when clicking a link to skip this modal." "skipExternalLinkModal": "Hold CTRL (Windows) or Command (Mac) when clicking a link to skip this modal.",
"askQuestionHeaderDescribe": "New to Habitica and don't know what you're doing? Veteran but just can't figure out how to use one of the features? Fill out this form and our team will get back to you.",
"questionEmailText": "This will only be used to contact you regarding your question.",
"question": "Question",
"questionDescriptionText": "It's okay to ask your questions in your primary language if you aren't comfortable speaking in English.",
"questionPlaceholder": "Ask your question here",
"submitQuestion": "Submit Question"
} }

View File

@@ -32,14 +32,14 @@ api.bugReport = {
const validationErrors = req.validationErrors(); const validationErrors = req.validationErrors();
if (validationErrors) throw validationErrors; if (validationErrors) throw validationErrors;
const { message, email } = req.body; const { message, email, question } = req.body;
const { user } = res.locals; const { user } = res.locals;
const BROWSER_UA = req.get('User-Agent'); const BROWSER_UA = req.get('User-Agent');
const { const {
emailData, sendMailResult, emailData, sendMailResult,
} = bugReportLogic( } = bugReportLogic(
user, email, message, BROWSER_UA, user, email, message, BROWSER_UA, question,
); );
res.status(200).send({ res.status(200).send({

View File

@@ -2,7 +2,7 @@ import nconf from 'nconf';
import { convertVariableObjectToArray, sendTxn } from './email'; import { convertVariableObjectToArray, sendTxn } from './email';
export async function bugReportLogic ( export async function bugReportLogic (
user, userEmail, message, BROWSER_UA, user, userEmail, message, BROWSER_UA, question,
) { ) {
const emailData = { const emailData = {
USER_ID: user._id, USER_ID: user._id,
@@ -28,7 +28,7 @@ export async function bugReportLogic (
const sendMailResult = await sendTxn( const sendMailResult = await sendTxn(
adminMail, adminMail,
'report-a-bug', question ? 'ask-a-question' : 'report-a-bug',
convertVariableObjectToArray(emailData), convertVariableObjectToArray(emailData),
); );