# Pull Request Template ## Description This PR adds new eslint rules to the code base. **Error rules** | Rule name | Type | Files updated | | ----------------- | --- | - | | `vue/block-order` | error | ✅ | | `vue/component-name-in-template-casing` | error | ✅ | | `vue/component-options-name-casing` | error | ✅ | | `vue/custom-event-name-casing` | error | ✅ | | `vue/define-emits-declaration` | error | ✅ | | `vue/no-unused-properties` | error | ✅ | | `vue/define-macros-order` | error | ✅ | | `vue/define-props-declaration` | error | ✅ | | `vue/match-component-import-name` | error | ✅ | | `vue/next-tick-style` | error | ✅ | | `vue/no-bare-strings-in-template` | error | ✅ | | `vue/no-empty-component-block` | error | ✅ | | `vue/no-multiple-objects-in-class` | error | ✅ | | `vue/no-required-prop-with-default` | error | ✅ | | `vue/no-static-inline-styles` | error | ✅ | | `vue/no-template-target-blank` | error | ✅ | | `vue/no-this-in-before-route-enter` | error | ✅ | | `vue/no-undef-components` | error | ✅ | | `vue/no-unused-emit-declarations` | error | ✅ | | `vue/no-unused-refs` | error | ✅ | | `vue/no-use-v-else-with-v-for` | error | ✅ | | `vue/no-useless-v-bind` | error | ✅ | | `vue/no-v-text` | error | ✅ | | `vue/padding-line-between-blocks` | error | ✅ | | ~`vue/prefer-prop-type-boolean-first`~ | ~error~ | ❌ (removed this rule, cause a bug in displaying custom attributes) | | `vue/prefer-separate-static-class` | error | ✅ | | `vue/prefer-true-attribute-shorthand` | error | ✅ | | `vue/require-explicit-slots` | error | ✅ | | `vue/require-macro-variable-name` | error | ✅ | **Warn rules** | Rule name | Type | Files updated | | ---- | ------------- | ------------- | | `vue/no-root-v-if` | warn | ❎ | Fixes https://linear.app/chatwoot/issue/CW-3492/vue-eslint-rules ## Type of change - [x] New feature (non-breaking change which adds functionality) ## Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my code - [x] I have commented on my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules --------- Co-authored-by: Fayaz Ahmed <fayazara@gmail.com> Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com> Co-authored-by: Shivam Mishra <scm.mymail@gmail.com> Co-authored-by: Pranav <pranav@chatwoot.com>
136 lines
3.8 KiB
Vue
136 lines
3.8 KiB
Vue
<script>
|
|
import { useVuelidate } from '@vuelidate/core';
|
|
import { required, minLength } from '@vuelidate/validators';
|
|
import { useAlert } from 'dashboard/composables';
|
|
import FormInput from '../../../components/Form/Input.vue';
|
|
import SubmitButton from '../../../components/Button/SubmitButton.vue';
|
|
import { DEFAULT_REDIRECT_URL } from 'dashboard/constants/globals';
|
|
import { setNewPassword } from '../../../api/auth';
|
|
|
|
export default {
|
|
components: {
|
|
FormInput,
|
|
SubmitButton,
|
|
},
|
|
props: {
|
|
resetPasswordToken: { type: String, default: '' },
|
|
},
|
|
setup() {
|
|
return { v$: useVuelidate() };
|
|
},
|
|
data() {
|
|
return {
|
|
// We need to initialize the component with any
|
|
// properties that will be used in it
|
|
credentials: {
|
|
confirmPassword: '',
|
|
password: '',
|
|
},
|
|
newPasswordAPI: {
|
|
message: '',
|
|
showLoading: false,
|
|
},
|
|
error: '',
|
|
};
|
|
},
|
|
mounted() {
|
|
// If url opened without token
|
|
// redirect to login
|
|
if (!this.resetPasswordToken) {
|
|
window.location = DEFAULT_REDIRECT_URL;
|
|
}
|
|
},
|
|
validations: {
|
|
credentials: {
|
|
password: {
|
|
required,
|
|
minLength: minLength(6),
|
|
},
|
|
confirmPassword: {
|
|
required,
|
|
minLength: minLength(6),
|
|
isEqPassword(value) {
|
|
if (value !== this.credentials.password) {
|
|
return false;
|
|
}
|
|
return true;
|
|
},
|
|
},
|
|
},
|
|
},
|
|
methods: {
|
|
showAlertMessage(message) {
|
|
// Reset loading, current selected agent
|
|
this.newPasswordAPI.showLoading = false;
|
|
useAlert(message);
|
|
},
|
|
submitForm() {
|
|
this.newPasswordAPI.showLoading = true;
|
|
const credentials = {
|
|
confirmPassword: this.credentials.confirmPassword,
|
|
password: this.credentials.password,
|
|
resetPasswordToken: this.resetPasswordToken,
|
|
};
|
|
setNewPassword(credentials)
|
|
.then(() => {
|
|
window.location = DEFAULT_REDIRECT_URL;
|
|
})
|
|
.catch(error => {
|
|
this.showAlertMessage(
|
|
error?.message || this.$t('SET_NEW_PASSWORD.API.ERROR_MESSAGE')
|
|
);
|
|
});
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<template>
|
|
<div
|
|
class="flex flex-col justify-center w-full min-h-full py-12 bg-woot-25 sm:px-6 lg:px-8 dark:bg-slate-900"
|
|
>
|
|
<form
|
|
class="bg-white shadow sm:mx-auto sm:w-full sm:max-w-lg dark:bg-slate-800 p-11 sm:shadow-lg sm:rounded-lg"
|
|
@submit.prevent="submitForm"
|
|
>
|
|
<h1
|
|
class="mb-1 text-2xl font-medium tracking-tight text-left text-slate-900 dark:text-white"
|
|
>
|
|
{{ $t('SET_NEW_PASSWORD.TITLE') }}
|
|
</h1>
|
|
|
|
<div class="space-y-5">
|
|
<FormInput
|
|
v-model.trim="credentials.password"
|
|
class="mt-3"
|
|
name="password"
|
|
type="password"
|
|
:has-error="v$.credentials.password.$error"
|
|
:error-message="$t('SET_NEW_PASSWORD.PASSWORD.ERROR')"
|
|
:placeholder="$t('SET_NEW_PASSWORD.PASSWORD.PLACEHOLDER')"
|
|
@blur="v$.credentials.password.$touch"
|
|
/>
|
|
<FormInput
|
|
v-model.trim="credentials.confirmPassword"
|
|
class="mt-3"
|
|
name="confirm_password"
|
|
type="password"
|
|
:has-error="v$.credentials.confirmPassword.$error"
|
|
:error-message="$t('SET_NEW_PASSWORD.CONFIRM_PASSWORD.ERROR')"
|
|
:placeholder="$t('SET_NEW_PASSWORD.CONFIRM_PASSWORD.PLACEHOLDER')"
|
|
@blur="v$.credentials.confirmPassword.$touch"
|
|
/>
|
|
<SubmitButton
|
|
:disabled="
|
|
v$.credentials.password.$invalid ||
|
|
v$.credentials.confirmPassword.$invalid ||
|
|
newPasswordAPI.showLoading
|
|
"
|
|
:button-text="$t('SET_NEW_PASSWORD.SUBMIT')"
|
|
:loading="newPasswordAPI.showLoading"
|
|
/>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</template>
|