add: services
This commit is contained in:
@@ -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"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user