From 0df1de9e72c2a6b06d7cd0bd95b32f0ee2363380 Mon Sep 17 00:00:00 2001 From: Roy Duineveld Date: Wed, 21 Feb 2024 14:10:42 +0100 Subject: [PATCH] Rapidez v2 compatibility (#43) --- composer.json | 2 +- resources/js/callbacks.js | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index 90c4f7d..1f3624a 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "php": "^8.0|^8.1", "illuminate/support": "^9.0|^10.0", "illuminate/view": "^9.0|^10.0", - "rapidez/core": "^1.0" + "rapidez/core": "^2.0" }, "autoload": { "psr-4": { diff --git a/resources/js/callbacks.js b/resources/js/callbacks.js index 5ab6a23..dac9942 100644 --- a/resources/js/callbacks.js +++ b/resources/js/callbacks.js @@ -1,14 +1,13 @@ import 'Vendor/rapidez/core/resources/js/vue' import InteractWithUser from 'Vendor/rapidez/core/resources/js/components/User/mixins/InteractWithUser' -import { mask } from 'Vendor/rapidez/core/resources/js/stores/useMask'; -import { token } from 'Vendor/rapidez/core/resources/js/stores/useUser' -import GetCart from 'Vendor/rapidez/core/resources/js/components/Cart/mixins/GetCart' +import { mask } from 'Vendor/rapidez/core/resources/js/stores/useMask' +import { cart, linkUserToCart, refresh as refreshCart } from 'Vendor/rapidez/core/resources/js/stores/useCart' Vue.prototype.registerCallback = async function (variables, response) { await InteractWithUser.methods.login(variables.email, variables.password) await InteractWithUser.methods.refreshUser() - if (token.value && mask.value) { - await GetCart.methods.linkUserToCart() + if (cart?.value?.id && mask) { + await linkUserToCart() } } @@ -24,11 +23,11 @@ Vue.prototype.reorderCallback = async function (variables, response) { document.removeEventListener('turbo:load', showReorderErrors) }) - await GetCart.methods.refreshCart() + await refreshCart() } -Vue.prototype.sortOrdersCallback = async function (response) { - response.data.data.customer.orders.items.sort((a,b) => { +Vue.prototype.sortOrdersCallback = async function (data, response) { + response.data.customer.orders.items.sort((a,b) => { return new Date(b.order_date) - new Date(a.order_date) })