You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
196 lines
5.3 KiB
196 lines
5.3 KiB
<template>
|
|
<modal >
|
|
<div class="tw-p-[40px]">
|
|
<div
|
|
class="modal-header tw-flex tw-justify-left tw-items-center tw-mb-[40px] md:tw-mb-[40px] xl:tw-justify-between">
|
|
<div class="tw-text-[20px] tw-font-bold tw-leading-[26px]">
|
|
{{ $t("Add Contact Info") }}
|
|
</div>
|
|
<button class="close tw-transition tw-btn-md" @click="$modal.hide('add-contact-modal')"></button>
|
|
</div>
|
|
|
|
<div class="modal-content tw-grid tw-grid-cols-1 tw-gap-y-[20px] md:tw-grid-cols-2 md:tw-gap-x-[60px]">
|
|
<div class="element">
|
|
<elementInput :input="{
|
|
id: 'FirstName',
|
|
label: 'First name',
|
|
required: true,
|
|
type: 'text',
|
|
}"
|
|
@change="formData.first_name = $event"></elementInput>
|
|
</div>
|
|
<div class="element">
|
|
<elementInput :input="{
|
|
id: 'LastName',
|
|
label: 'Last Name',
|
|
required: true,
|
|
type: 'text',
|
|
}" @change="formData.last_name = $event">
|
|
</elementInput>
|
|
</div>
|
|
<div class="element">
|
|
<elementInput :input="{
|
|
id: 'Email',
|
|
label: 'Email',
|
|
required: true,
|
|
type: 'email',
|
|
}" @change="formData.email = $event">
|
|
</elementInput>
|
|
</div>
|
|
<div class="element">
|
|
<label class="tw-block tw-mb-[10px]"><span>{{ $t("Phone") }}<span class="required">*</span></span></label>
|
|
<vue-country-code class="d-none" enabledCountryCode :enabledFlags="false"></vue-country-code>
|
|
<vue-phone-number-input color="#EF5A5A" valid-color="#EE9546" :border-radius="5" no-flags no-example
|
|
v-model="formData.phone_number"></vue-phone-number-input>
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer tw-flex tw-justify-end tw-items-center tw-mt-[60px]">
|
|
<button class="tw-transition tw-btn-md tw-text-primary-1 tw-px-[30px] tw-py-[9.5px] tw-mr-[10px] tw-rounded-2xl"
|
|
@click="reset">
|
|
{{ $t("Clear") }}
|
|
</button>
|
|
<button
|
|
class="tw-transition tw-btn-md tw-bg-primary-1 tw-px-[30px] tw-py-[9.5px] tw-rounded-2xl hover:tw-bg-primary-2"
|
|
@click="save">
|
|
{{ $t("Add") }}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</modal>
|
|
</template>
|
|
<script>
|
|
import elementInput from "@/components/newComponent/form/ElementInput";
|
|
import is from "is_js";
|
|
export default {
|
|
name: "AddContactModal",
|
|
components: {
|
|
elementInput,
|
|
is,
|
|
},
|
|
data() {
|
|
return {
|
|
formData: {
|
|
first_name: "",
|
|
last_name: "",
|
|
email: "",
|
|
country_code: "",
|
|
phone_number: "",
|
|
},
|
|
validation: {
|
|
first_name: true,
|
|
last_name: true,
|
|
email: true,
|
|
phone_number: true,
|
|
},
|
|
errors: null,
|
|
};
|
|
},
|
|
mounted() {},
|
|
methods: {
|
|
reset() {
|
|
this.formData = {
|
|
first_name: "",
|
|
last_name: "",
|
|
email: "",
|
|
country_code: "",
|
|
phone_number: "",
|
|
};
|
|
},
|
|
save() {
|
|
this.validators();
|
|
if (this.validators()) {
|
|
const patchData = JSON.parse(JSON.stringify(this.formData));
|
|
this.$axios
|
|
.post(
|
|
`/member/contacts?jwt=${
|
|
this.$auth.$storage.getUniversal("jwt").token
|
|
}`,
|
|
patchData
|
|
)
|
|
.then((result) => {
|
|
if (result.status == 200) {
|
|
this.$emit("update", true);
|
|
this.reset();
|
|
this.$modal.hide("add-contact-modal");
|
|
}
|
|
})
|
|
.catch((err) => {
|
|
console.log(err);
|
|
});
|
|
}
|
|
},
|
|
validators() {
|
|
if (is.empty(this.formData.first_name)) {
|
|
this.validation.first_name = false;
|
|
} else {
|
|
this.validation.first_name = true;
|
|
}
|
|
if (is.empty(this.formData.last_name)) {
|
|
this.validation.last_name = false;
|
|
} else {
|
|
this.validation.last_name = true;
|
|
}
|
|
if (is.empty(this.formData.email) || is.not.email(this.formData.email)) {
|
|
this.validation.email = false;
|
|
} else {
|
|
this.validation.email = true;
|
|
}
|
|
if (
|
|
is.empty(this.formData.phone_number) &&
|
|
is.number(this.formData.phone_number)
|
|
) {
|
|
this.validation.phone_number = false;
|
|
} else {
|
|
this.validation.phone_number = true;
|
|
}
|
|
this.errors = Object.entries(this.validation).filter(
|
|
(e) => e[1] == false
|
|
);
|
|
if (this.errors.length > 0) {
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
<style lang="scss" scoped>
|
|
.close {
|
|
position: absolute;
|
|
right: 25px;
|
|
top: 25px;
|
|
background-image: url("~/assets/svg/close.svg");
|
|
background-position: center;
|
|
background-repeat: no-repeat;
|
|
background-size: cover;
|
|
width: 14px;
|
|
height: 14px;
|
|
|
|
@media screen and (min-width: 1366px) {
|
|
position: relative;
|
|
right: initial;
|
|
top: initial;
|
|
}
|
|
}
|
|
|
|
:deep() {
|
|
.v--modal-box {
|
|
height: 100vh !important;
|
|
|
|
@media screen and (min-width: 768px) {
|
|
height: max-content !important;
|
|
width: max-content;
|
|
}
|
|
}
|
|
|
|
.v--modal {
|
|
height: 100vh !important;
|
|
|
|
@media screen and (min-width: 768px) {
|
|
height: max-content !important;
|
|
width: max-content;
|
|
}
|
|
}
|
|
}
|
|
</style>
|