add: delete load
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import { getStatusPublished } from '../helpers/status';
|
||||
import { getStatusLoad } from '../helpers/status';
|
||||
import { useLoadsStore } from '../stores/loads';
|
||||
import Swal from 'sweetalert2'
|
||||
|
||||
const loadsStore = useLoadsStore();
|
||||
|
||||
@@ -11,13 +12,55 @@
|
||||
type: Object,
|
||||
required: true,
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
|
||||
const openAttachmentsModal = () => {
|
||||
loadsStore.currentLoad = props.load;
|
||||
loadsStore.openAttachmentsModal = true;
|
||||
}
|
||||
|
||||
const handleDeleteLoad = async() => {
|
||||
Swal.fire({
|
||||
title: 'Eliminar carga!',
|
||||
text: '¿Estás seguro de eliminar esta carga?',
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: 'Eliminar',
|
||||
cancelButtonText: 'Cancelar',
|
||||
}).then(async(result) => {
|
||||
if(result.isConfirmed) {
|
||||
Swal.fire({
|
||||
title: 'Por favor espere!',
|
||||
html: 'Eliminando carga...',// add html attribute if you want or remove
|
||||
allowOutsideClick: false,
|
||||
didOpen: () => {
|
||||
Swal.showLoading()
|
||||
},
|
||||
});
|
||||
const resp = await loadsStore.deleteLoad(props.load._id);
|
||||
if(resp != null) {
|
||||
loadsStore.loads = loadsStore.loads.filter(load => load._id !== props.load._id);
|
||||
Swal.fire({
|
||||
title: "Carga eliminada!",
|
||||
text: "Tu carga ha sido eliminada exitosamente.",
|
||||
icon: "success"
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
title: "No eliminado!",
|
||||
text: "Tu carga no se pudo eliminar, intente más tarde.",
|
||||
icon: "error"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
const openEditModal = () => {
|
||||
loadsStore.currentLoad = props.load
|
||||
loadsStore.openModalEdit = true;
|
||||
@@ -74,7 +117,7 @@
|
||||
<div class="btn-row">
|
||||
<button
|
||||
class="btn-primary-sm bg-dark"
|
||||
data-toggle="modal" data-target="#editcompanymodal"
|
||||
@click="handleDeleteLoad"
|
||||
><i class="fa-solid fa-ban clear-sm"></i> Cancelar</button>
|
||||
<button v-if="load.status !== 'Draft' && load.load_status !== 'Published' && load.load_status !== 'Loading'"
|
||||
type="button"
|
||||
@@ -86,11 +129,13 @@
|
||||
Evidencias
|
||||
</button>
|
||||
<button
|
||||
v-if="load.load_status !== 'Delivered'"
|
||||
class="btn-primary-sm"
|
||||
data-toggle="modal" data-target="#formLoadModal"
|
||||
@click="openEditModal"
|
||||
><i class="fa-solid fa-pen-to-square clear-sm"></i> Editar carga</button>
|
||||
<button
|
||||
v-if="load.status !== 'Draft'"
|
||||
class="btn-primary-sm"
|
||||
@click="openProposalsModal"
|
||||
data-toggle="modal"
|
||||
|
||||
Reference in New Issue
Block a user