@homefile/components-v2 2.36.19 → 2.36.20

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.
@@ -2,12 +2,15 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { t } from 'i18next';
3
3
  import { Checkbox, Flex, Stack, Image, Text } from '@chakra-ui/react';
4
4
  import { getReceiptOrigin } from '../../helpers';
5
- import { formatCurrency, formatDateWithAt } from '../../utils';
5
+ import { formatCurrency, formatDateWithAt, toQuantity } from '../../utils';
6
6
  export const AssignableReceiptCard = ({ isChecked, itemQuantity = 1, onChange, purchaseDate = new Date(), origin = '', total = '0', }) => {
7
7
  const date = formatDateWithAt({ date: purchaseDate });
8
- const totalFormatted = formatCurrency({ value: total });
9
- const totalItems = Number(itemQuantity) > 1
10
- ? `${itemQuantity} ${t('receipts.items')}`
11
- : `${itemQuantity} ${t('receipts.item')}`;
12
- return (_jsxs(Flex, { bg: "lightBlue.2", gap: "4", borderTop: "1px solid", borderColor: "lightBlue.2", children: [_jsx(Checkbox, { isChecked: isChecked, onChange: onChange }), _jsx(Stack, { w: "100%", p: "base", bg: isChecked ? 'lightGreen.1' : 'neutral.white', spacing: "1", children: _jsxs(Flex, { align: "center", gap: "base", children: [_jsx(Image, { src: getReceiptOrigin(origin), w: "auto", h: ["40px", "69px"], fit: "contain" }), _jsxs(Stack, { w: "100%", spacing: "1", children: [_jsx(Text, { fontSize: "xxs", children: date }), _jsx(Text, { textTransform: "capitalize", children: `${origin} ${t('receipts.receipt')}` }), _jsxs(Flex, { align: "baseline", justify: "flex-end", gap: "4", children: [_jsx(Text, { fontSize: "xs", fontFamily: "secondary", textTransform: "uppercase", children: totalItems }), _jsx(Text, { children: totalFormatted })] })] })] }) })] }));
8
+ const numericTotal = total !== null ? total.replace(/[^0-9.-]/g, "") : "";
9
+ const totalFormatted = formatCurrency({ value: numericTotal });
10
+ const originCheck = origin === null ? "" : origin;
11
+ const formatQtty = toQuantity(itemQuantity);
12
+ const totalItems = Number(formatQtty) > 1
13
+ ? `${formatQtty} ${t('receipts.items')}`
14
+ : `${formatQtty} ${t('receipts.item')}`;
15
+ return (_jsxs(Flex, { bg: "lightBlue.2", gap: "4", borderTop: "1px solid", borderColor: "lightBlue.2", children: [_jsx(Checkbox, { isChecked: isChecked, onChange: onChange }), _jsx(Stack, { w: "100%", p: "base", bg: isChecked ? 'lightGreen.1' : 'neutral.white', spacing: "1", children: _jsxs(Flex, { align: "center", gap: "base", children: [_jsx(Image, { src: getReceiptOrigin(originCheck), w: "auto", h: ["40px", "69px"], fit: "contain" }), _jsxs(Stack, { w: "100%", spacing: "1", children: [_jsx(Text, { fontSize: "xxs", children: date }), _jsx(Text, { textTransform: "capitalize", children: `${originCheck} ${t('receipts.receipt')}` }), _jsxs(Flex, { align: "baseline", justify: "flex-end", gap: "4", children: [_jsx(Text, { fontSize: "xs", fontFamily: "secondary", textTransform: "uppercase", children: totalItems }), _jsx(Text, { children: totalFormatted })] })] })] }) })] }));
13
16
  };
@@ -7,7 +7,7 @@ export const receiptOrigins = {
7
7
  "": DefaultReceipt
8
8
  };
9
9
  function normalize(input) {
10
- return input.trim().toLowerCase().replace(/['\s]+/g, '');
10
+ return input === null || input === undefined ? "" : input.trim().toLowerCase().replace(/['\s]+/g, '');
11
11
  }
12
12
  export const getReceiptOrigin = (key) => {
13
13
  var _a;
@@ -6,8 +6,9 @@ export declare const AssignableReceiptCardComponent: {
6
6
  (args: AssignableReceiptCardI): import("react/jsx-runtime").JSX.Element;
7
7
  args: {
8
8
  _id: string;
9
- total: string;
10
- purchaseDate: Date;
11
- itemQuantity: number;
9
+ total: null;
10
+ purchaseDate: null;
11
+ itemQuantity: null;
12
+ origin: null;
12
13
  };
13
14
  };
@@ -10,7 +10,8 @@ export const AssignableReceiptCardComponent = (args) => {
10
10
  };
11
11
  AssignableReceiptCardComponent.args = {
12
12
  _id: '123',
13
- total: '120.45',
14
- purchaseDate: new Date(),
15
- itemQuantity: 10,
13
+ total: null,
14
+ purchaseDate: null,
15
+ itemQuantity: null,
16
+ origin: null
16
17
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homefile/components-v2",
3
- "version": "2.36.19",
3
+ "version": "2.36.20",
4
4
  "author": "Homefile",
5
5
  "license": "UNLICENSED",
6
6
  "typings": "dist/index.d.ts",