This commit is contained in:
rakesh 2023-05-13 16:12:37 +05:30
parent 72183bf5f4
commit 653dbf3b8a
1 changed files with 266 additions and 184 deletions

View File

@ -3,68 +3,97 @@
<v-row>
<v-col cols="12" sm="12" class="fontcolor-black-light">
<div v-show="!addressId">
<p class="h2 mb-5 body-font text-uppercase text-primary pb-2">Address Book</p>
<p class="h2 mb-5 body-font text-uppercase text-primary pb-2">
Address Book
</p>
<div class="address-book-line my-1"></div>
<v-row class="mt-12" align="center" justify="center" v-if="inProgress">
<v-progress-circular :size="60" color="primary" indeterminate></v-progress-circular>
<v-row
class="mt-12"
align="center"
justify="center"
v-if="inProgress"
>
<v-progress-circular
:size="60"
color="primary"
indeterminate
></v-progress-circular>
</v-row>
<v-row class="mt-4" v-else>
<v-col cols="12" sm="6" md="6" lg="6">
<p
class="body-font text-uppercase text-primary font-weight-bold"
>Default Billing Address</p>
<p
class="body-font"
v-if="!billingAddressDetails.address"
>You have not set a default billing address.</p>
<p class="body-font text-uppercase text-primary font-weight-bold">
Default Billing Address
</p>
<p class="body-font" v-if="!billingAddressDetails.address">
You have not set a default billing address.
</p>
<div v-else>
<p class="body-font">You have set a default billing address.</p>
<BillingAddressComponent :address="billingAddressDetails.address" />
<BillingAddressComponent
:address="billingAddressDetails.address"
/>
</div>
<v-row>
<v-col cols="12">
<v-hover v-slot:default="{ isHovering, props }">
<v-btn
@click="editAddress(billingAddressDetails.address,billingAddressDetails.index)"
@click="
editAddress(
billingAddressDetails.address,
billingAddressDetails.index
)
"
v-bind="props"
:variant="isHovering"
:color="isHovering?'white':'primary'"
:class="isHovering?'text-primary':'text-white'"
depressed
:variant="isHovering ? 'outlined' : 'outlined'"
:class="
isHovering ? ' bg-white text-primary' : 'bg-primary'
"
rounded="0"
size="large"
:large="$vuetify.display.mdAndUp ? true : false"
tile
class="body-font my-2 address-book-button"
>EDIT</v-btn>
>EDIT</v-btn
>
</v-hover>
</v-col>
</v-row>
</v-col>
<v-col cols="12" sm="6" md="6" lg="6">
<p
class="body-font text-uppercase text-primary font-weight-bold"
>Default Shipping Address</p>
<p
class="body-font"
v-if="!shippingAddressDetails.address"
>You have not set a default shipping address.</p>
<p class="body-font text-uppercase text-primary font-weight-bold">
Default Shipping Address
</p>
<p class="body-font" v-if="!shippingAddressDetails.address">
You have not set a default shipping address.
</p>
<div v-else>
<p class="body-font">You have set a default shipping address.</p>
<ShippingAddressComponent :address="shippingAddressDetails.address" />
<p class="body-font">
You have set a default shipping address.
</p>
<ShippingAddressComponent
:address="shippingAddressDetails.address"
/>
</div>
<v-row>
<v-col cols="12">
<v-hover v-slot:default="{ isHovering, props }">
<v-btn
@click="editAddress(shippingAddressDetails.address,shippingAddressDetails.index)"
depressed
@click="
editAddress(
shippingAddressDetails.address,
shippingAddressDetails.index
)
"
:large="$vuetify.display.mdAndUp ? true : false"
tile
v-bind="props"
:variant="isHovering"
:color="isHovering?'white':'primary'"
:class="isHovering?'text-primary':'text-white'"
:variant="isHovering ? 'outlined' : 'outlined'"
:class="
isHovering ? ' bg-white text-primary' : 'bg-primary'
"
rounded="0"
size="large"
class="body-font my-2 address-book-button"
>EDIT</v-btn>
>EDIT</v-btn
>
</v-hover>
</v-col>
</v-row>
@ -75,20 +104,35 @@
<v-row class="mt-4">
<p
class="h3 body-font text-uppercase text-primary pb-2 mb-1 mr-3"
>Additional Address Entries</p>
>
Additional Address Entries
</p>
</v-row>
</v-col>
<div class="address-book-line my-1"></div>
<v-row class="mt-12" justify="center" align="center" v-if="fetchInProgress">
<v-progress-circular :size="60" color="primary" indeterminate></v-progress-circular>
<v-row
class="mt-12"
justify="center"
align="center"
v-if="fetchInProgress"
>
<v-progress-circular
:size="60"
color="primary"
indeterminate
></v-progress-circular>
</v-row>
<v-row
v-else-if="addresses.length < 2 && address.id==basicInfo.defaultBilling && address.id==basicInfo.defaultShipping"
v-else-if="
addresses.length < 2 &&
address.id == basicInfo.defaultBilling &&
address.id == basicInfo.defaultShipping
"
>
<v-col>
<p
class="body-font mb-1 mr-3"
>You have no other address entries in your address book.</p>
<p class="body-font mb-1 mr-3">
You have no other address entries in your address book.
</p>
</v-col>
</v-row>
<v-row v-else>
@ -99,7 +143,10 @@
lg="6"
v-for="(address, index) in addresses"
v-bind:key="index"
v-show="address.id!==basicInfo.defaultBilling || address.id!==basicInfo.defaultShipping"
v-show="
address.id !== basicInfo.defaultBilling ||
address.id !== basicInfo.defaultShipping
"
>
<ShippingAddressComponent :address="address" />
<v-row>
@ -107,30 +154,32 @@
<v-hover v-slot:default="{ isHovering, props }">
<v-btn
@click="editAddress(address, index)"
depressed
tile
dense
v-bind="props"
:variant="isHovering"
:color="isHovering?'white':'primary'"
:class="isHovering?'text-primary':'text-white'"
variant="isHovering ? 'outlined' : 'outlined'"
:class="
isHovering ? ' bg-white text-primary' : 'bg-primary'
"
rounded="0"
size="large"
class="body-font my-2 address-book-button"
>EDIT</v-btn>
>EDIT</v-btn
>
</v-hover>
</v-col>
<v-col cols="2">
<v-hover v-slot:default="{ isHovering, props }">
<v-btn
@click="deleteAddress(address)"
depressed
tile
dense
v-bind="props"
:variant="isHovering"
:color="isHovering?'white':'red'"
:class="isHovering?'text-red':'text-white'"
:variant="isHovering ? 'outlined' : 'outlined'"
:class="
isHovering ? ' bg-white text-primary' : 'bg-primary'
"
rounded="0"
size="large"
class="body-font my-2 white--text"
>DELETE</v-btn>
>DELETE</v-btn
>
</v-hover>
</v-col>
</v-row>
@ -141,67 +190,92 @@
<v-hover v-slot:default="{ isHovering, props }">
<v-btn
@click="editAddress()"
depressed
:large="$vuetify.display.mdAndUp ? true : false"
tile
v-bind="props"
:variant="isHovering"
:color="isHovering?'white':'primary'"
:class="isHovering?'text-primary':'text-white'"
:variant="isHovering ? 'outlined' : 'outlined'"
:class="
isHovering ? ' bg-white text-primary' : 'bg-primary'
"
rounded="0"
size="large"
class="body-font my-2 address-book-button"
>ADD NEW ADDRESS</v-btn>
>ADD NEW ADDRESS</v-btn
>
</v-hover>
</v-col>
</v-row>
</div>
</div>
<div v-show="addressId">
<p class="h2 mb-5 body-font text-uppercase text-primary">Add New Address</p>
<p class="h2 mb-5 body-font text-uppercase text-primary">
Add New Address
</p>
<v-form ref="addressBookForm" v-model="valid">
<v-row>
<v-col cols="12" sm="6">
<p class="h3 body-font text-uppercase text-primary">Contact Information</p>
<p class="h3 body-font text-uppercase text-primary">
Contact Information
</p>
<div class="address-book-line mb-5"></div>
<!-- <ContactInfoComponent v-bind:contactDetails="basicInfo" ref="contactInfoForm" /> -->
<v-form ref="contactForm" v-model="valid" :lazy-validation="lazy">
<v-form
ref="contactForm"
v-model="valid"
:lazy-validation="lazy"
>
<v-row no-gutters>
<v-col cols="12">
<v-text-field
label="First Name"
ref="firstName"
v-model="firstname"
outlined
required
dense
color="primary"
density="compact"
variant="outlined"
:rules="textRules"
></v-text-field>
<v-text-field
label="Last Name"
ref="lastName"
v-model="lastname"
outlined
dense
color="primary"
density="compact"
variant="outlined"
required
:rules="textRules"
></v-text-field>
<v-text-field label="Company" ref="company" v-model="company" outlined dense></v-text-field>
<v-text-field
label="Company"
ref="company"
v-model="company"
color="primary"
density="compact"
variant="outlined"
></v-text-field>
<vue-tel-input
type="number"
v-model="telephone"
:defaultCountry="setCountryCode"
:class="phoneNumberError ? 'phonenumber-input-error-border':'phonenumber-custom-input'"
:class="
phoneNumberError
? 'phonenumber-input-error-border'
: 'phonenumber-custom-input'
"
@input="validateNumber"
></vue-tel-input>
<span
class="red--text caption ml-3"
v-show="phoneNumberError"
>This field is required</span>
>This field is required</span
>
</v-col>
</v-row>
</v-form>
</v-col>
<v-col cols="12" sm="6">
<p class="h3 body-font text-uppercase primary--text">Address</p>
<p class="h3 body-font text-uppercase text-primary">
Contact Information
</p>
<div class="address-book-line mb-5"></div>
<ShippingAddressFormComponent
@ -216,6 +290,7 @@
v-model="defaultBilling"
class="pt-2"
label="Use as my default billing address"
color="primary"
></v-checkbox>
<v-alert
class="alert-box-outline"
@ -223,12 +298,15 @@
text
dense
v-if="addressId == basicInfo.defaultBilling"
>This is default billing address</v-alert>
>This is default billing address</v-alert
>
<v-checkbox
v-if="addressId != basicInfo.defaultShipping"
v-model="defaultShipping"
class="mt-0"
label="Use as my default shipping address"
color="primary"
></v-checkbox>
<v-alert
class="alert-box-outline"
@ -236,28 +314,31 @@
text
dense
v-if="addressId == basicInfo.defaultShipping"
>This is default shipping address</v-alert>
>This is default shipping address</v-alert
>
</v-col>
</v-row>
<v-hover v-slot:default="{ hover }">
<v-hover v-slot:default="{ isHovering, props }">
<v-btn
v-bind="props"
class="text-uppercase address-book-button"
:outlined="hover"
:color="hover?'white':'primary'"
:class="hover?'primary--text':'white--text'"
:variant="isHovering ? 'outlined' : 'outlined'"
:class="isHovering ? ' bg-white text-primary' : 'bg-primary'"
rounded="0"
size="large"
@click.stop="dialog = dialog"
tile
large
depressed
@click="submit()"
>SAVE ADDRESS</v-btn>
>SAVE ADDRESS</v-btn
>
</v-hover>
<v-dialog v-model="dialog" persistent max-width="1100px">
<v-card class="pb-2">
<v-card-title class="pb-2">
<v-row no-gutters>
<v-col cols="11">
<p class="h2 mb-1 body-font text-uppercase primary--text">Verify Your Address</p>
<p class="h2 mb-1 body-font text-uppercase primary--text">
Verify Your Address
</p>
</v-col>
<v-col cols="1" class="text-right">
@ -272,8 +353,17 @@
</v-card-title>
<v-card-text>
<div class="address-book-line my-1"></div>
<v-row class="mt-12" justify="center" align="center" v-if="addressInProgress">
<v-progress-circular :size="60" color="primary" indeterminate></v-progress-circular>
<v-row
class="mt-12"
justify="center"
align="center"
v-if="addressInProgress"
>
<v-progress-circular
:size="60"
color="primary"
indeterminate
></v-progress-circular>
</v-row>
<MeVerifyAddressComponent
@ -287,27 +377,30 @@
<v-card-actions class="px-2 py-3">
<v-row no-gutters>
<v-col cols="12" class="text-right">
<v-hover v-slot:default="{ hover }">
<v-hover v-slot:default="{ isHovering, props }">
<v-btn
class="text-uppercase px-3 mr-2 my-2 address-book-button"
:outlined="hover"
:color="hover?'white':'primary'"
:class="hover?'primary--text':'white--text'"
tile
large
depressed
v-bind="props"
:variant="isHovering ? 'outlined' : 'outlined'"
:class="
isHovering ? ' bg-white text-primary' : 'bg-primary'
"
rounded="0"
size="large"
@click="dialog = false"
>EDIT ADDRESS</v-btn>
>EDIT ADDRESS</v-btn
>
</v-hover>
<v-hover v-slot:default="{ hover }">
<v-hover v-slot:default="{ isHovering, props }">
<v-btn
class="text-uppercase px-3 mr-2 my-2 address-book-save-button"
:outlined="hover"
:color="hover?'white':'success'"
:class="hover?'success--text':'white--text'"
tile
large
depressed
v-bind="props"
:variant="isHovering ? 'outlined' : 'outlined'"
:class="
isHovering ? ' bg-white text-primary' : 'bg-primary'
"
rounded="0"
size="large"
@click="saveAddress"
:disabled="inProgress"
>
@ -316,7 +409,8 @@
color="success"
indeterminate
v-if="inProgress"
></v-progress-circular>SAVE ADDRESS
></v-progress-circular
>SAVE ADDRESS
</v-btn>
</v-hover>
</v-col>
@ -329,21 +423,6 @@
</v-col>
</v-row>
<!-- <v-row no-gutters>
<v-col cols="12">
<p class="h2 mb-6">Address Book</p>
<p class="h3">Default Addresses</p>
<hr/>
<v-row no-gutters class="mt-8">
<v-col cols="12" sm="6">
<p class="body"><b>Default Billing Address</b></p>
<BillingAddressComponent v-bind:contactDetails="addressFields"/>
</v-col>
</v-row>
</v-col>
</v-row>-->
<ConfirmationDialog
:confirmationDialog="confirmationDialog"
:confirmationDetails="confirmation"
@ -363,14 +442,14 @@ import MeVerifyAddressComponent from "@/components/retailer/address/MeVerifyAddr
import { loginInterrupt } from "@/services/nav";
import SnackbarComponent from "@/components/common/SnackbarComponent.vue";
import ConfirmationDialog from "@/components/common/ConfirmationDialog.vue";
import { VueTelInput } from 'vue3-tel-input'
import { VueTelInput } from "vue3-tel-input";
//import BillingAddressComponent from "@/components/retailer/address/BillingAddressComponent.vue";
import { createHelpers } from "vuex-map-fields";
const { mapFields } = createHelpers({
getterType: "accountOne/getField",
mutationType: "accountOne/updateField"
mutationType: "accountOne/updateField",
});
export default {
name: "AddressBook",
@ -380,7 +459,7 @@ export default {
phoneNumberError: false,
confirmationDialog: false,
confirmation: {
confirmationMessage: ""
confirmationMessage: "",
},
dialog: false,
deleteAddressDialog: false,
@ -394,17 +473,18 @@ export default {
show: false,
message: null,
color: null,
timeout: 0
timeout: 0,
},
textRules: [
v => !!v || "This field is required",
v => (v && v.length >= 3) || "This field must be at least 3 characters"
(v) => !!v || "This field is required",
(v) =>
(v && v.length >= 3) || "This field must be at least 3 characters",
],
phoneNumberRules: [
v => !!v || "This field is required",
v =>
(v && v.length >= 8) || "Phone Number must be at least 8 characters"
]
(v) => !!v || "This field is required",
(v) =>
(v && v.length >= 8) || "Phone Number must be at least 8 characters",
],
};
},
components: {
@ -415,12 +495,12 @@ export default {
BillingAddressComponent,
ShippingAddressComponent,
ConfirmationDialog,
VueTelInput
VueTelInput,
//BillingAddressComponent
},
computed: {
hideAndShowFields: function () {
let currentName = this.$route.name
let currentName = this.$route.name;
if (currentName === "AddressBook") {
return false;
}
@ -447,7 +527,7 @@ export default {
"allCountries",
"countryAllStates",
"inProgress",
"addressIndex"
"addressIndex",
]),
userAuth: function () {
return this.$store.state.auth.userAuth;
@ -469,7 +549,7 @@ export default {
},
fetchInProgress: function () {
return this.$store.state.accountOne.fetchInProgress;
}
},
},
methods: {
resetForm() {
@ -490,12 +570,14 @@ export default {
) {
this.addressInProgress = true;
this.dialog = true;
let response = await this.$store
.dispatch("accountOne/validateAddress", this.addressFields)
if(typeof(response) == "string"){
let response = await this.$store.dispatch(
"accountOne/validateAddress",
this.addressFields
);
if (typeof response == "string") {
this.geoCodedAddress = response;
this.geoCodedAddressFlag = false;
}else if(typeof(response) == "object"){
} else if (typeof response == "object") {
this.geoCodedAddress = "Address is geocoded.";
this.geoCodedAddressFlag = true;
}
@ -506,7 +588,7 @@ export default {
message: error,
color: "error",
show: true,
timeout: 3000
timeout: 3000,
};
}
},
@ -518,30 +600,30 @@ export default {
message: "Address Updated Successfully",
color: "success",
show: true,
timeout: 3000
timeout: 3000,
};
let page = localStorage.getItem("cr_meCurrentPage");
setTimeout(() => {
if (page == "addressBook")
this.$router.push({
name: "AddressBook"
name: "AddressBook",
});
else
this.$router.push({
name: "AccountDashboard"
name: "AccountDashboard",
});
}, 1000);
})
.catch(error => {
.catch((error) => {
this.snackbar = {
message: error,
color: "error",
show: true,
timeout: 3000
timeout: 3000,
};
setTimeout(() => {
this.$router.push({
name: "AccountDashboard"
name: "AccountDashboard",
});
}, 1000);
});
@ -562,14 +644,14 @@ export default {
localStorage.setItem("cr_meCurrentPage", "addressBook");
this.$router.push({
name: "EditAddressBook",
params: { addressId: addressId }
params: { addressId: addressId },
});
},
deleteAddress(address) {
this.addressObj = address;
(this.confirmationDialog = true),
(this.confirmation = {
confirmationMessage: "Are you sure you want to delete this address?"
confirmationMessage: "Are you sure you want to delete this address?",
});
},
removeAddress(action) {
@ -578,14 +660,14 @@ export default {
}
(this.confirmationDialog = false),
(this.confirmation = {
confirmationMessage: ""
confirmationMessage: "",
});
this.addressObj = "";
},
validateNumber(number, data) {
if (data.possible && data.valid) this.phoneNumberError = false;
else this.phoneNumberError = true;
}
},
},
async created() {
if (this.$route.params.addressId == "new") {
@ -604,7 +686,7 @@ export default {
this.$store.dispatch("accountOne/setAddress", null);
}
}
}
},
};
</script>
<style src="./address_book.scss" lang="scss" scoped/>