Skip to content

Commit

Permalink
fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanieg467 committed Aug 6, 2024
1 parent 23bbfee commit 6db2857
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
1 change: 0 additions & 1 deletion components/cart/CartItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {apiClient} from '../../lib/api';
import {addPromise} from '../../redux/reducers/xhr';
import {RootState} from '../../redux/store';
import debounce from 'lodash/debounce';
import _cloneDeep from 'lodash/cloneDeep';
import CartRow from './CartRow';
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
import {faShoppingCart} from '@fortawesome/free-solid-svg-icons/faShoppingCart';
Expand Down
10 changes: 4 additions & 6 deletions components/cart/CartRow.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import {ICartItem} from 'boundless-api-client';
import Link from 'next/link';
import {getCartImg} from '../../lib/imgs';
import {getProductUrl} from '../../lib/urls';
import NoImage from '../NoImage';
import {TThumbRatio} from 'boundless-api-client';
import {calcTotalPrice} from '../../lib/calculator';
import useFormatCurrency from '../../hooks/useFormatCurrency';
import { IUseCartItems } from '../../hooks/cart';
import {IUseCartItems} from '../../hooks/cart';

export default function CartRow({item, rmItem, onQtyChange}: ICartRowProps) {
const {formatCurrency} = useFormatCurrency();
Expand Down Expand Up @@ -46,17 +45,16 @@ export default function CartRow({item, rmItem, onQtyChange}: ICartRowProps) {
className='btn btn-outline-secondary text-center'
type='button'
style={{width: 25}}
// disabled={item.qty < 2}
onClick={() => {
if (item.qty === 1) {
// Split items will have an originalQty in which case we don't want to remove the entire item.
if (item?.originalQty) {
onQtyChange(item.originalQty - 1)
onQtyChange(item.originalQty - 1);
} else {
rmItem()
rmItem();
}
} else {
onQtyChange(item?.originalQty ? item.originalQty - 1 : item.qty - 1)
onQtyChange(item?.originalQty ? item.originalQty - 1 : item.qty - 1);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/calculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import currency from 'currency.js';
import {find} from 'lodash';
import _cloneDeep from 'lodash/cloneDeep';
import {apiClient} from './api';
import { IUseCartItems } from '../hooks/cart';
import {IUseCartItems} from '../hooks/cart';

export const calcTotal = (items: ICalcTotalItem[]) => {
let totalQty = 0;
Expand Down
8 changes: 4 additions & 4 deletions lib/splitOrderByThcGrams.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import _cloneDeep from 'lodash/cloneDeep';
import {IUseCartItems} from '../hooks/cart';
import { splitItemByQty } from './calculator';
import {splitItemByQty} from './calculator';

const splitOrderByThcGrams = (props: {
items: IUseCartItems[];
Expand All @@ -20,7 +20,7 @@ const splitOrderByThcGrams = (props: {
let currentOrder: IUseCartItems[] = currentThcTotal > 30 ? [] : [firstItem];

const processSplitItem = (item: IUseCartItems, thcTotal?: number): void => {
currentThcTotal = thcTotal ?? currentThcTotal
currentThcTotal = thcTotal ?? currentThcTotal;
const itemThcGramsTotal = item?.thcGrams ? item?.thcGrams * item.qty : 0;

if (currentThcTotal + itemThcGramsTotal <= 30) {
Expand All @@ -32,7 +32,7 @@ const splitOrderByThcGrams = (props: {
currentOrder = [item];
currentThcTotal = itemThcGramsTotal;
}
}
};

// If the first item's THC grams total exceeds the limit, split the item into multiple orders.
if (currentThcTotal > 30) {
Expand Down Expand Up @@ -60,7 +60,7 @@ const splitOrderByThcGrams = (props: {
});
}
else {
processSplitItem(item)
processSplitItem(item);
}
}
});
Expand Down

0 comments on commit 6db2857

Please sign in to comment.