Skip to content

Commit ce62a1b

Browse files
committed
adding default folder, addressing nits
1 parent a049f51 commit ce62a1b

File tree

8 files changed

+44
-56
lines changed

8 files changed

+44
-56
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{%- if flavor contains "vanilla-js" -%}
2+
// @ts-check
3+
4+
/**
5+
* @typedef {import("../generated/api").InputQuery} InputQuery
6+
* @typedef {import("../generated/api").FunctionResult} FunctionResult
7+
*/
8+
9+
export default /**
10+
* @param {InputQuery} input
11+
* @returns {FunctionResult}
12+
*/
13+
(input) => {
14+
const errors = input.cart.lines
15+
.filter(({ quantity }) => quantity > 1)
16+
.map(() => ({
17+
localizedMessage: "Not possible to order more than one of each",
18+
target: "cart",
19+
}));
20+
21+
return {
22+
errors
23+
}
24+
};
25+
{%- elsif flavor contains "typescript" -%}
26+
import {
27+
InputQuery,
28+
FunctionResult,
29+
FunctionError,
30+
} from "../generated/api";
31+
32+
export default (input: InputQuery): FunctionResult => {
33+
const errors: FunctionError[] = input.cart.lines
34+
.filter(({ quantity }) => quantity > 1)
35+
.map(() => ({
36+
localizedMessage: "Not possible to order more than one of each",
37+
target: "cart",
38+
}));
39+
40+
return {
41+
errors
42+
}
43+
};
44+
{%- endif -%}

checkout/javascript/cart-checkout-validation/src/index.liquid

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)