Fixes: 1) Replace `ElNotification` with `useNotification` across all components and composables; 2) Add missing semicolons, consistent formatting, and type annotations in multiple files; 3) Resolve non-reactive elements in wishlist and cart state management; Extra: 1) Update i18n translations with new strings for promocodes, balance, authentication, and profile settings; 2) Refactor SCSS styles including variable additions and component-specific tweaks; 3) Remove redundant queries, unused imports, and `storePage.ts` file for cleanup.
115 lines
No EOL
2.6 KiB
Vue
115 lines
No EOL
2.6 KiB
Vue
<template>
|
|
<form class="form" @submit.prevent="handleUpdate">
|
|
<div class="form__box">
|
|
<ui-input
|
|
:type="'text'"
|
|
:placeholder="t('fields.firstName')"
|
|
:rules="[required]"
|
|
v-model="firstName"
|
|
/>
|
|
<ui-input
|
|
:type="'text'"
|
|
:placeholder="t('fields.lastName')"
|
|
:rules="[required]"
|
|
v-model="lastName"
|
|
/>
|
|
</div>
|
|
<div class="form__box">
|
|
<ui-input
|
|
:type="'email'"
|
|
:placeholder="t('fields.email')"
|
|
:rules="[isEmail]"
|
|
v-model="email"
|
|
/>
|
|
<ui-input
|
|
:type="'text'"
|
|
:placeholder="t('fields.phoneNumber')"
|
|
:rules="[required]"
|
|
v-model="phoneNumber"
|
|
/>
|
|
</div>
|
|
<div class="form__box">
|
|
<ui-input
|
|
:type="'password'"
|
|
:placeholder="t('fields.newPassword')"
|
|
:rules="[isPasswordValid]"
|
|
v-model="password"
|
|
/>
|
|
<ui-input
|
|
:type="'password'"
|
|
:placeholder="t('fields.confirmNewPassword')"
|
|
:rules="[compareStrings]"
|
|
v-model="confirmPassword"
|
|
/>
|
|
</div>
|
|
<ui-button
|
|
class="form__button"
|
|
:isLoading="loading"
|
|
>
|
|
{{ t('buttons.save') }}
|
|
</ui-button>
|
|
</form>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import {useValidators} from "~/composables/rules";
|
|
import {useUserUpdating} from "~/composables/user/index.js";
|
|
|
|
const { t } = useI18n();
|
|
const userStore = useUserStore();
|
|
|
|
const { required, isEmail, isPasswordValid } = useValidators();
|
|
|
|
const user = computed(() => userStore.user);
|
|
|
|
const firstName = ref<string>('');
|
|
const lastName = ref<string>('');
|
|
const email = ref<string>('');
|
|
const phoneNumber = ref<string>('');
|
|
const password = ref<string>('');
|
|
const confirmPassword = ref<string>('');
|
|
|
|
const compareStrings = (v: string) => {
|
|
if (v === password.value) return true;
|
|
return t('errors.compare');
|
|
};
|
|
|
|
const { updateUser, loading } = useUserUpdating();
|
|
|
|
watchEffect(() => {
|
|
firstName.value = user.value?.firstName || '';
|
|
lastName.value = user.value?.lastName || '';
|
|
email.value = user.value?.email || '';
|
|
phoneNumber.value = user.value?.phoneNumber || '';
|
|
});
|
|
|
|
async function handleUpdate() {
|
|
await updateUser(
|
|
firstName.value,
|
|
lastName.value,
|
|
email.value,
|
|
phoneNumber.value,
|
|
password.value,
|
|
confirmPassword.value,
|
|
);
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.form {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 20px;
|
|
|
|
&__box {
|
|
display: flex;
|
|
align-items: flex-start;
|
|
gap: 20px;
|
|
}
|
|
|
|
&__button {
|
|
width: fit-content;
|
|
padding-inline: 20px;
|
|
}
|
|
}
|
|
</style> |