diff --git a/src/assets/main.css b/src/assets/main.css index 27bb00e..634ea55 100644 --- a/src/assets/main.css +++ b/src/assets/main.css @@ -231,6 +231,47 @@ td { border: 1px solid #FBBA33 !important; } +.box-observers { + display: flex; + flex-direction: column; +} +.box-input { + display: flex; + flex-direction: row; + gap: 1rem; + align-items: center; +} +.input-observer { + flex: 1; +} +.box-emails { + display: flex; + flex-direction: row; + flex-wrap: wrap; + gap: 0.5rem; + margin-top: 1rem; + border-radius: 5px; + padding: 0.5rem; + background-color: #FFF; + border: 1px solid #ccc; +} +.observer-email { + display: flex; + align-items: center; + background-color: #e0f7fa; + padding: 0.5rem; + border-radius: 5px; + margin-right: 0.5rem; + margin-bottom: 0.5rem; +} +.icon-delete { + cursor: pointer; + color: #FF0000; + font-size: 1.5rem; + margin-left: 0.5rem; + transition: color 0.3s; +} + @media (max-width: 1024px) { th { font-size: 13px; diff --git a/src/components/CreateLocationModal.vue b/src/components/CreateLocationModal.vue index 0726f10..4d7c644 100644 --- a/src/components/CreateLocationModal.vue +++ b/src/components/CreateLocationModal.vue @@ -10,6 +10,7 @@ import { useCompanyStore } from '../stores/company'; import Swal from 'sweetalert2'; import { useI18n } from 'vue-i18n'; + import { validateEmail } from '../helpers/validations'; const props = defineProps({ location: { @@ -27,6 +28,8 @@ const { t } = useI18n() const loading = ref(false); + const emails = ref([]); + const emailInput = ref(''); const title = computed(() => { return (props.location) ? t('directory.editLocation') : t('directory.createLocation'); @@ -139,6 +142,33 @@ } } + const addObserver = () => { + const trimmedEmail = emailInput.value.trim() + + if (trimmedEmail && validateEmail(trimmedEmail)) { + if(emails.value.includes(trimmedEmail)) { + Swal.fire({ + title: t('errors.emailExist'), + icon: 'error' + }) + return + } + emails.value.push(trimmedEmail) + emailInput.value = '' + } else if (trimmedEmail) { + Swal.fire({ + title: t('errors.email'), + icon: 'error' + }) + } + } + + const removeObserver = (email) => { + emails.value = emails.value.filter((e) => e !== email) + } + + + const validations = () => { errors.value = { branch_name: locationForm.branch_name.length < 2 ? t('errors.nameRequired') : null, @@ -251,6 +281,42 @@ v-model="locationForm.description" > +
+