@open-tender/utils 0.4.96 → 0.4.98
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CartItem, CartLevels } from '@open-tender/types';
|
|
2
|
-
export declare const useBuilder: (orderItem: CartItem) => {
|
|
2
|
+
export declare const useBuilder: (orderItem: CartItem, orderTimeoutCallback?: () => void) => {
|
|
3
3
|
item: CartItem;
|
|
4
4
|
increment: () => void;
|
|
5
5
|
decrement: () => void;
|
|
@@ -3,8 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useBuilder = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
|
-
const useBuilder = (orderItem) => {
|
|
6
|
+
const useBuilder = (orderItem, orderTimeoutCallback) => {
|
|
7
7
|
const [item, setItem] = (0, react_1.useState)(orderItem);
|
|
8
|
+
(0, react_1.useEffect)(() => {
|
|
9
|
+
orderTimeoutCallback && orderTimeoutCallback();
|
|
10
|
+
}, [item, orderTimeoutCallback]);
|
|
8
11
|
const increment = () => {
|
|
9
12
|
const newQuantity = item.max
|
|
10
13
|
? Math.min(item.quantity + item.increment, item.max)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CartItem, CartLevels } from '@open-tender/types';
|
|
2
|
-
export declare const useBuilder: (orderItem: CartItem) => {
|
|
2
|
+
export declare const useBuilder: (orderItem: CartItem, orderTimeoutCallback?: () => void) => {
|
|
3
3
|
item: CartItem;
|
|
4
4
|
increment: () => void;
|
|
5
5
|
decrement: () => void;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
2
|
import { calcPrices } from '../utils';
|
|
3
|
-
export const useBuilder = (orderItem) => {
|
|
3
|
+
export const useBuilder = (orderItem, orderTimeoutCallback) => {
|
|
4
4
|
const [item, setItem] = useState(orderItem);
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
orderTimeoutCallback && orderTimeoutCallback();
|
|
7
|
+
}, [item, orderTimeoutCallback]);
|
|
5
8
|
const increment = () => {
|
|
6
9
|
const newQuantity = item.max
|
|
7
10
|
? Math.min(item.quantity + item.increment, item.max)
|
package/package.json
CHANGED