@final-commerce/command-frame 0.7.0-staging.10 → 0.7.0-staging.11
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.
|
@@ -5,6 +5,12 @@ export const mockGetProducts = async (params) => {
|
|
|
5
5
|
// Simple filter simulation
|
|
6
6
|
let products = MOCK_PRODUCTS;
|
|
7
7
|
const query = params?.query || {};
|
|
8
|
+
// Same rule as the real host: a bookable service is not catalogue stock and is left out unless
|
|
9
|
+
// the query names `productType`. Mirrored here on purpose — a mock that hands back services the
|
|
10
|
+
// device withholds is how a flow gets built around a grid that cannot exist.
|
|
11
|
+
if (!JSON.stringify(query).includes('productType')) {
|
|
12
|
+
products = products.filter((p) => p.productType !== 'booking');
|
|
13
|
+
}
|
|
8
14
|
if (query.searchValue) {
|
|
9
15
|
const search = String(query.searchValue).toLowerCase();
|
|
10
16
|
products = products.filter((p) => p.name.toLowerCase().includes(search) || p.sku?.toLowerCase().includes(search));
|
|
@@ -1,6 +1,21 @@
|
|
|
1
|
-
import { CFProduct } from
|
|
1
|
+
import { CFProduct } from '../../CommonTypes';
|
|
2
2
|
export interface GetProductsParams {
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* MongoDB-like query object.
|
|
5
|
+
*
|
|
6
|
+
* BOOKABLE SERVICES ARE EXCLUDED unless this query mentions `productType`. A service is not
|
|
7
|
+
* catalogue stock: it is sold by claiming a time with `addBookingToCart`, and
|
|
8
|
+
* `addProductToCart` refuses it. Returned by default it appeared in ordinary product grids,
|
|
9
|
+
* where the obvious gesture took the money and reserved nothing.
|
|
10
|
+
*
|
|
11
|
+
* Ask for them explicitly when the user actually wants services — a "Book" tab, a services
|
|
12
|
+
* screen, a search across everything:
|
|
13
|
+
*
|
|
14
|
+
* getProducts({ query: { productType: 'booking' } }) // services only
|
|
15
|
+
* getProducts({ query: { productType: { $in: ['simple', 'variable', 'booking'] } } }) // both
|
|
16
|
+
*
|
|
17
|
+
* Any query naming `productType` is used exactly as written.
|
|
18
|
+
*/
|
|
4
19
|
query?: {
|
|
5
20
|
name?: string | {
|
|
6
21
|
$regex?: string;
|
|
@@ -11,7 +26,14 @@ export interface GetProductsParams {
|
|
|
11
26
|
$options?: string;
|
|
12
27
|
};
|
|
13
28
|
status?: string;
|
|
14
|
-
|
|
29
|
+
/**
|
|
30
|
+
* `simple` | `variable` | `booking`. Naming it at all switches OFF the default exclusion
|
|
31
|
+
* of bookable services — including `{ $ne: 'booking' }`, which then means what it says.
|
|
32
|
+
*/
|
|
33
|
+
productType?: string | {
|
|
34
|
+
$in?: string[];
|
|
35
|
+
$ne?: string;
|
|
36
|
+
};
|
|
15
37
|
categories?: string | {
|
|
16
38
|
$in?: string[];
|
|
17
39
|
};
|