2020-01-09 07:36:40 +00:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<form
|
|
|
|
v-if="!hasSubmitted"
|
|
|
|
class="email-input-group"
|
2021-11-18 09:48:51 +00:00
|
|
|
@submit.prevent="onSubmit"
|
2020-01-09 07:36:40 +00:00
|
|
|
>
|
|
|
|
<input
|
|
|
|
v-model.trim="email"
|
2020-05-03 09:15:33 +00:00
|
|
|
class="form-input"
|
2020-05-06 08:08:36 +00:00
|
|
|
:placeholder="$t('EMAIL_PLACEHOLDER')"
|
2020-01-09 07:36:40 +00:00
|
|
|
:class="{ error: $v.email.$error }"
|
|
|
|
@input="$v.email.$touch"
|
2021-12-20 03:18:09 +00:00
|
|
|
@keydown.enter="onSubmit"
|
2020-01-09 07:36:40 +00:00
|
|
|
/>
|
|
|
|
<button
|
2021-11-18 09:48:51 +00:00
|
|
|
class="button small"
|
2020-01-09 07:36:40 +00:00
|
|
|
:disabled="$v.email.$invalid"
|
|
|
|
:style="{ background: widgetColor, borderColor: widgetColor }"
|
|
|
|
>
|
2021-11-18 09:48:51 +00:00
|
|
|
<fluent-icon v-if="!isUpdating" icon="chevron-right" />
|
|
|
|
<spinner v-else class="mx-2" />
|
2020-01-09 07:36:40 +00:00
|
|
|
</button>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { mapGetters } from 'vuex';
|
|
|
|
import { required, email } from 'vuelidate/lib/validators';
|
|
|
|
|
2021-11-18 09:48:51 +00:00
|
|
|
import FluentIcon from 'shared/components/FluentIcon/Index.vue';
|
|
|
|
import Spinner from 'shared/components/Spinner';
|
|
|
|
|
2020-01-09 07:36:40 +00:00
|
|
|
export default {
|
|
|
|
components: {
|
2021-11-18 09:48:51 +00:00
|
|
|
FluentIcon,
|
2020-01-09 07:36:40 +00:00
|
|
|
Spinner,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
messageId: {
|
|
|
|
type: Number,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
messageContentAttributes: {
|
|
|
|
type: Object,
|
|
|
|
default: () => {},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
email: '',
|
2021-07-07 05:54:08 +00:00
|
|
|
isUpdating: false,
|
2020-01-09 07:36:40 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapGetters({
|
|
|
|
widgetColor: 'appConfig/getWidgetColor',
|
|
|
|
}),
|
|
|
|
hasSubmitted() {
|
|
|
|
return (
|
|
|
|
this.messageContentAttributes &&
|
|
|
|
this.messageContentAttributes.submitted_email
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
validations: {
|
|
|
|
email: {
|
|
|
|
required,
|
|
|
|
email,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
2021-07-07 05:54:08 +00:00
|
|
|
async onSubmit() {
|
2020-05-03 09:15:33 +00:00
|
|
|
if (this.$v.$invalid) {
|
|
|
|
return;
|
|
|
|
}
|
2021-07-07 05:54:08 +00:00
|
|
|
this.isUpdating = true;
|
|
|
|
try {
|
|
|
|
await this.$store.dispatch('message/update', {
|
|
|
|
email: this.email,
|
|
|
|
messageId: this.messageId,
|
|
|
|
});
|
|
|
|
} catch (error) {
|
|
|
|
// Ignore error
|
|
|
|
} finally {
|
|
|
|
this.isUpdating = false;
|
|
|
|
}
|
2020-01-09 07:36:40 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
@import '~widget/assets/scss/variables.scss';
|
|
|
|
|
|
|
|
.email-input-group {
|
|
|
|
display: flex;
|
|
|
|
margin: $space-small 0;
|
|
|
|
min-width: 200px;
|
|
|
|
|
|
|
|
input {
|
|
|
|
border-bottom-right-radius: 0;
|
2020-05-03 09:15:33 +00:00
|
|
|
border-top-right-radius: 0;
|
|
|
|
padding: $space-one;
|
2020-07-06 12:44:19 +00:00
|
|
|
width: auto;
|
2020-01-09 07:36:40 +00:00
|
|
|
|
|
|
|
&.error {
|
|
|
|
border-color: $color-error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.button {
|
|
|
|
border-bottom-left-radius: 0;
|
|
|
|
border-top-left-radius: 0;
|
|
|
|
font-size: $font-size-large;
|
|
|
|
height: auto;
|
|
|
|
margin-left: -1px;
|
|
|
|
|
|
|
|
.spinner {
|
|
|
|
display: block;
|
|
|
|
padding: 0;
|
|
|
|
height: auto;
|
|
|
|
width: auto;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|