Skip to content

Commit

Permalink
Merge pull request #290 from Pinelab-studio/fix/low-stock-widget
Browse files Browse the repository at this point in the history
Fix Low Stock Widget Bug
  • Loading branch information
martijnvdbrug authored Nov 9, 2023
2 parents 91269e3 + ae689eb commit fb6d83c
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 40 deletions.
5 changes: 5 additions & 0 deletions packages/vendure-plugin-stock-monitoring/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 1.3.0 (2023-11-09)

- Fixed `reduceSum` function call bug
- Made `StockWidgetComponent` standalone and removed `StockWidgetSharedModule` and `StockWidgetModule`

# 1.2.0 (2023-10-26)

- Fix broken links as described [here](https://github.com/Pinelab-studio/pinelab-vendure-plugins/issues/277)
Expand Down
2 changes: 1 addition & 1 deletion packages/vendure-plugin-stock-monitoring/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pinelab/vendure-plugin-stock-monitoring",
"version": "1.2.0",
"version": "1.3.0",
"description": "Vendure plugin for monitoring stock levels through a widget or by email",
"author": "Martijn van de Brug <[email protected]>",
"homepage": "https://pinelab-plugins.com/",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,7 @@ export interface StockMonitoringPlugin {
export class StockMonitoringPlugin {
static ui: AdminUiExtension = {
extensionPath: path.join(__dirname, 'ui'),
ngModules: [
{
type: 'shared',
ngModuleFileName: 'stock-widget.shared-module.ts',
ngModuleName: 'StockWidgetSharedModule',
},
],
providers: ['providers.ts'],
};
static threshold = 10;
static init(options: StockMonitoringPlugin): typeof StockMonitoringPlugin {
Expand Down
18 changes: 18 additions & 0 deletions packages/vendure-plugin-stock-monitoring/src/ui/providers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import {
registerDashboardWidget,
setDashboardWidgetLayout,
} from '@vendure/admin-ui/core';
export default [
registerDashboardWidget('stock-levels', {
title: 'Low stock',
supportedWidths: [4, 6, 8, 12],
loadComponent: () =>
import('./stock-widget').then((m) => m.StockWidgetComponent),
}),
setDashboardWidgetLayout([
{ id: 'welcome', width: 12 },
{ id: 'orderSummary', width: 6 },
{ id: 'reviews', width: 6 },
{ id: 'latestOrders', width: 12 },
]),
];

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { Observable } from 'rxjs';
import gql from 'graphql-tag';

@Component({
standalone: true,
imports: [SharedModule],
selector: 'stock-widget',
template: `
<vdr-data-table [items]="variant$ | async" class="stock-widget-overflow">
Expand Down Expand Up @@ -63,13 +65,7 @@ export class StockWidgetComponent implements OnInit {
)
.mapStream((data) => (data as any).productVariantsWithLowStock);
}
}

@NgModule({
imports: [SharedModule],
declarations: [StockWidgetComponent],
})
export class StockWidgetModule {
reduceSum(stockLevels: any[]): number {
return stockLevels.reduce((acc, val) => (acc += val.stockOnHand), 0);
}
Expand Down

0 comments on commit fb6d83c

Please sign in to comment.