Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix merge issues, remove todos #647

Merged
merged 2 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
.git
**/*.php
!**/*.blade.php
/resources/views/cart/queries/*.graphql
/resources/views/cart/queries/**/*.graphql
/resources/views/checkout/queries/*.graphql
/resources/views/checkout/queries/**/*.graphql
/resources/views/customer/queries/*.graphql
/resources/views/customer/queries/**/*.graphql
composer.lock
/resources/views/*.graphql
/resources/views/**/*.graphql
CHANGELOG.md
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"lcobucci/clock": "^2.0|^3.2",
"lcobucci/jwt": "^4.0|^5.3",
"mailerlite/laravel-elasticsearch": "^11.1",
"rapidez/blade-directives": "^0.6",
"rapidez/blade-directives": "^0.7",
"tormjens/eventy": "^0.8"
},
"require-dev": {
Expand Down
75 changes: 1 addition & 74 deletions resources/js/callbacks.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cart, clear as clearCart, getAttributeValues } from './stores/useCart'
import { cart, clear as clearCart } from './stores/useCart'
import { fillFromGraphqlResponse as updateOrder, order } from './stores/useOrder'
import { runAfterPlaceOrderHandlers, runBeforePaymentMethodHandlers, runBeforePlaceOrderHandlers } from './stores/usePaymentHandlers'
import { refresh as refreshUser, token } from './stores/useUser'
Expand Down Expand Up @@ -35,48 +35,6 @@ Vue.prototype.submitPartials = async function (form) {
return await Promise.all(promises)
}

Vue.prototype.updateCart = async function (variables, response) {
cart.value = 'cart' in Object.values(response.data)[0] ? Object.values(response.data)[0].cart : Object.values(response.data)[0]

getAttributeValues().then((response) => {
if (!response?.data?.customAttributeMetadata?.items) {
return
}

const mapping = Object.fromEntries(
response.data.customAttributeMetadata.items.map((attribute) => [
attribute.attribute_code,
Object.fromEntries(attribute.attribute_options.map((value) => [value.value, value.label])),
]),
)

cart.value.items = cart.value.items.map((cartItem) => {
cartItem.product.attribute_values = {}

for (const key in mapping) {
cartItem.product.attribute_values[key] = cartItem.product[key]
if (cartItem.product.attribute_values[key] === null) {
continue
}

if (typeof cartItem.product.attribute_values[key] === 'string') {
cartItem.product.attribute_values[key] = cartItem.product.attribute_values[key].split(',')
}

if (typeof cartItem.product.attribute_values[key] !== 'object') {
cartItem.product.attribute_values[key] = [cartItem.product.attribute_values[key]]
}

cartItem.product.attribute_values[key] = cartItem.product.attribute_values[key].map((value) => mapping[key][value] || value)
}

return cartItem
})
})

return response.data
}

Vue.prototype.checkResponseForExpiredCart = async function (variables, response) {
if (
response?.errors?.some(
Expand Down Expand Up @@ -115,37 +73,6 @@ Vue.prototype.updateOrder = async function (data, response) {
return response.data
}

Vue.prototype.checkResponseForExpiredCart = async function (variables, response) {
if (
response?.errors?.some(
(error) =>
error.extensions.category === 'graphql-no-such-entity' &&
error.path.some((path) =>
[
'cart',
'customerCart',
'assignCustomerToGuestCart',
'mergeCarts',
'addProductsToCart',
'removeItemFromCart',
'updateCartItems',
].includes(path),
),
)
) {
Notify(window.config.translations.errors.cart_expired, 'error')
clearCart()
if (token.value !== undefined) {
// If the cart has expired, check if the session is not expired
refreshUser()
}

return true
}

return false
}

Vue.prototype.handleBeforePaymentMethodHandlers = runBeforePaymentMethodHandlers
Vue.prototype.handleBeforePlaceOrderHandlers = runBeforePlaceOrderHandlers

Expand Down
1 change: 0 additions & 1 deletion resources/views/cart/queries/fragments/cart.graphql
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
fragment cart on Cart {
id
# TODO: Check if virtual orders are working
is_virtual
total_quantity
items {
Expand Down
5 changes: 2 additions & 3 deletions resources/views/checkout/partials/sidebar.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@

<div v-if="cart.shipping_addresses[0]" class="flex w-full flex-col gap-x-1 border p-3 rounded">
<p class="font-lg mb-2 font-bold text-neutral">
{{-- TODO: Check this compare as uid might not what we want but there is not anything else in the cart response --}}
<template v-if="cart.shipping_addresses[0]?.uid == cart.billing_address?.uid">@lang('Shipping & billing address')</template>
<template v-if="cart.billing_address?.same_as_shipping">@lang('Shipping & billing address')</template>
<template v-else>@lang('Shipping address')</template>
</p>
<ul>
Expand All @@ -49,7 +48,7 @@
<li v-if="cart.shipping_addresses[0]?.telephone">@{{ cart.shipping_addresses[0]?.telephone }}</li>
</ul>
</div>
<div v-if="cart.billing_address && !cart.shipping_addresses[0]?.uid != cart.billing_address.uid" class="mt-4 flex w-full flex-col gap-x-1 border p-3">
<div v-if="cart.billing_address && !cart.billing_address?.same_as_shipping" class="mt-4 flex w-full flex-col gap-x-1 border p-3">
<p class="font-lg mb-2 font-bold text-neutral">@lang('Billing address')</p>
<ul>
<li v-if="cart.billing_address.company">@{{ cart.billing_address.company }}</li>
Expand Down
4 changes: 1 addition & 3 deletions resources/views/checkout/steps/agreements.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
@php($checkoutAgreements ??= \Rapidez\Core\Models\CheckoutAgreement::all())
@if (!$checkoutAgreements->count())
@return
@endif
@return(!$checkoutAgreements->count())

@foreach ($checkoutAgreements as $agreement)
<x-rapidez::slideover position="right" id="{{ $agreement->agreement_id }}_agreement">
Expand Down
1 change: 0 additions & 1 deletion resources/views/checkout/steps/place_order.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
:callback="handlePlaceOrder"
mutate-event="placeOrder"
redirect="{{ route('checkout.success') }}"
{{-- :error-callback="alert" --}}
v-slot="{ mutate, variables }"
>
<fieldset>
Expand Down
3 changes: 0 additions & 3 deletions src/Http/Controllers/CheckoutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ public function __invoke(Request $request, ?string $step = null)

abort_if(! in_array($step, $checkoutSteps), 404);

// TODO: Is there a way to check if we should be able to go to this step?
// For example; without a quote we could be redirected to the homepage.

return view('rapidez::checkout.pages.' . $step, [
'checkoutSteps' => $checkoutSteps,
'currentStep' => $step,
Expand Down
Loading