Skip to content
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
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": "^8.0|^8.1|^8.2",
"php": "^8.0",
"blade-ui-kit/blade-heroicons": "^2.0",
"rapidez/account": "^3.0",
"rapidez/core": "^3.1"
"rapidez/account": "^3.2",
"rapidez/core": "^3.4"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 4 additions & 0 deletions resources/js/components/AddressCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
return this.address?.country_id ?? this.address?.country_code ?? ''
},

region() {
return this.address?.region?.region ?? this.address?.region?.region_code ?? ''
},

isEmpty() {
return [this.company, this.street, this.name, this.city].filter(Boolean).length == 0
}
Expand Down
4 changes: 2 additions & 2 deletions resources/views/account/address-edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@section('account-content')
<x-rapidez-ct::sections>
<graphql
query="{ customer { addresses { id firstname middlename lastname street city postcode country_code telephone company vat_id default_billing default_shipping } } }"
query="{ customer { addresses { id firstname middlename lastname street city postcode country_code region { region_id } telephone company vat_id default_billing default_shipping } } }"
:check="(data) => data.customer?.addresses.find(a => a.id == {{ request()->id }})"
redirect="{{ route('account.edit') }}"
>
Expand All @@ -19,7 +19,7 @@
:notify="{ 'message': '@lang('Address changed successfully')' }"
redirect="{{ route('account.edit') }}"
>
@include('rapidez-ct::account.partials.address-form')
@include('rapidez-ct::account.partials.address-form', ['region' => 'region.region_id'])
</graphql-mutation>
</div>
</graphql>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/account/address-new.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
:notify="{ 'message': '@lang('Address created successfully')' }"
redirect="{{ route('account.edit') }}"
>
@include('rapidez-ct::account.partials.address-form')
@include('rapidez-ct::account.partials.address-form', ['region' => 'region.region_id'])
</graphql-mutation>
</x-rapidez-ct::sections>
@endsection
4 changes: 3 additions & 1 deletion resources/views/account/partials/address-form.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
@props(['region' => 'region_id'])

<form slot-scope="{ variables, mutate, mutated }" v-on:submit.prevent="mutate">
<x-rapidez-ct::sections>
<x-rapidez-ct::card.inactive>
<x-rapidez-ct::address-form type="edit" address="variables" country-key="country_code"/>
<x-rapidez-ct::address-form type="edit" :$region/>
<div class="flex gap-5 py-5">
<x-rapidez::input.checkbox v-model="variables.default_shipping">@lang('Default shipping address')</x-input.checkbox>
<x-rapidez::input.checkbox v-model="variables.default_billing">@lang('Default billing address')</x-input.checkbox>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,23 @@
<x-rapidez::input.select.country
name="country_code"
v-model="addressVariables.country_code"
v-on:change="window.app.$emit('postcode-change', addressVariables)"
class="w-full"
v-on:change="() => {
window.app.$emit('postcode-change', addressVariables);
addressVariables.region = { region_id: null };
}"
required
/>
</label>
<label class="sm:col-span-2 has-[.exists]:block hidden">
<x-rapidez::label>@lang('Region')</x-rapidez::label>
<x-rapidez::input.select.region
class="exists"
name="region"
v-model="addressVariables.region.region_id"
country="addressVariables.country_code"
/>
</label>
</span>
</div>
</div>
Expand Down
6 changes: 4 additions & 2 deletions resources/views/checkout/partials/sections/address.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
cart_id: mask,
...window.address_defaults,
...cart.shipping_addresses[0],
country_code: cart.shipping_addresses[0]?.country.code || window.address_defaults.country_code
country_code: cart.shipping_addresses[0]?.country.code || window.address_defaults.country_code,
region_id: cart.shipping_addresses[0]?.region.region_id || window.address_defaults.region_id,
}"
group="shipping"
:callback="updateCart"
Expand All @@ -34,7 +35,8 @@
...window.address_defaults,
...cart.billing_address,
same_as_shipping: !cart.is_virtual && (cart?.billing_address?.same_as_shipping ?? true),
country_code: cart.billing_address?.country.code || window.address_defaults.country_code
country_code: cart.billing_address?.country.code || window.address_defaults.country_code,
region_id: cart.billing_address?.region.region_id || window.address_defaults.region_id,
}))"
:callback="updateCart"
:error-callback="checkResponseForExpiredCart"
Expand Down
15 changes: 14 additions & 1 deletion resources/views/components/address-form.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@props(['type' => 'shipping', 'address' => 'variables', 'countryKey' => 'country_code'])
@props(['type' => 'shipping', 'address' => 'variables', 'countryKey' => 'country_code', 'region' => 'region_id'])

<div class="grid gap-4 md:gap-5 md:grid-cols-4">
@if (Rapidez::config('customer/address/company_show', 'opt') || Rapidez::config('customer/address/taxvat_show', 0))
Expand Down Expand Up @@ -29,9 +29,22 @@
<x-rapidez::input.select.country
name="{{ $type }}_country"
v-model="{{ $address }}.{{ $countryKey }}"
v-on:change="() => {
{{ $address }}.region = {};
{{ $address }}.{{ $region }} = null;
}"
required
/>
</label>
<label class="sm:col-span-2 has-[.exists]:block hidden">
<x-rapidez::label>@lang('Region')</x-rapidez::label>
<x-rapidez::input.select.region
class="exists"
name="{{ $type }}_region"
v-model="{{ $address }}.{{ $region }}"
country="{{ $address }}.{{ $countryKey }}"
/>
</label>
<div class="max-sm:hidden sm:col-span-2"></div>
<label @class([ 'sm:col-span-2' => !Rapidez::config('customer/address/middlename_show', 0)])>
<x-rapidez::label>@lang('Firstname')</x-rapidez::label>
Expand Down
3 changes: 2 additions & 1 deletion resources/views/components/address.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
'v-bind:shipping' => var_export($shipping, true),
'v-bind:billing' => var_export($billing, true),
]) }}
v-slot="{ company, name, street, city, country, billing, shipping, isEmpty, customTitle, disabled, check }"
v-slot="{ company, name, street, city, country, region, billing, shipping, isEmpty, customTitle, disabled, check }"
>
<div {{ $attributes->whereDoesntStartWith('v-')->class('flex flex-col') }}>
<template v-if="!isEmpty">
Expand All @@ -32,6 +32,7 @@
<li v-if="name">@{{ name }}</li>
<li v-if="street">@{{ street }}</li>
<li v-if="city">@{{ city }}</li>
<li v-if="region">@{{ region }}</li>
<li v-if="country">@{{ country }}</li>
</ul>
@if (!empty($slot))
Expand Down