From 759e6d0987e488e2023d4616c5d7b4b650559dec Mon Sep 17 00:00:00 2001 From: Alexandro Uc Santos Date: Mon, 8 Apr 2024 20:44:58 -0600 Subject: [PATCH 1/5] add: view change password & email --- src/components/CardLocation.vue | 2 +- src/components/FormChangeEmail.vue | 114 ++++++++++++++++++++ src/components/FormChangePassword.vue | 144 ++++++++++++++++++++++++++ src/views/CarriersView.vue | 2 +- src/views/EditProfileView.vue | 41 +++++++- src/views/LoadsPublishedView.vue | 2 +- src/views/LocationsView.vue | 2 +- src/views/ShippersView.vue | 2 +- src/views/TrucksPublishedView.vue | 2 +- src/views/UsersView.vue | 2 +- src/views/VehiclesView.vue | 2 +- 11 files changed, 302 insertions(+), 13 deletions(-) create mode 100644 src/components/FormChangeEmail.vue create mode 100644 src/components/FormChangePassword.vue diff --git a/src/components/CardLocation.vue b/src/components/CardLocation.vue index dbda61b..4ad2d2a 100644 --- a/src/components/CardLocation.vue +++ b/src/components/CardLocation.vue @@ -1,7 +1,7 @@ + + + + \ No newline at end of file diff --git a/src/components/FormChangePassword.vue b/src/components/FormChangePassword.vue new file mode 100644 index 0000000..b542f0c --- /dev/null +++ b/src/components/FormChangePassword.vue @@ -0,0 +1,144 @@ + + + + + \ No newline at end of file diff --git a/src/views/CarriersView.vue b/src/views/CarriersView.vue index f2b3ec7..15bc52b 100644 --- a/src/views/CarriersView.vue +++ b/src/views/CarriersView.vue @@ -17,7 +17,7 @@ import Pagination from '../components/Pagination.vue'; const selectedCities = ref([]); const filterQuery = ref([]); - const limit = 5; + const limit = 10; onMounted(() => { filterQuery.value.company_type = 'carrier'; diff --git a/src/views/EditProfileView.vue b/src/views/EditProfileView.vue index d3f7ed2..60822d0 100644 --- a/src/views/EditProfileView.vue +++ b/src/views/EditProfileView.vue @@ -5,6 +5,8 @@ import CustomInput from '../components/ui/CustomInput.vue'; import { storeToRefs } from 'pinia'; import NotificationBadge from '../components/ui/NotificationBadge.vue'; + import FormChangePassword from '../components/FormChangePassword.vue'; +import FormChangeEmail from '../components/FormChangeEmail.vue'; const auth = useAuthStore(); @@ -13,6 +15,7 @@ const loading = ref(false) const msgError = ref(''); const msgSuccess = ref(''); + const form = ref(0); const userForm = reactive({ name: '', @@ -36,6 +39,7 @@ userForm.name = user.value?.first_name userForm.lastName = user.value?.last_name userForm.phone1 = user.value?.phone + } const handleSave = async() => { @@ -82,18 +86,38 @@ } } + const setForm = (val) => { + form.value = val + } + @@ -135,11 +161,16 @@ /* .profile { margin: 0 auto; } */ + .box-btns { display: flex; justify-content: flex-end; gap: 2rem; } + + .selection { + color: #333; + } .form-content { margin-top: 1rem; max-width: 768px; diff --git a/src/views/LoadsPublishedView.vue b/src/views/LoadsPublishedView.vue index 80ef112..aa6b5e2 100644 --- a/src/views/LoadsPublishedView.vue +++ b/src/views/LoadsPublishedView.vue @@ -13,7 +13,7 @@ const loading = ref(false); const query = ref(''); const filterQuery = ref([]); - const limit = 5; + const limit = 10; onMounted(() =>{ console.log('init') diff --git a/src/views/LocationsView.vue b/src/views/LocationsView.vue index 2c88636..9a7b40c 100644 --- a/src/views/LocationsView.vue +++ b/src/views/LocationsView.vue @@ -19,7 +19,7 @@ getInitData(); }) - const limit = 5; + const limit = 10; const getInitData = async() => { loading.value = true; diff --git a/src/views/ShippersView.vue b/src/views/ShippersView.vue index 0844908..73b55cd 100644 --- a/src/views/ShippersView.vue +++ b/src/views/ShippersView.vue @@ -17,7 +17,7 @@ const selectedCities = ref([]); const filterQuery = ref([]); - const limit = 5; + const limit = 10; onMounted(() => { filterQuery.value.company_type = 'shipper'; diff --git a/src/views/TrucksPublishedView.vue b/src/views/TrucksPublishedView.vue index ab26fe8..dccb251 100644 --- a/src/views/TrucksPublishedView.vue +++ b/src/views/TrucksPublishedView.vue @@ -12,7 +12,7 @@ const proposalCurrent = ref(null); const openModal = ref(false); const openModalProposal = ref(false); - const limit = 5; + const limit = 10; onMounted(() =>{ getInitData(); diff --git a/src/views/UsersView.vue b/src/views/UsersView.vue index 19a80aa..d1c5695 100644 --- a/src/views/UsersView.vue +++ b/src/views/UsersView.vue @@ -16,7 +16,7 @@ import { useAuthStore } from '../stores/auth'; const currentUser = ref(null); const openModal = ref(false); - const limit = 3; + const limit = 10; const getInitData = async() => { console.log('callll') diff --git a/src/views/VehiclesView.vue b/src/views/VehiclesView.vue index 38b737c..fd2fa50 100644 --- a/src/views/VehiclesView.vue +++ b/src/views/VehiclesView.vue @@ -21,7 +21,7 @@ const editStatusVehicle = ref(false); const editDriverVehicle = ref(false); - const limit = 3; + const limit = 10; onMounted(() => { getInitData(); From 9ea63bc1b20bed1ba8bc49d5cc29e8119531e2cb Mon Sep 17 00:00:00 2001 From: Alexandro Uc Santos Date: Tue, 9 Apr 2024 20:58:48 -0600 Subject: [PATCH 2/5] add: change password, done --- src/components/FormChangePassword.vue | 128 +++++++++++++++++++++++++- src/views/EditProfileView.vue | 2 +- 2 files changed, 125 insertions(+), 5 deletions(-) diff --git a/src/components/FormChangePassword.vue b/src/components/FormChangePassword.vue index b542f0c..55893f7 100644 --- a/src/components/FormChangePassword.vue +++ b/src/components/FormChangePassword.vue @@ -2,17 +2,30 @@ import {reactive, ref} from 'vue'; import CustomInput from './ui/CustomInput.vue'; import Spiner from './ui/Spiner.vue'; -import NotificationBadge from './ui/NotificationBadge.vue'; + import NotificationBadge from './ui/NotificationBadge.vue'; + import { recoveryPassword, recoveryPasswordConfirm, regiter } from '../services/auth'; + import { useAuthStore } from '../stores/auth'; + import { useRouter } from 'vue-router'; + import { useNotificationsStore } from '../stores/notifications'; + const pwdForm = reactive({ pwd: '', pwd2: '', + code: '', + checksum: '', }) + const step = ref(1); + + const auth = useAuthStore(); + const router = useRouter(); + const notifications = useNotificationsStore() + const loading = ref(false) const msgError = ref(''); const msgSuccess = ref(''); - const hangleSave = () => { + const hangleSave = async() => { msgError.value = ''; msgSuccess.value = ''; let resp = validations(); @@ -21,10 +34,88 @@ import NotificationBadge from './ui/NotificationBadge.vue'; clearMessages(); return; } else { - + loading.value = true; + msgError.value = ''; + const data = { + email: auth.user.email, + password: pwdForm.pwd + } + const result = await recoveryPassword(data); + if(result.msg === 'success' && result.data !== null) { + msgSuccess.value = 'Te enviamos un código al correo, ingresado!'; + pwdForm.checksum = result.data.checksum; + step.value = 2; + clearMessages(); + } else { + msgError.value = result.msg; + clearMessages(); + } + loading.value = false; } } + const handleConfirmChange = async() => { + msgError.value = ''; + msgSuccess.value = ''; + if(pwdForm.code.length < 6) { + msgError.value = 'Ingresa código valido'; + clearMessages(); + return; + } else { + loading.value = true; + msgError.value = ''; + const data = { + email: auth.user.email, + password: pwdForm.pwd, + otp: pwdForm.code, + checksum: pwdForm.checksum + } + const result = await recoveryPasswordConfirm(data); + // console.log(result); + if(result.msg === 'success' && result.data !== null){ + Object.assign(pwdForm, { + pwd: '', + retryPwd: '', + code: '', + checksum: '', + }); + clearMessages(); + notifications.$patch({ + text : 'Contraseña se ha cambiando exitosamente!', + show : true, + error: false + }); + router.push({name: 'login'}); + } else { + msgError.value = result.msg; + clearMessages() + } + loading.value = false; + } + } + + const resendCode = async() => { + // loading.value = true; + // const data = { + // email: pwdForm.email, + // password: pwdForm.pwd + // } + // const result = await regiter(data); + // if(result.msg === 'success' && result.data !== null) { + // msgSuccess.value = 'Te enviamos un código al correo, ingresado!'; + // checksum.value = result.data.checksum; + // clearMessages(); + // } else { + // msgError.value = result.msg; + // clearMessages(); + // } + // loading.value = false; + } + + const handleBack = (val) => { + step.value = val; + } + const validations = () => { const pass = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[a-zA-Z]).{8,}$/; @@ -51,6 +142,7 @@ import NotificationBadge from './ui/NotificationBadge.vue'; autocomplete="off" method="post" ref="formRef1" + v-if="step === 1" >

Cambiar contraseña

@@ -81,7 +173,35 @@ import NotificationBadge from './ui/NotificationBadge.vue'; + class="btn btn-dark btn-block" type="submit">Continuar + + +
+
+ Volver +
+ + +

Te enviamos un código de verificación al correo electrónico, ingresalo para confirmar la recuperacion de contraseña. No olvides revisar en la carpeta spam

+ + +
+ +
diff --git a/src/views/EditProfileView.vue b/src/views/EditProfileView.vue index 60822d0..ca04cdd 100644 --- a/src/views/EditProfileView.vue +++ b/src/views/EditProfileView.vue @@ -6,7 +6,7 @@ import { storeToRefs } from 'pinia'; import NotificationBadge from '../components/ui/NotificationBadge.vue'; import FormChangePassword from '../components/FormChangePassword.vue'; -import FormChangeEmail from '../components/FormChangeEmail.vue'; + import FormChangeEmail from '../components/FormChangeEmail.vue'; const auth = useAuthStore(); From f026e568f6a6a2576239810b128ef78dc8b5cad6 Mon Sep 17 00:00:00 2001 From: Alexandro Uc Santos Date: Fri, 12 Apr 2024 20:01:26 -0600 Subject: [PATCH 3/5] add: validations in change email form --- src/components/CardCompany.vue | 9 ---- src/components/CardUser.vue | 6 +-- src/components/CreateLocationModal.vue | 21 ++++++++- src/components/CreateUserModal.vue | 64 +++++++------------------- src/components/FormChangeEmail.vue | 60 +++++++++++++++++++++++- 5 files changed, 99 insertions(+), 61 deletions(-) diff --git a/src/components/CardCompany.vue b/src/components/CardCompany.vue index 0b7173d..823c35e 100644 --- a/src/components/CardCompany.vue +++ b/src/components/CardCompany.vue @@ -9,15 +9,6 @@ } }); - - /* - - Ocultar el RFC y Afilizaicon de la empresa y en todos lados, incluso en la aplicación - - Editar ocultar el form de ubicicacion - - Form de directorio agregar un campo para tipo de ubicacion - - Agregar otro page para cambiar el correo y contraseña - - Quitar telefono 2, segmento y tipo de transporte en usuarios form - - Se va a cambiar el endpint para obtener las ubicaciones de usuarios form, vehiculo - */