@homefile/components-v2 2.36.21 → 2.36.22

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,12 +1,14 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { t } from 'i18next';
3
3
  import { Box, Divider, Flex, IconButton, Image, Text } from '@chakra-ui/react';
4
- import { formatDate, toQuantity } from '../../../utils';
4
+ import { formatDate, toQuantity, formatCurrency } from '../../../utils';
5
5
  import { DetailsColumn, Edit, PdfButton } from '../../../components';
6
6
  import { getReceiptOrigin } from '../../../helpers';
7
7
  export const ReceiptDetails = ({ name, cashier = '', itemQuantity, paymentMethod, purchaseDate, tax, store, origin = "", storePhone = '', total, onEdit, onFileClick }) => {
8
8
  const quantity = toQuantity(itemQuantity);
9
9
  const storeImage = getReceiptOrigin(origin);
10
+ const numericTotal = total !== null && total !== undefined ? total.replace(/[^0-9.-]/g, "") : "";
11
+ const totalFormatted = formatCurrency({ value: numericTotal });
10
12
  const leftLabels = t('receipts.columnLeft').split(',');
11
13
  const rightLabels = t('receipts.columnRight').split(',');
12
14
  const leftColumn = [
@@ -16,11 +18,11 @@ export const ReceiptDetails = ({ name, cashier = '', itemQuantity, paymentMethod
16
18
  },
17
19
  {
18
20
  label: leftLabels[1],
19
- value: store,
21
+ value: store && store !== null ? store : "",
20
22
  },
21
23
  {
22
24
  label: leftLabels[3],
23
- value: cashier,
25
+ value: cashier && cashier !== null ? cashier : "",
24
26
  },
25
27
  ];
26
28
  const rightColumn = [
@@ -30,15 +32,15 @@ export const ReceiptDetails = ({ name, cashier = '', itemQuantity, paymentMethod
30
32
  },
31
33
  {
32
34
  label: rightLabels[1],
33
- value: tax,
35
+ value: tax && tax !== null ? tax : "",
34
36
  },
35
37
  {
36
38
  label: rightLabels[2],
37
- value: total,
39
+ value: totalFormatted,
38
40
  },
39
41
  {
40
42
  label: rightLabels[3],
41
- value: paymentMethod,
43
+ value: paymentMethod && paymentMethod !== null ? paymentMethod : "",
42
44
  },
43
45
  ];
44
46
  return (_jsxs(Box, { boxShadow: "md", minW: "108px", bg: "lightBlue.2", borderBottom: "1px solid", borderColor: "lightBlue.2", children: [onEdit && (_jsxs(Flex, { align: "center", justify: "space-between", p: "base", children: [_jsx(Text, { children: name }), _jsx(IconButton, { variant: "menuIconWithShadow", maxW: "fit-content", "aria-label": t('ariaLabels.edit'), p: "1", icon: _jsx(Edit, {}), onClick: onEdit })] })), _jsx(Box, { w: "100%", h: "10px", bg: "lightBlue.2", overflow: "hidden", position: "relative", children: _jsxs("svg", { width: "100%", height: "8", viewBox: "0 0 100 10", preserveAspectRatio: "none", style: { display: 'block', position: 'absolute', bottom: 0, left: 0 }, children: [_jsx("defs", { children: _jsx("pattern", { id: "triangle", width: "4", height: "10", patternUnits: "userSpaceOnUse", children: _jsx("polygon", { points: "0,10 2,0 4,10", fill: "white" }) }) }), _jsx("rect", { width: "100%", height: "10", fill: "url(#triangle)" })] }) }), _jsxs(Box, { bg: "neutral.white", px: "2", p: "base", children: [_jsxs(Flex, { align: "center", gap: "base", children: [_jsx(Image, { src: storeImage, w: "75px", h: "75px", fit: "cover" }), _jsxs(Flex, { align: "center", gap: "2", flex: "auto", children: [_jsx(DetailsColumn, { details: leftColumn }), _jsx(Divider, { orientation: "vertical", bg: "lightBlue.2", h: "63px", mr: "6" }), _jsx(DetailsColumn, { align: "right", details: rightColumn })] })] }), _jsx(Flex, { justifyContent: 'flex-end', pt: '.5rem', children: onFileClick && (_jsx(PdfButton, { onClick: onFileClick })) })] })] }));
@@ -5,16 +5,16 @@ export default _default;
5
5
  export declare const ReceiptDetailsComponent: {
6
6
  (args: ReceiptDetailsDBI): import("react/jsx-runtime").JSX.Element;
7
7
  args: {
8
- cashier: string;
8
+ cashier: null;
9
9
  itemQuantity: number;
10
- paymentMethod: string;
11
- purchaseDate: Date;
12
- tax: string;
13
- store: string;
14
- storePhone: string;
15
- name: string;
16
- origin: string;
17
- total: string;
10
+ paymentMethod: null;
11
+ purchaseDate: null;
12
+ tax: null;
13
+ store: null;
14
+ storePhone: null;
15
+ name: null;
16
+ origin: null;
17
+ total: null;
18
18
  onEdit: import("@storybook/addon-actions").HandlerFunction;
19
19
  onFileClick: () => void;
20
20
  };
@@ -10,16 +10,16 @@ export const ReceiptDetailsComponent = (args) => {
10
10
  return (_jsx(Box, { width: "30rem", p: "base", children: _jsx(ReceiptDetails, Object.assign({}, args)) }));
11
11
  };
12
12
  ReceiptDetailsComponent.args = {
13
- cashier: 'John Doe',
13
+ cashier: null,
14
14
  itemQuantity: 3,
15
- paymentMethod: 'Cash',
16
- purchaseDate: new Date(),
17
- tax: '0.5',
18
- store: '8418',
19
- storePhone: '1234567890',
20
- name: 'Home Depot',
21
- origin: "Home Depot",
22
- total: '41.65',
15
+ paymentMethod: null,
16
+ purchaseDate: null,
17
+ tax: null,
18
+ store: null,
19
+ storePhone: null,
20
+ name: null,
21
+ origin: null,
22
+ total: null,
23
23
  onEdit: action('onEdit'),
24
24
  onFileClick: () => { }
25
25
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homefile/components-v2",
3
- "version": "2.36.21",
3
+ "version": "2.36.22",
4
4
  "author": "Homefile",
5
5
  "license": "UNLICENSED",
6
6
  "typings": "dist/index.d.ts",