@fleetbase/storefront-engine 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -89,7 +89,7 @@ export default class NetworksIndexNetworkIndexController extends Controller {
89
89
  this.model
90
90
  .save()
91
91
  .then(() => {
92
- this.notifications.success(this.intl.t('storefront.controllers.networks.index.change-network-saved'));
92
+ this.notifications.success(this.intl.t('storefront.networks.index.network.index.change-network-saved'));
93
93
  })
94
94
  .catch((error) => {
95
95
  this.notifications.serverError(error);
@@ -140,10 +140,10 @@ export default class ProductsIndexCategoryNewController extends BaseController {
140
140
 
141
141
  @action makePrimaryFile(file) {
142
142
  if (file.isNotImage) {
143
- return this.notifications.warning(this.intl.t('storefront.products.index.category.new.warning-only-select-an-image-file-to-be-primary'));
143
+ return this.notifications.warning(this.intl.t('storefront.products.index.new.warning-only-select-an-image-file-to-be-primary'));
144
144
  }
145
145
 
146
- this.notifications.success(this.intl.t('storefront.products.index.category.new.made-the-primary-success-image', { fileName: file.original_filename }));
146
+ this.notifications.success(this.intl.t('storefront.products.index.new.made-the-primary-success-image', { fileName: file.original_filename }));
147
147
  this.product.primary_image_uuid = file.id;
148
148
  this.product.primary_image_url = file.url;
149
149
  this.product.primary_image = file;
@@ -183,7 +183,10 @@
183
183
  }}</span>
184
184
  </Toggle>
185
185
  {{#if @model.options.require_pod}}
186
- <InputGroup @wrapperClass="mb-0 mt-2" @name={{t "storefront.networks.index.network.index.general-network-settings-form.config-switches.proof-of-delivery-method"}}>
186
+ <InputGroup
187
+ @wrapperClass="mb-0 mt-2"
188
+ @name={{t "storefront.networks.index.network.index.general-network-settings-form.config-switches.proof-of-delivery-method-label"}}
189
+ >
187
190
  <Select
188
191
  @options={{this.podMethods}}
189
192
  @optionValue="value"
@@ -15,7 +15,7 @@
15
15
  </div>
16
16
  </div>
17
17
 
18
- {{#each this.gateways as |gateway|}}
18
+ {{#each this.model as |gateway|}}
19
19
  <ContentPanel @title={{gateway.name}} @open={{true}} @pad={{true}}>
20
20
  <InputGroup @name={{t "storefront.settings.gateways.gateway-name"}} @value={{gateway.name}} @helpText={{t "storefront.settings.gateways.helpText"}} />
21
21
  <InputGroup @name={{t "storefront.settings.gateways.gateway-code"}} @value={{gateway.code}} @disabled={{true}} @helpText={{t "storefront.settings.gateways.gateway-code-help-text"}} />
package/composer.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetbase/storefront-api",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Headless Commerce & Marketplace Extension for Fleetbase",
5
5
  "keywords": [
6
6
  "fleetbase-extension",
@@ -22,8 +22,8 @@
22
22
  ],
23
23
  "require": {
24
24
  "php": "^8.0",
25
- "fleetbase/core-api": "^1.4.3",
26
- "fleetbase/fleetops-api": "^0.4.9",
25
+ "fleetbase/core-api": "^1.4.7",
26
+ "fleetbase/fleetops-api": "^0.4.13",
27
27
  "geocoder-php/google-maps-places-provider": "^1.4",
28
28
  "laravel-notification-channels/apn": "^5.0",
29
29
  "laravel-notification-channels/fcm": "^4.1",
package/extension.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "Storefront",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Headless Commerce & Marketplace Extension for Fleetbase",
5
5
  "repository": "https://github.com/fleetbase/storefront",
6
6
  "license": "MIT",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fleetbase/storefront-engine",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Headless Commerce & Marketplace Extension for Fleetbase",
5
5
  "fleetbase": {
6
6
  "route": "storefront",
@@ -44,8 +44,8 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@fleetbase/ember-core": "^0.2.4",
47
- "@fleetbase/ember-ui": "^0.2.10",
48
- "@fleetbase/fleetops-data": "^0.1.8",
47
+ "@fleetbase/ember-ui": "^0.2.11",
48
+ "@fleetbase/fleetops-data": "^0.1.9",
49
49
  "@babel/core": "^7.23.2",
50
50
  "@fortawesome/ember-fontawesome": "^0.4.1",
51
51
  "@fortawesome/fontawesome-svg-core": "^6.4.0",
@@ -15,7 +15,7 @@ class CartController extends Controller
15
15
  *
16
16
  * @return \Illuminate\Http\Response
17
17
  */
18
- public function retrieve(?string $uniqueId = null, Request $request)
18
+ public function retrieve(string $uniqueId = null, Request $request)
19
19
  {
20
20
  $cart = Cart::retrieve($uniqueId, true);
21
21
 
@@ -462,7 +462,7 @@ class CustomerController extends Controller
462
462
  /**
463
463
  * Patches phone number with international code.
464
464
  */
465
- public static function phone(?string $phone = null): string
465
+ public static function phone(string $phone = null): string
466
466
  {
467
467
  if ($phone === null) {
468
468
  $phone = request()->input('phone');
@@ -109,7 +109,7 @@ class StoreController extends Controller
109
109
 
110
110
  // if cod is enabled add cash as a gateway
111
111
  if ($about->hasOption('cod_enabled')) {
112
- $gateways->push(Gateway::cash($sandbox));
112
+ $gateways->push(Gateway::cash(['sandbox'=>$sandbox]));
113
113
  }
114
114
 
115
115
  return GatewayResource::collection($gateways);
@@ -30,7 +30,7 @@ class Category extends FleetbaseResource
30
30
  ),
31
31
  'tags' => $this->tags ?? [],
32
32
  'translations' => $this->translations ?? [],
33
- 'products' => $this->when($request->has('with_products') || $request->inArray('with', 'products'), Product::collection($this->products)),
33
+ 'products' => $this->when($request->has('with_products') || $request->inArray('with', 'products'), $this->products ? Product::collection($this->products) : []),
34
34
  'subcategories' => $this->when(
35
35
  $request->has('with_subcategories') || $request->inArray('with', 'subcategories'),
36
36
  array_map(
@@ -55,7 +55,7 @@ class Product extends FleetbaseResource
55
55
  ];
56
56
  }
57
57
 
58
- public function mapHours(?\Illuminate\Database\Eloquent\Collection $hours = null): array
58
+ public function mapHours(\Illuminate\Database\Eloquent\Collection $hours = null): array
59
59
  {
60
60
  if (empty($hours)) {
61
61
  return [];
@@ -79,7 +79,7 @@ class Product extends FleetbaseResource
79
79
  );
80
80
  }
81
81
 
82
- public function mapFiles(?\Illuminate\Database\Eloquent\Collection $files = null, $contentType = 'image')
82
+ public function mapFiles(\Illuminate\Database\Eloquent\Collection $files = null, $contentType = 'image')
83
83
  {
84
84
  return collect($files)->map(function ($file) use ($contentType) {
85
85
  if (!Str::contains($file->content_type, $contentType)) {
@@ -90,7 +90,7 @@ class Product extends FleetbaseResource
90
90
  })->filter()->values();
91
91
  }
92
92
 
93
- public function mapAddonCategories(?\Illuminate\Database\Eloquent\Collection $addonCategories = null)
93
+ public function mapAddonCategories(\Illuminate\Database\Eloquent\Collection $addonCategories = null)
94
94
  {
95
95
  return collect($addonCategories)->map(function ($addonCategory) {
96
96
  $addons = data_get($addonCategory, 'category.addons', []);
@@ -120,7 +120,7 @@ class Product extends FleetbaseResource
120
120
  });
121
121
  }
122
122
 
123
- public function mapProductAddons(?\Illuminate\Database\Eloquent\Collection $addons = null, $excluded = [])
123
+ public function mapProductAddons(\Illuminate\Database\Eloquent\Collection $addons = null, $excluded = [])
124
124
  {
125
125
  return collect($addons)->map(function ($addon) use ($excluded) {
126
126
  if (is_array($excluded) && in_array($addon->uuid, $excluded)) {
@@ -157,7 +157,7 @@ class Product extends FleetbaseResource
157
157
  })->filter()->values();
158
158
  }
159
159
 
160
- public function mapVariants(?\Illuminate\Database\Eloquent\Collection $variants = null)
160
+ public function mapVariants(\Illuminate\Database\Eloquent\Collection $variants = null)
161
161
  {
162
162
  return collect($variants)->map(function ($variant) {
163
163
  $productVariantArr = [
@@ -25,37 +25,9 @@ class ReviewCustomer extends FleetbaseResource
25
25
  'email' => $this->email,
26
26
  'phone' => $this->phone,
27
27
  'photo_url' => $this->photo_url,
28
- 'reviews_count' => $this->getReviewsCount(),
29
- 'uploads_count' => $this->getUploadsCount(),
30
28
  'slug' => $this->slug,
31
29
  'created_at' => $this->created_at,
32
30
  'updated_at' => $this->updated_at,
33
31
  ];
34
32
  }
35
-
36
- public function getReviewsCount()
37
- {
38
- if (session('storefront_network')) {
39
- return $this->storeReviews()->whereHas('subject', function ($q) {
40
- $q->whereHas('networks', function ($q) {
41
- $q->where('network_uuid', session('storefront_network'));
42
- });
43
- })->count();
44
-
45
- // $productReviewsCount = $this->productReviews()->whereHas('subject', function ($q) {
46
- // $q->whereHas('store', function ($q) {
47
- // $q->whereHas('networks', function ($q) {
48
- // $q->where('network_uuid', session('storefront_network'));
49
- // });
50
- // });
51
- // })->count();
52
-
53
- // return $storeReviewsCount + $productReviewsCount;
54
- }
55
- }
56
-
57
- public function getUploadsCount()
58
- {
59
- return $this->reviewUploads()->count();
60
- }
61
33
  }
@@ -587,7 +587,7 @@ class Cart extends StorefrontModel
587
587
  *
588
588
  * @return \Fleetbase\Models\Storefront\Cart
589
589
  */
590
- public function updateCurrency(?string $currencyCode = null, $save = false)
590
+ public function updateCurrency(string $currencyCode = null, $save = false)
591
591
  {
592
592
  $this->attributes['currency'] = $currencyCode ?? session('storefront_currency');
593
593
 
@@ -220,7 +220,7 @@ class Network extends StorefrontModel
220
220
  /**
221
221
  * Adds a new store to the network.
222
222
  */
223
- public function addStore(Store $store, ?Category $category = null): NetworkStore
223
+ public function addStore(Store $store, Category $category = null): NetworkStore
224
224
  {
225
225
  return NetworkStore::updateOrCreate(
226
226
  [
@@ -241,7 +241,7 @@ class Network extends StorefrontModel
241
241
  * @param File|string|null $icon
242
242
  * @param string $iconColor
243
243
  */
244
- public function createCategory(string $name, string $description = '', ?array $meta = [], ?array $translations = [], ?Category $parent = null, $icon = null, $iconColor = '#000000'): Category
244
+ public function createCategory(string $name, string $description = '', ?array $meta = [], ?array $translations = [], Category $parent = null, $icon = null, $iconColor = '#000000'): Category
245
245
  {
246
246
  $iconFile = null;
247
247
  $iconName = null;
@@ -276,7 +276,7 @@ class Network extends StorefrontModel
276
276
  * @param File|string|null $icon
277
277
  * @param string $iconColor
278
278
  */
279
- public function createCategoryStrict(string $name, string $description = '', ?array $meta = [], ?array $translations = [], ?Category $parent = null, $icon = null, $iconColor = '#000000'): Category
279
+ public function createCategoryStrict(string $name, string $description = '', ?array $meta = [], ?array $translations = [], Category $parent = null, $icon = null, $iconColor = '#000000'): Category
280
280
  {
281
281
  $existingCategory = Category::where(['company_uuid' => $this->company_uuid, 'owner_uuid' => $this->uuid, 'name' => $name])->first();
282
282
 
@@ -360,7 +360,7 @@ class Store extends StorefrontModel
360
360
  * @param File|string|null $icon
361
361
  * @param string $iconColor
362
362
  */
363
- public function createCategory(string $name, string $description = '', ?array $meta = [], ?array $translations = [], ?Category $parent = null, $icon = null, $iconColor = '#000000'): Category
363
+ public function createCategory(string $name, string $description = '', ?array $meta = [], ?array $translations = [], Category $parent = null, $icon = null, $iconColor = '#000000'): Category
364
364
  {
365
365
  $iconFile = null;
366
366
  $iconName = null;
@@ -397,7 +397,7 @@ class Store extends StorefrontModel
397
397
  * @param File|string|null $icon
398
398
  * @param string $iconColor
399
399
  */
400
- public function createCategoryStrict(string $name, string $description = '', ?array $meta = [], ?array $translations = [], ?Category $parent = null, $icon = null, $iconColor = '#000000'): Category
400
+ public function createCategoryStrict(string $name, string $description = '', ?array $meta = [], ?array $translations = [], Category $parent = null, $icon = null, $iconColor = '#000000'): Category
401
401
  {
402
402
  $existingCategory = Category::where(['company_uuid' => $this->company_uuid, 'owner_uuid' => $this->uuid, 'name' => $name])->first();
403
403
 
@@ -411,7 +411,7 @@ class Store extends StorefrontModel
411
411
  /**
412
412
  * Creates a new product in the store.
413
413
  */
414
- public function createProduct(string $name, string $description, array $tags = [], ?Category $category = null, ?File $image = null, ?User $createdBy = null, string $sku = '', int $price = 0, string $status = 'available', array $options = []): Product
414
+ public function createProduct(string $name, string $description, array $tags = [], Category $category = null, File $image = null, User $createdBy = null, string $sku = '', int $price = 0, string $status = 'available', array $options = []): Product
415
415
  {
416
416
  return Product::create(
417
417
  [
@@ -438,7 +438,7 @@ class Store extends StorefrontModel
438
438
  );
439
439
  }
440
440
 
441
- public function createLocation($location, ?string $name = null, ?User $createdBy): ?StoreLocation
441
+ public function createLocation($location, string $name = null, ?User $createdBy): ?StoreLocation
442
442
  {
443
443
  $place = Place::createFromMixed($location);
444
444
 
@@ -96,6 +96,5 @@ class StorefrontServiceProvider extends CoreServiceProvider
96
96
  $this->mergeConfigFrom(__DIR__ . '/../../config/database.connections.php', 'database.connections');
97
97
  $this->mergeConfigFrom(__DIR__ . '/../../config/storefront.php', 'storefront');
98
98
  $this->mergeConfigFrom(__DIR__ . '/../../config/api.php', 'storefront.api');
99
- $this->mergeConfigFrom(__DIR__ . '/../../config/twilio-notification-channel.php', 'twilio-notification-channel');
100
99
  }
101
100
  }
@@ -23,7 +23,7 @@ class Metrics
23
23
  protected Company $company;
24
24
  protected array $metrics = [];
25
25
 
26
- public static function new(Company $company, ?\DateTime $start = null, ?\DateTime $end = null): Metrics
26
+ public static function new(Company $company, \DateTime $start = null, \DateTime $end = null): Metrics
27
27
  {
28
28
  $start = $start === null ? Carbon::create(1900)->toDateTime() : $start;
29
29
  $end = $end === null ? Carbon::tomorrow()->toDateTime() : $end;
@@ -31,7 +31,7 @@ class Metrics
31
31
  return (new static())->setCompany($company)->between($start, $end);
32
32
  }
33
33
 
34
- public static function forCompany(Company $company, ?\DateTime $start = null, ?\DateTime $end = null): Metrics
34
+ public static function forCompany(Company $company, \DateTime $start = null, \DateTime $end = null): Metrics
35
35
  {
36
36
  return static::new($company, $start, $end);
37
37
  }
@@ -104,7 +104,7 @@ class Metrics
104
104
  return $this;
105
105
  }
106
106
 
107
- public function totalProducts(?callable $callback = null): Metrics
107
+ public function totalProducts(callable $callback = null): Metrics
108
108
  {
109
109
  $query = Product::where('company_uuid', $this->company->uuid);
110
110
 
@@ -117,7 +117,7 @@ class Metrics
117
117
  return $this->set('total_products', $data);
118
118
  }
119
119
 
120
- public function totalStores(?callable $callback = null): Metrics
120
+ public function totalStores(callable $callback = null): Metrics
121
121
  {
122
122
  $query = Store::where('company_uuid', $this->company->uuid);
123
123
 
@@ -130,7 +130,7 @@ class Metrics
130
130
  return $this->set('total_stores', $data);
131
131
  }
132
132
 
133
- public function totalNetworks(?callable $callback = null): Metrics
133
+ public function totalNetworks(callable $callback = null): Metrics
134
134
  {
135
135
  $query = Network::where('company_uuid', $this->company->uuid);
136
136
 
@@ -143,7 +143,7 @@ class Metrics
143
143
  return $this->set('total_networks', $data);
144
144
  }
145
145
 
146
- public function ordersInProgress(?callable $callback = null): Metrics
146
+ public function ordersInProgress(callable $callback = null): Metrics
147
147
  {
148
148
  $query = Order::where('company_uuid', $this->company->uuid)
149
149
  ->whereBetween('created_at', [$this->start, $this->end])
@@ -159,7 +159,7 @@ class Metrics
159
159
  return $this->set('orders_in_progress', $data);
160
160
  }
161
161
 
162
- public function ordersCompleted(?callable $callback = null): Metrics
162
+ public function ordersCompleted(callable $callback = null): Metrics
163
163
  {
164
164
  $query = Order::where('company_uuid', $this->company->uuid)
165
165
  ->whereBetween('created_at', [$this->start, $this->end])
@@ -175,7 +175,7 @@ class Metrics
175
175
  return $this->set('orders_completed', $data);
176
176
  }
177
177
 
178
- public function ordersCanceled(?callable $callback = null): Metrics
178
+ public function ordersCanceled(callable $callback = null): Metrics
179
179
  {
180
180
  $query = Order::where('company_uuid', $this->company->uuid)
181
181
  ->whereBetween('created_at', [$this->start, $this->end])
@@ -12,7 +12,7 @@ class QPay
12
12
  private array $requestOptions = [];
13
13
  private Client $client;
14
14
 
15
- public function __construct(?string $username = null, ?string $password = null, ?string $callbackUrl = null)
15
+ public function __construct(string $username = null, string $password = null, string $callbackUrl = null)
16
16
  {
17
17
  $this->callbackUrl = $callbackUrl;
18
18
  $this->requestOptions = [
@@ -60,7 +60,7 @@ class QPay
60
60
  return $this;
61
61
  }
62
62
 
63
- public static function instance(?string $username = null, ?string $password = null, ?string $callbackUrl = null): QPay
63
+ public static function instance(string $username = null, string $password = null, string $callbackUrl = null): QPay
64
64
  {
65
65
  return new static($username, $password, $callbackUrl);
66
66
  }
@@ -120,7 +120,7 @@ class QPay
120
120
  return $this;
121
121
  }
122
122
 
123
- public function setAuthToken(?string $accessToken = null): QPay
123
+ public function setAuthToken(string $accessToken = null): QPay
124
124
  {
125
125
  if ($accessToken) {
126
126
  $this->useBearerToken($accessToken);
@@ -136,7 +136,7 @@ class QPay
136
136
  return $this;
137
137
  }
138
138
 
139
- public function createSimpleInvoice(int $amount, ?string $invoiceCode = '', ?string $invoiceDescription = '', ?string $invoiceReceiverCode = '', ?string $senderInvoiceNo = '', ?string $callbackUrl = null)
139
+ public function createSimpleInvoice(int $amount, ?string $invoiceCode = '', ?string $invoiceDescription = '', ?string $invoiceReceiverCode = '', ?string $senderInvoiceNo = '', string $callbackUrl = null)
140
140
  {
141
141
  if (!$callbackUrl && $this->hasCallbackUrl()) {
142
142
  $callbackUrl = $this->callbackUrl;
@@ -1,36 +0,0 @@
1
- <?php
2
-
3
- return [
4
- 'username' => env('TWILIO_USERNAME'), // optional when using auth token
5
- 'password' => env('TWILIO_PASSWORD'), // optional when using auth token
6
- 'auth_token' => env('TWILIO_TOKEN'), // optional when using username and password
7
- 'account_sid' => env('TWILIO_SID'),
8
-
9
- 'from' => env('TWILIO_FROM'), // optional
10
- 'alphanumeric_sender' => env('TWILIO_ALPHA_SENDER'),
11
-
12
- /**
13
- * See https://www.twilio.com/docs/sms/services.
14
- */
15
- 'sms_service_sid' => env('TWILIO_SMS_SERVICE_SID'),
16
-
17
- /**
18
- * Specify a number where all calls/messages should be routed. This can be used in development/staging environments
19
- * for testing.
20
- */
21
- 'debug_to' => env('TWILIO_DEBUG_TO'),
22
-
23
- /**
24
- * If an exception is thrown with one of these error codes, it will be caught & suppressed.
25
- * To replicate the 2.x behaviour, specify '*' in the array, which will cause all exceptions to be suppressed.
26
- * Suppressed errors will not be logged or reported, but the `NotificationFailed` event will be emitted.
27
- *
28
- * @see https://www.twilio.com/docs/api/errors
29
- */
30
- 'ignored_error_codes' => [
31
- 21608, // The 'to' phone number provided is not yet verified for this account.
32
- 21211, // Invalid 'To' Phone Number
33
- 21614, // 'To' number is not a valid mobile number
34
- 21408, // Permission to send an SMS has not been enabled for the region indicated by the 'To' number
35
- ],
36
- ];