diff --git a/src/components/common/VnInput.vue b/src/components/common/VnInput.vue index 6144f975d..c84a55122 100644 --- a/src/components/common/VnInput.vue +++ b/src/components/common/VnInput.vue @@ -13,6 +13,10 @@ const $props = defineProps({ type: Boolean, default: false, }, + info: { + type: String, + default: '', + }, }); const { t } = useI18n(); @@ -83,6 +87,11 @@ const inputRules = [ v-if="hover && value && !$attrs.disabled" @click="value = null" > + + + {{ info }} + + diff --git a/src/pages/Worker/Card/WorkerChangePasswordForm.vue b/src/pages/Worker/Card/WorkerChangePasswordForm.vue new file mode 100644 index 000000000..ef75ba55a --- /dev/null +++ b/src/pages/Worker/Card/WorkerChangePasswordForm.vue @@ -0,0 +1,99 @@ + + + + + +es: + Reset password: Restablecer contraseña + New password: Nueva contraseña + Repeat password: Repetir contraseña + You must enter a new password: Debes introducir la nueva contraseña + Passwords don't match: Las contraseñas no coinciden + diff --git a/src/pages/Worker/Card/WorkerDescriptor.vue b/src/pages/Worker/Card/WorkerDescriptor.vue index daa290ea1..86c846aca 100644 --- a/src/pages/Worker/Card/WorkerDescriptor.vue +++ b/src/pages/Worker/Card/WorkerDescriptor.vue @@ -6,8 +6,10 @@ import { useSession } from 'src/composables/useSession'; import CardDescriptor from 'src/components/ui/CardDescriptor.vue'; import VnLv from 'src/components/ui/VnLv.vue'; import VnLinkPhone from 'src/components/ui/VnLinkPhone.vue'; +import WorkerChangePasswordForm from 'src/pages/Worker/Card/WorkerChangePasswordForm.vue'; import useCardDescription from 'src/composables/useCardDescription'; import { useState } from 'src/composables/useState'; +import axios from 'axios'; const $props = defineProps({ id: { @@ -25,12 +27,16 @@ const route = useRoute(); const { t } = useI18n(); const { getTokenMultimedia } = useSession(); const state = useState(); +const user = state.getUser(); +const changePasswordFormDialog = ref(null); +const cardDescriptorRef = ref(null); const entityId = computed(() => { return $props.id || route.params.id; }); const worker = ref(); +const workerExcluded = ref(false); const filter = { include: [ { @@ -71,14 +77,44 @@ function getWorkerAvatar() { const token = getTokenMultimedia(); return `/api/Images/user/160x160/${entityId.value}/download?access_token=${token}`; } + const data = ref(useCardDescription()); const setData = (entity) => { if (!entity) return; data.value = useCardDescription(entity.user.nickname, entity.id); }; + +const openChangePasswordForm = () => changePasswordFormDialog.value.show(); + +const getIsExcluded = async () => { + try { + const { data } = await axios.get( + `WorkerDisableExcludeds/${entityId.value}/exists` + ); + if (!data) return; + workerExcluded.value = data.exists; + } catch (err) { + console.error('Error getting worker excluded: ', err); + } +}; + +const handleExcluded = async () => { + if (workerExcluded.value) + await axios.delete(`WorkerDisableExcludeds/${entityId.value}`); + else + await axios.post(`WorkerDisableExcludeds`, { + workerFk: entityId.value, + dated: new Date(), + }); + + workerExcluded.value = !workerExcluded.value; +}; + +const refetch = async () => await cardDescriptorRef.value.getData();