diff --git a/src/components/CustomSwitch.vue b/src/components/CustomSwitch.vue index 3c2e9c3..6409ffd 100644 --- a/src/components/CustomSwitch.vue +++ b/src/components/CustomSwitch.vue @@ -27,7 +27,7 @@ const toggle = (event) => { - {{ label }} + {{ label }} { \ No newline at end of file diff --git a/src/components/NavBar.vue b/src/layouts/components/NavBar.vue similarity index 92% rename from src/components/NavBar.vue rename to src/layouts/components/NavBar.vue index 8c9a6b8..fe10b15 100644 --- a/src/components/NavBar.vue +++ b/src/layouts/components/NavBar.vue @@ -1,10 +1,10 @@ @@ -41,7 +43,7 @@ diff --git a/src/views/contacts/components/ContactCard.vue b/src/views/contacts/components/ContactCard.vue index 15d48c8..e83bb5a 100644 --- a/src/views/contacts/components/ContactCard.vue +++ b/src/views/contacts/components/ContactCard.vue @@ -2,7 +2,8 @@ import { useI18n } from 'vue-i18n'; import { useAuthStore } from '../../../stores/auth'; import Swal from 'sweetalert2'; -import { useContactsStore } from '../../../stores/contacts'; +import { usePrivacyStore } from '../../../stores/privacy'; +import { computed } from 'vue'; const props = defineProps({ @@ -14,7 +15,7 @@ import { useContactsStore } from '../../../stores/contacts'; const { t } = useI18n(); const authStore = useAuthStore(); - const contactsStore = useContactsStore(); + const contactsStore = usePrivacyStore(); const handleDeleteContact = async() => { Swal.fire({ @@ -60,13 +61,23 @@ import { useContactsStore } from '../../../stores/contacts'; } + const categories = computed(() => (props.contact.categories) + ? props.contact.categories.map((e) => e.name).join(', ') + : '' + ) + + const truckTypes = computed(() => (props.contact.truck_type) + ? props.contact.truck_type.join(', ') + : '' + ) + - {{ contact.company }} + {{ contact.company_name }} RFC: {{ contact.rfc}} - {{ t('global.segments') }}: {{contact.category}} - {{ t('directory.typeTruckNeed') }}: Torton + {{ t('global.segments') }}: {{ categories }} + {{ t('directory.typeTruckNeed') }}: {{ truckTypes }} diff --git a/src/views/searchs/components/CardCompany.vue b/src/views/searchs/components/CardCompany.vue index 3752992..6ff075a 100644 --- a/src/views/searchs/components/CardCompany.vue +++ b/src/views/searchs/components/CardCompany.vue @@ -3,20 +3,27 @@ import { getDateMonthDay } from '../../../helpers/date_formats'; import { useI18n } from 'vue-i18n'; import Swal from 'sweetalert2'; - import { ref } from 'vue'; + import { onMounted, ref } from 'vue'; import { useAuthStore } from '../../../stores/auth'; + import { usePrivacyStore } from '../../../stores/privacy'; - defineProps({ + const props = defineProps({ company: { type: Object, required: true, } }); - + const authStore = useAuthStore(); - let existInPrivateList = ref(false); + const privacyStore = usePrivacyStore(); + const existInPrivateList = ref(false); - const handleAddPrivateList = async() => { + onMounted(() => { + const id = props.company._id; + existInPrivateList.value = privacyStore.privateListRef.includes(id); + }) + + const handleAddPrivateList = async() => { Swal.fire({ title: 'Lista privadad', text: '¿Estas seguro de añadir a este transportista de la lista privada?', @@ -34,26 +41,22 @@ Swal.showLoading() }, }); - let resp = null; - setTimeout(() => { - resp = true - Swal.close(); - if(resp != null) { - // contactsStore.removeContact(id); - existInPrivateList.value = true; - Swal.fire({ - title: 'Transportista añadido', - text: 'Se ha añadido este transportista a la lista privada', - icon: "success" - }); - } else { - Swal.fire({ - title: t('errors.msgTitleNotDel'), - text: 'No se pudo completar la añadir este transportista a la lista privada', - icon: "error" - }); - } - }, 500); + const response = await privacyStore.addCompanyToPrivateList(props.company._id); + Swal.close(); + if(response === 'success') { + existInPrivateList.value = true; + Swal.fire({ + title: 'Transportista añadido', + text: 'Se ha añadido este transportista a la lista privada', + icon: "success" + }); + } else { + Swal.fire({ + title: 'Error', + text: response, + icon: "error" + }); + } } });
RFC: {{ contact.rfc}}
{{ t('global.segments') }}: {{contact.category}}
{{ t('directory.typeTruckNeed') }}: Torton
{{ t('global.segments') }}: {{ categories }}
{{ t('directory.typeTruckNeed') }}: {{ truckTypes }}