¨4.0.1¨
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import Errors from '../../../Errors';
|
||||
import Errors from "../../../Errors";
|
||||
|
||||
export default {
|
||||
props: ['initialAddresses', 'initialDefaultAddress', 'countries'],
|
||||
props: ["initialAddresses", "initialDefaultAddress", "countries"],
|
||||
|
||||
data() {
|
||||
return {
|
||||
addresses: this.initialAddresses,
|
||||
defaultAddress: this.initialDefaultAddress,
|
||||
form: { state: '' },
|
||||
form: { state: "" },
|
||||
states: {},
|
||||
errors: new Errors(),
|
||||
formOpen: false,
|
||||
@@ -36,33 +36,33 @@ export default {
|
||||
|
||||
methods: {
|
||||
changeDefaultAddress(address) {
|
||||
this.$set(this.defaultAddress, 'address_id', address.id);
|
||||
this.$set(this.defaultAddress, "address_id", address.id);
|
||||
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
url: route('account.change_default_address'),
|
||||
data: { address_id: address.id },
|
||||
}).then((message) => {
|
||||
this.$notify(message);
|
||||
}).catch((xhr) => {
|
||||
this.$notify(xhr.responseJSON.message);
|
||||
});
|
||||
axios
|
||||
.post(route("account.change_default_address"), {
|
||||
address_id: address.id,
|
||||
})
|
||||
.then((response) => {
|
||||
this.$notify(response.data);
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$notify(error.response.data.message);
|
||||
});
|
||||
},
|
||||
|
||||
changeCountry(country) {
|
||||
this.form.country = country;
|
||||
this.form.state = '';
|
||||
this.form.state = "";
|
||||
|
||||
this.fetchStates(country);
|
||||
},
|
||||
|
||||
fetchStates(country) {
|
||||
$.ajax({
|
||||
method: 'GET',
|
||||
url: route('countries.states.index', { code: country }),
|
||||
}).then((states) => {
|
||||
this.$set(this, 'states', states);
|
||||
});
|
||||
async fetchStates(country) {
|
||||
const response = await axios.get(
|
||||
route("countries.states.index", { code: country })
|
||||
);
|
||||
|
||||
this.$set(this, "states", response.data);
|
||||
},
|
||||
|
||||
edit(address) {
|
||||
@@ -74,19 +74,21 @@ export default {
|
||||
},
|
||||
|
||||
remove(address) {
|
||||
if (! confirm(this.$trans('storefront::account.addresses.confirm'))) {
|
||||
if (
|
||||
!confirm(this.$trans("storefront::account.addresses.confirm"))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
method: 'DELETE',
|
||||
url: route('account.addresses.destroy', address.id),
|
||||
}).then((response) => {
|
||||
this.$delete(this.addresses, address.id);
|
||||
this.$notify(response.message);
|
||||
}).catch((xhr) => {
|
||||
this.$notify(xhr.responseJSON.message);
|
||||
});
|
||||
axios
|
||||
.delete(route("account.addresses.destroy", address.id))
|
||||
.then((response) => {
|
||||
this.$delete(this.addresses, address.id);
|
||||
this.$notify(response.data.message);
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$notify(error.response.data.message);
|
||||
});
|
||||
},
|
||||
|
||||
cancel() {
|
||||
@@ -108,56 +110,62 @@ export default {
|
||||
},
|
||||
|
||||
update() {
|
||||
$.ajax({
|
||||
method: 'PUT',
|
||||
url: route('account.addresses.update', { id: this.form.id }),
|
||||
data: this.form,
|
||||
}).then((response) => {
|
||||
this.formOpen = false;
|
||||
this.editing = false;
|
||||
axios
|
||||
.put(
|
||||
route("account.addresses.update", { id: this.form.id }),
|
||||
this.form
|
||||
)
|
||||
.then(({ data }) => {
|
||||
this.formOpen = false;
|
||||
this.editing = false;
|
||||
|
||||
this.addresses[this.form.id] = response.address;
|
||||
this.addresses[this.form.id] = data.address;
|
||||
|
||||
this.resetForm();
|
||||
this.$notify(response.message);
|
||||
}).catch((xhr) => {
|
||||
if (xhr.status === 422) {
|
||||
this.errors.record(xhr.responseJSON.errors);
|
||||
}
|
||||
this.resetForm();
|
||||
this.$notify(data.message);
|
||||
})
|
||||
.catch(({ response }) => {
|
||||
if (response.status === 422) {
|
||||
this.errors.record(response.data.errors);
|
||||
}
|
||||
|
||||
this.$notify(xhr.responseJSON.message);
|
||||
}).always(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
this.$notify(response.data.message);
|
||||
})
|
||||
.finally(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
|
||||
create() {
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
url: route('account.addresses.store'),
|
||||
data: this.form,
|
||||
}).then((response) => {
|
||||
this.formOpen = false;
|
||||
axios
|
||||
.post(route("account.addresses.store"), this.form)
|
||||
.then(({ data }) => {
|
||||
this.formOpen = false;
|
||||
|
||||
let address = { [response.address.id]: response.address };
|
||||
let address = { [data.address.id]: data.address };
|
||||
|
||||
this.$set(this, 'addresses', { ...this.addresses, ...address });
|
||||
this.$set(this, "addresses", {
|
||||
...this.addresses,
|
||||
...address,
|
||||
});
|
||||
|
||||
this.resetForm();
|
||||
this.$notify(response.message);
|
||||
}).catch((xhr) => {
|
||||
if (xhr.status === 422) {
|
||||
this.errors.record(xhr.responseJSON.errors);
|
||||
}
|
||||
this.resetForm();
|
||||
this.$notify(data.message);
|
||||
})
|
||||
.catch(({ response }) => {
|
||||
if (response.status === 422) {
|
||||
this.errors.record(response.data.errors);
|
||||
}
|
||||
|
||||
this.$notify(xhr.responseJSON.message);
|
||||
}).always(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
this.$notify(response.data.message);
|
||||
})
|
||||
.finally(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
|
||||
resetForm() {
|
||||
this.form = { state: '' };
|
||||
this.form = { state: "" };
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
import ProductHelpersMixin from "../../../mixins/ProductHelpersMixin";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
VPagination: () => import("../../VPagination.vue"),
|
||||
},
|
||||
|
||||
mixins: [ProductHelpersMixin],
|
||||
|
||||
data() {
|
||||
return {
|
||||
fetchingReviews: false,
|
||||
reviews: { data: [] },
|
||||
currentPage: 1,
|
||||
};
|
||||
},
|
||||
|
||||
computed: {
|
||||
reviewIsEmpty() {
|
||||
return this.reviews.data.length === 0;
|
||||
},
|
||||
|
||||
totalPage() {
|
||||
return Math.ceil(this.reviews.total / 10);
|
||||
},
|
||||
},
|
||||
|
||||
created() {
|
||||
this.fetchReviews();
|
||||
},
|
||||
|
||||
methods: {
|
||||
changePage(page) {
|
||||
this.currentPage = page;
|
||||
|
||||
this.fetchReviews();
|
||||
},
|
||||
|
||||
async fetchReviews() {
|
||||
this.fetchingReviews = true;
|
||||
|
||||
try {
|
||||
const response = await axios.get(
|
||||
route("reviews.products.index", {
|
||||
page: this.currentPage,
|
||||
})
|
||||
);
|
||||
|
||||
this.reviews = response.data;
|
||||
} catch (error) {
|
||||
this.$notify(error.response.data.message);
|
||||
} finally {
|
||||
this.fetchingReviews = false;
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -1,13 +1,10 @@
|
||||
import store from '../../../store';
|
||||
import VPagination from '../../VPagination.vue';
|
||||
import ProductHelpersMixin from '../../../mixins/ProductHelpersMixin';
|
||||
import store from "../../../store";
|
||||
import ProductHelpersMixin from "../../../mixins/ProductHelpersMixin";
|
||||
|
||||
export default {
|
||||
components: { VPagination },
|
||||
components: { VPagination: () => import("../../VPagination.vue") },
|
||||
|
||||
mixins: [
|
||||
ProductHelpersMixin,
|
||||
],
|
||||
mixins: [ProductHelpersMixin],
|
||||
|
||||
data() {
|
||||
return {
|
||||
@@ -23,7 +20,7 @@ export default {
|
||||
},
|
||||
|
||||
totalPage() {
|
||||
return Math.ceil(this.products.total / 20);
|
||||
return Math.ceil(this.products.total / 10);
|
||||
},
|
||||
},
|
||||
|
||||
@@ -32,21 +29,28 @@ export default {
|
||||
},
|
||||
|
||||
methods: {
|
||||
fetchWishlist() {
|
||||
changePage(page) {
|
||||
this.currentPage = page;
|
||||
|
||||
this.fetchWishlist();
|
||||
},
|
||||
|
||||
async fetchWishlist() {
|
||||
this.fetchingWishlist = true;
|
||||
|
||||
$.ajax({
|
||||
method: 'GET',
|
||||
url: route('wishlist.products.index', {
|
||||
page: this.currentPage,
|
||||
}),
|
||||
}).then((products) => {
|
||||
this.products = products;
|
||||
}).catch((xhr) => {
|
||||
this.$notify(xhr.responseJSON.message);
|
||||
}).always(() => {
|
||||
try {
|
||||
const response = await axios.get(
|
||||
route("wishlist.products.index", {
|
||||
page: this.currentPage,
|
||||
})
|
||||
);
|
||||
|
||||
this.products = response.data;
|
||||
} catch (error) {
|
||||
this.$notify(error.response.data.message);
|
||||
} finally {
|
||||
this.fetchingWishlist = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
remove(product) {
|
||||
|
||||
Reference in New Issue
Block a user