Skip to content
Open
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
34 changes: 21 additions & 13 deletions app/Http/Resources/CustomerResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,42 @@ public function toArray($request)
{
$shipping = $this->shippingAddress;
$billing = $this->billingAddress;
return [
'id' => $this->user_id,
'first_name' => $this->first_name,
'last_name' => $this->last_name,
'email' => $this->user->email,
'phone' => $this->phone,
'status' => $this->status === CustomerStatus::Active->value,
'created_at' => (new \DateTime($this->created_at))->format('Y-m-d H:i:s'),
'updated_at' => (new \DateTime($this->updated_at))->format('Y-m-d H:i:s'),

'shippingAddress' => [
if($shipping) {
$shipping = [
'id' => $shipping->id,
'address1' => $shipping->address1,
'address2' => $shipping->address2,
'city' => $shipping->city,
'state' => $shipping->state,
'zipcode' => $shipping->zipcode,
'country_code' => $shipping->country->code,
],
'billingAddress' => [
];
}
if($billing) {
$billing = [
'id' => $billing->id,
'address1' => $billing->address1,
'address2' => $billing->address2,
'city' => $billing->city,
'state' => $billing->state,
'zipcode' => $billing->zipcode,
'country_code' => $billing->country->code,
]
];
}

return [
'id' => $this->user_id,
'first_name' => $this->first_name,
'last_name' => $this->last_name,
'email' => $this->user->email,
'phone' => $this->phone,
'status' => $this->status === CustomerStatus::Active->value,
'created_at' => (new \DateTime($this->created_at))->format('Y-m-d H:i:s'),
'updated_at' => (new \DateTime($this->updated_at))->format('Y-m-d H:i:s'),

'shippingAddress' => $shipping,
'billingAddress' => $billing
];
}
}
10 changes: 8 additions & 2 deletions backend/src/views/Customers/CustomerView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<div>
<h2 class="text-xl font-semibold mt-6 pb-2 border-b border-gray-300">Billing Address</h2>

<div class="grid grid-cols-1 md:grid-cols-2 gap-2">
<div v-if="customer.billingAddress !== null" class="grid grid-cols-1 md:grid-cols-2 gap-2">
<CustomInput v-model="customer.billingAddress.address1" label="Address 1"/>
<CustomInput v-model="customer.billingAddress.address2" label="Address 2"/>
<CustomInput v-model="customer.billingAddress.city" label="City"/>
Expand All @@ -26,12 +26,15 @@
<CustomInput v-else type="select" :select-options="billingStateOptions"
v-model="customer.billingAddress.state" label="State"/>
</div>
<p v-else class="text-center py-8 text-gray-700">
There are is no billing address

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

direct users to provide billing address

</p>
</div>

<div>
<h2 class="text-xl font-semibold mt-6 pb-2 border-b border-gray-300">Shipping Address</h2>

<div class="grid grid-cols-1 md:grid-cols-2 gap-2">
<div v-if="customer.shippingAddress !== null" class="grid grid-cols-1 md:grid-cols-2 gap-2">
<CustomInput v-model="customer.shippingAddress.address1" label="Address 1"/>
<CustomInput v-model="customer.shippingAddress.address2" label="Address 2"/>
<CustomInput v-model="customer.shippingAddress.city" label="City"/>
Expand All @@ -42,6 +45,9 @@
<CustomInput v-else type="select" :select-options="shippingStateOptions"
v-model="customer.shippingAddress.state" label="State"/>
</div>
<p v-else class="text-center py-8 text-gray-700">
There are is no shipping address

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

</p>
</div>
</div>

Expand Down