diff --git a/src/components/CardCompany.vue b/src/components/CardCompany.vue new file mode 100644 index 0000000..c16f057 --- /dev/null +++ b/src/components/CardCompany.vue @@ -0,0 +1,77 @@ + + + + + \ No newline at end of file diff --git a/src/components/ui/EditCompanyModal.vue b/src/components/ui/EditCompanyModal.vue index 666cd03..c7237b9 100644 --- a/src/components/ui/EditCompanyModal.vue +++ b/src/components/ui/EditCompanyModal.vue @@ -8,8 +8,10 @@ import TruckTypes from './TruckTypes.vue'; import Custominput from './custominput.vue'; import { useCompanyStore } from '../../stores/company'; + import { useNotificationsStore } from '../../stores/notifications'; const companyStore = useCompanyStore() + const notifications = useNotificationsStore() console.log(companyStore.company?.categories); @@ -45,14 +47,6 @@ } }) const company = reactive({ - typeCompany: '', - // segments: [{ - // createdAt: "2022-08-25T05:14:35.906Z", - // name:"AGRICOLA", - // updatedAt: "2022-08-25T05:16:35.603Z", - // __v: 0, - // _id: "6307053bbf4a7b12a4dca8c9" - // }], segments: companyCategories, states: companyStates, cities: companyCity, @@ -61,7 +55,38 @@ }); const handleSave = () => { + // const resp = editCompany() + const resp = validations(); + if(resp !== '') { + msgError.value = resp; + clearMessages(); + } else { + // $('#editcompanymodal').modal('toggle'); + document.getElementById('btnCloseEditCompany').click(); + notifications.show = true; + notifications.text = 'Empresa actualizada'; + } + } + const clearMessages = () => { + setTimeout(() => { + msgError.value = ''; + }, 3000); + } + + const validations = () => { + if(company.segments.length === 0) { + return 'Agregue al menos un segmento'; + }else if(company.states.length === 0) { + return 'Agregue al menos un estado'; + } else if( company.cities.length === 0) { + msgError.value = 'Agregue al menos una ciudad'; + } else if(company.truckTypes.length === 0){ + msgError.value = 'Agregue al menos un tipo de camión'; + } else { + return ''; + } + } @@ -72,7 +97,7 @@