Skip to content

Commit

Permalink
Merge pull request #16 from fleetbase/dev-v0.3.2
Browse files Browse the repository at this point in the history
release v0.3.2
  • Loading branch information
roncodes authored Feb 23, 2024
2 parents c356f46 + 5ab0082 commit 0de0157
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 38 deletions.
4 changes: 2 additions & 2 deletions addon/components/schedule-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export default class ScheduleManagerComponent extends Component {
});

this.modalsManager.show('modals/add-store-hours', {
title: this.intl.t('storefront.component.schedule-manager.add-new-hours-for-day', { Day: day }),
acceptButtonText: this.intl.t('storefront.component.schedule-manager-add-hours'),
title: this.intl.t('storefront.component.schedule-manager.add-new-hours-for-day', { day: day }),
acceptButtonText: this.intl.t('storefront.component.schedule-manager.add-hours'),
acceptButtonIcon: 'save',
hours,
confirm: (modal) => {
Expand Down
7 changes: 7 additions & 0 deletions addon/controllers/networks/index/network/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ export default class NetworksIndexNetworkIndexController extends Controller {
*/
@service intl;

/**
* Store service to handle file uploads and other network requests.
*
* @property {Service} store
*/
@service store;

/**
* Proof of delivery methods.
*
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fleetbase/storefront-api",
"version": "0.3.1",
"version": "0.3.2",
"description": "Headless Commerce & Marketplace Extension for Fleetbase",
"keywords": [
"fleetbase-extension",
Expand All @@ -22,8 +22,8 @@
],
"require": {
"php": "^8.0",
"fleetbase/core-api": "^1.4.7",
"fleetbase/fleetops-api": "^0.4.13",
"fleetbase/core-api": "^1.4.9",
"fleetbase/fleetops-api": "^0.4.15",
"geocoder-php/google-maps-places-provider": "^1.4",
"laravel-notification-channels/apn": "^5.0",
"laravel-notification-channels/fcm": "^4.1",
Expand Down
2 changes: 1 addition & 1 deletion extension.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Storefront",
"version": "0.3.1",
"version": "0.3.2",
"description": "Headless Commerce & Marketplace Extension for Fleetbase",
"repository": "https://github.com/fleetbase/storefront",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fleetbase/storefront-engine",
"version": "0.3.1",
"version": "0.3.2",
"description": "Headless Commerce & Marketplace Extension for Fleetbase",
"fleetbase": {
"route": "storefront",
Expand Down
10 changes: 6 additions & 4 deletions server/src/Expansions/EntityExpansion.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace Fleetbase\Storefront\Expansions;

use Fleetbase\Build\Expansion;
use Fleetbase\FleetOps\Models\Entity;
use Fleetbase\Storefront\Models\Product;

class EntityExpansion implements Expansion
{
Expand All @@ -13,18 +15,18 @@ class EntityExpansion implements Expansion
*/
public static function target()
{
return \Fleetbase\FleetOps\Models\Entity::class;
return Entity::class;
}

/**
* Create a new Entity from a Storefront Product.
*
* @return \Fleetbase\FleetOps\Models\Entity
* @return Entity
*/
public function fromStorefrontProduct()
{
return static function (\Fleetbase\Storefront\Models\Product $product) {
return new static([
return static function (Product $product) {
return new Entity([
'company_uuid' => session('company'),
'photo_uuid' => $product->primary_image_uuid,
'internal_id' => $product->public_id,
Expand Down
38 changes: 15 additions & 23 deletions server/src/Http/Controllers/v1/CheckoutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Fleetbase\Storefront\Http\Requests\InitializeCheckoutRequest;
use Fleetbase\Storefront\Models\Cart;
use Fleetbase\Storefront\Models\Checkout;
use Fleetbase\Storefront\Models\Customer;
use Fleetbase\Storefront\Models\Gateway;
use Fleetbase\Storefront\Models\Product;
use Fleetbase\Storefront\Models\Store;
Expand Down Expand Up @@ -53,7 +54,7 @@ public function beforeCheckout(InitializeCheckoutRequest $request)
// find and validate cart session
$cart = Cart::retrieve($cartId);
$gateway = Storefront::findGateway($gatewayCode);
$customer = Contact::findFromCustomerId($customerId);
$customer = Customer::findFromCustomerId($customerId);
$serviceQuote = ServiceQuote::select(['amount', 'meta', 'uuid', 'public_id'])->where('public_id', $serviceQuoteId)->first();

// handle cash orders
Expand Down Expand Up @@ -113,7 +114,7 @@ public static function initializeCashCheckout(Contact $customer, Gateway $gatewa
'gateway_uuid' => $gateway->uuid ?? null,
'service_quote_uuid' => $serviceQuote->uuid,
'owner_uuid' => $customer->uuid,
'owner_type' => 'contact',
'owner_type' => 'fleet-ops:contact',
'amount' => $amount,
'currency' => $currency,
'is_cod' => true,
Expand Down Expand Up @@ -187,7 +188,7 @@ public static function initializeStripeCheckout(Contact $customer, Gateway $gate
'gateway_uuid' => $gateway->uuid,
'service_quote_uuid' => $serviceQuote->uuid,
'owner_uuid' => $customer->uuid,
'owner_type' => 'contact',
'owner_type' => 'fleet-ops:contact',
'amount' => $amount,
'currency' => $currency,
'is_pickup' => $isPickup,
Expand Down Expand Up @@ -249,7 +250,7 @@ public static function initializeQpayCheckout(Contact $customer, Gateway $gatewa
'gateway_uuid' => $gateway->uuid,
'service_quote_uuid' => $serviceQuote->uuid,
'owner_uuid' => $customer->uuid,
'owner_type' => 'contact',
'owner_type' => 'fleet-ops:contact',
'amount' => $amount,
'currency' => $currency,
'is_pickup' => $isPickup,
Expand Down Expand Up @@ -345,7 +346,7 @@ public function captureOrder(CaptureOrderRequest $request)
$transaction = Transaction::create([
'company_uuid' => session('company'),
'customer_uuid' => $customer->uuid,
'customer_type' => 'contact',
'customer_type' => Utils::getMutationType('fleet-ops:contact'),
'gateway_transaction_id' => Utils::or($transactionDetails, ['id', 'transaction_id']) ?? Transaction::generateNumber(),
'gateway' => $gateway->code,
'gateway_uuid' => $gateway->uuid,
Expand Down Expand Up @@ -458,18 +459,7 @@ public function captureOrder(CaptureOrderRequest $request)
// create entities
foreach ($cart->items as $cartItem) {
$product = Product::where('public_id', $cartItem->product_id)->first();
$entity = Entity::fromStorefrontProduct($product)->fill([
'company_uuid' => session('company'),
'payload_uuid' => $payload->uuid,
'customer_uuid' => $customer->uuid,
'customer_type' => 'contact',
])->setMetas([
'variants' => $cartItem->variants,
'addons' => $cartItem->addons,
'subtotal' => $cartItem->subtotal,
'quantity' => $cartItem->quantity,
'scheduled_at' => $cartItem->scheduled_at ?? null,
]);
$entity = Entity::fromStorefrontProduct($product);

$entity->save();
}
Expand Down Expand Up @@ -505,7 +495,7 @@ public function captureOrder(CaptureOrderRequest $request)
'company_uuid' => $store->company_uuid ?? session('company'),
'payload_uuid' => $payload->uuid,
'customer_uuid' => $customer->uuid,
'customer_type' => 'contact',
'customer_type' => Utils::getMutationType('fleet-ops:contact'),
'transaction_uuid' => $transaction->uuid,
'adhoc' => $about->isOption('auto_dispatch'),
'type' => 'storefront',
Expand All @@ -525,6 +515,8 @@ public function captureOrder(CaptureOrderRequest $request)
// create order
$order = Order::create($orderInput);

info('Order created', $order->toArray());

// notify order creation
Storefront::alertNewOrder($order);

Expand Down Expand Up @@ -610,7 +602,7 @@ public function captureMultipleOrders(CaptureOrderRequest $request)
$transaction = Transaction::create([
'company_uuid' => session('company'),
'customer_uuid' => $customer->uuid,
'customer_type' => 'contact',
'customer_type' => Utils::getMutationType('fleet-ops:contact'),
'gateway_transaction_id' => Utils::or($transactionDetails, ['id', 'transaction_id']) ?? Transaction::generateNumber(),
'gateway' => $gateway->code,
'gateway_uuid' => $gateway->uuid,
Expand Down Expand Up @@ -706,7 +698,7 @@ public function captureMultipleOrders(CaptureOrderRequest $request)
'company_uuid' => $store->company_uuid,
'payload_uuid' => $payload->uuid,
'customer_uuid' => $customer->uuid,
'customer_type' => 'contact',
'customer_type' => Utils::getMutationType('fleet-ops:contact'),
])->setMetas([
'variants' => $cartItem->variants,
'addons' => $cartItem->addons,
Expand Down Expand Up @@ -746,7 +738,7 @@ public function captureMultipleOrders(CaptureOrderRequest $request)
'company_uuid' => $store->company_uuid,
'payload_uuid' => $payload->uuid,
'customer_uuid' => $customer->uuid,
'customer_type' => 'contact',
'customer_type' => Utils::getMutationType('fleet-ops:contact'),
'transaction_uuid' => $transaction->uuid,
'adhoc' => $about->isOption('auto_dispatch'),
'type' => 'storefront',
Expand Down Expand Up @@ -811,7 +803,7 @@ public function captureMultipleOrders(CaptureOrderRequest $request)
'company_uuid' => session('company'),
'payload_uuid' => $payload->uuid,
'customer_uuid' => $customer->uuid,
'customer_type' => 'contact',
'customer_type' => Utils::getMutationType('fleet-ops:contact'),
])->setMetas([
'variants' => $cartItem->variants,
'addons' => $cartItem->addons,
Expand Down Expand Up @@ -849,7 +841,7 @@ public function captureMultipleOrders(CaptureOrderRequest $request)
'company_uuid' => session('company'),
'payload_uuid' => $payload->uuid,
'customer_uuid' => $customer->uuid,
'customer_type' => 'contact',
'customer_type' => Utils::getMutationType('fleet-ops:contact'),
'transaction_uuid' => $transaction->uuid,
'adhoc' => $about->isOption('auto_dispatch'),
'type' => 'storefront',
Expand Down
4 changes: 2 additions & 2 deletions server/src/Models/Checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace Fleetbase\Storefront\Models;

use Fleetbase\Casts\Json;
use Fleetbase\FleetOps\Support\Utils;
use Fleetbase\FleetOps\Models\ServiceQuote;
use Fleetbase\Models\Company;
use Fleetbase\Models\ServiceQuote;
use Fleetbase\Support\Utils;
use Fleetbase\Traits\HasOptionsAttributes;
use Fleetbase\Traits\HasPublicid;
use Fleetbase\Traits\HasUuid;
Expand Down
2 changes: 2 additions & 0 deletions server/src/Models/StoreLocation.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Fleetbase\Storefront\Models;

use Fleetbase\FleetOps\Models\Place;
use Fleetbase\LaravelMysqlSpatial\Eloquent\SpatialTrait;
use Fleetbase\Models\User;
use Fleetbase\Traits\HasApiModelBehavior;
use Fleetbase\Traits\HasPublicid;
Expand All @@ -13,6 +14,7 @@ class StoreLocation extends StorefrontModel
use HasUuid;
use HasPublicid;
use HasApiModelBehavior;
use SpatialTrait;

/**
* The type of public Id to generate.
Expand Down
4 changes: 2 additions & 2 deletions server/src/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function ($router) {
// storefront/v1/checkouts
$router->group(['prefix' => 'checkouts'], function () use ($router) {
$router->get('before', 'CheckoutController@beforeCheckout');
$router->get('capture', 'CheckoutController@captureOrder');
$router->post('capture', 'CheckoutController@captureOrder');
});

// storefront/v1/service-quotes
Expand Down Expand Up @@ -105,7 +105,7 @@ function ($router) {
*/
$router->prefix(config('storefront.api.routing.internal_prefix', 'int'))->group(
function ($router) {
$router->group(['prefix' => 'int/v1', 'middleware' => ['internal.cors']], function () use ($router) {
$router->group(['prefix' => 'v1'], function () use ($router) {
$router->get('networks/find/{id}', 'NetworkController@findNetwork');
});

Expand Down

0 comments on commit 0de0157

Please sign in to comment.