@homefile/components-v2 2.23.9 → 2.23.11

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,2 +1,4 @@
1
1
  import { ReceiptDetailsDBI } from '../../../interfaces';
2
- export declare const ReceiptDetails: ({ cashier, itemQuantity, paymentMethod, purchaseDate, tax, store, receiptOrigin, storePhone, total, }: ReceiptDetailsDBI) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const ReceiptDetails: ({ name, cashier, itemQuantity, paymentMethod, purchaseDate, tax, store, receiptOrigin, storePhone, total, onEdit, }: Partial<ReceiptDetailsDBI> & {
3
+ onEdit?: () => void;
4
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -1,10 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { t } from 'i18next';
3
- import { Box, Divider, Flex, Image } from '@chakra-ui/react';
3
+ import { Box, Divider, Flex, IconButton, Image, Text } from '@chakra-ui/react';
4
4
  import { formatDate } from '../../../utils';
5
- import { DetailsColumn } from '../..';
5
+ import { DetailsColumn, Edit } from '../..';
6
6
  import { receiptOrigins } from '../../../helpers';
7
- export const ReceiptDetails = ({ cashier = '', itemQuantity, paymentMethod, purchaseDate, tax, store, receiptOrigin = 'homeDepot', storePhone = '', total, }) => {
7
+ export const ReceiptDetails = ({ name, cashier = '', itemQuantity, paymentMethod, purchaseDate, tax, store, receiptOrigin = 'homeDepot', storePhone = '', total, onEdit, }) => {
8
8
  const storeImage = receiptOrigins[receiptOrigin];
9
9
  const leftLabels = t('receipts.columnLeft').split(',');
10
10
  const rightLabels = t('receipts.columnRight').split(',');
@@ -44,5 +44,5 @@ export const ReceiptDetails = ({ cashier = '', itemQuantity, paymentMethod, purc
44
44
  value: paymentMethod,
45
45
  },
46
46
  ];
47
- return (_jsxs(Box, { boxShadow: "md", minW: "108px", bg: "lightBlue.2", borderBottom: "1px solid", borderColor: "lightBlue.2", children: [_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)" })] }) }), _jsx(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 })] })] }) })] }));
47
+ 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)" })] }) }), _jsx(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 })] })] }) })] }));
48
48
  };
@@ -1,2 +1,2 @@
1
1
  import { ReceiptItemI } from '../../../interfaces';
2
- export declare const ReceiptItem: ({ icon, isChecked, itemPrice, onChange, onSelectedChange, total, quantity, sku, title, }: ReceiptItemI) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const ReceiptItem: ({ icon, isChecked, itemPrice, onChange, onSelectedChange, onEditClick, total, quantity, sku, title, }: ReceiptItemI) => import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Stack } from '@chakra-ui/react';
2
+ import { t } from 'i18next';
3
+ import { Flex, IconButton, Stack } from '@chakra-ui/react';
3
4
  import { Price } from '../../../assets/images';
4
- import { ReceiptItemBody, ReceiptItemContainer, ReceiptItemHeader, } from '../..';
5
- export const ReceiptItem = ({ icon = Price, isChecked, itemPrice, onChange, onSelectedChange = () => { }, total, quantity, sku, title, }) => {
6
- return (_jsx(ReceiptItemContainer, { isChecked: isChecked, onChange: onChange, children: _jsxs(Stack, { w: "100%", p: "base", bg: isChecked ? 'lightGreen.1' : 'neutral.white', spacing: "1", justify: "space-between", children: [_jsx(ReceiptItemHeader, { icon: icon, sku: sku, onSelectedChange: onSelectedChange, variant: "tertiary" }), _jsx(ReceiptItemBody, { itemPrice: itemPrice, quantity: quantity, title: title, total: total })] }) }));
5
+ import { Edit, ReceiptItemBody, ReceiptItemContainer, ReceiptItemHeader, } from '../..';
6
+ export const ReceiptItem = ({ icon = Price, isChecked, itemPrice, onChange, onSelectedChange = () => { }, onEditClick, total, quantity, sku, title, }) => {
7
+ return (_jsx(ReceiptItemContainer, { isChecked: isChecked, onChange: onChange, children: _jsxs(Stack, { w: "100%", p: "base", bg: isChecked ? 'lightGreen.1' : 'neutral.white', spacing: "1", justify: "space-between", children: [_jsxs(Flex, { align: "center", justify: "space-between", children: [_jsx(ReceiptItemHeader, { icon: icon, sku: sku, onSelectedChange: onSelectedChange, variant: "tertiary" }), onEditClick && (_jsx(IconButton, { variant: "menuIconWithShadow", maxW: "fit-content", "aria-label": t('ariaLabels.edit'), p: "1", icon: _jsx(Edit, {}), onClick: onEditClick }))] }), _jsx(ReceiptItemBody, { itemPrice: itemPrice, quantity: quantity, title: title, total: total })] }) }));
7
8
  };
@@ -1,2 +1,2 @@
1
1
  import { ReceiptItemsI } from '../../../interfaces';
2
- export declare const ReceiptItems: ({ isSelectDisabled, leftOptions, onItemSelectedChange, onLeftSelectChange, onReceiptSelectedChange, onRightSelectChange, onRoomClick, receipts, receiptOptions, rightOptions, title, variant, }: ReceiptItemsI) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const ReceiptItems: ({ isSelectDisabled, leftOptions, onItemSelectedChange, onLeftSelectChange, onReceiptSelectedChange, onRightSelectChange, onRoomClick, onEditReceipt, receipts, receiptOptions, rightOptions, title, variant, }: ReceiptItemsI) => import("react/jsx-runtime").JSX.Element;
@@ -3,13 +3,13 @@ import { t } from 'i18next';
3
3
  import { Flex, Checkbox, Text, Stack, Box } from '@chakra-ui/react';
4
4
  import { DoubleSelects, ReceiptItem, ReceiptItemAssigned } from '../..';
5
5
  import { useAssignableList } from '../../../hooks';
6
- export const ReceiptItems = ({ isSelectDisabled = true, leftOptions = [], onItemSelectedChange, onLeftSelectChange = () => null, onReceiptSelectedChange, onRightSelectChange = () => null, onRoomClick = () => null, receipts, receiptOptions, rightOptions = [], title = t('receipts.assign'), variant = 'secondary', }) => {
6
+ export const ReceiptItems = ({ isSelectDisabled = true, leftOptions = [], onItemSelectedChange, onLeftSelectChange = () => null, onReceiptSelectedChange, onRightSelectChange = () => null, onRoomClick = () => null, onEditReceipt, receipts, receiptOptions, rightOptions = [], title = t('receipts.assign'), variant = 'secondary', }) => {
7
7
  const { handleItemSelect, handleSelectAll, isItemSelected } = useAssignableList({
8
8
  onItemSelectedChange,
9
9
  items: receipts,
10
10
  });
11
11
  return (_jsxs(Box, { mb: "10rem", children: [_jsxs(Stack, { bg: "lightBlue.2", px: "4", pb: "base", pt: "2", children: [_jsx(Text, { textTransform: "uppercase", variant: "home", children: title }), _jsxs(Flex, { gap: "base", align: "center", children: [_jsx(Checkbox, { onChange: handleSelectAll }), _jsx(DoubleSelects, { isSelectDisabled: isSelectDisabled, leftOptions: leftOptions, rightOptions: rightOptions, onLeftSelectChange: onLeftSelectChange, onRightSelectChange: onRightSelectChange })] })] }), receipts.map((receipt) => {
12
12
  const hasRoomType = !!(receipt === null || receipt === void 0 ? void 0 : receipt.roomType);
13
- return (_jsxs(Box, { children: [!hasRoomType && (_jsx(ReceiptItem, Object.assign({ onChange: () => handleItemSelect(receipt._id), isChecked: isItemSelected(receipt._id), onSelectedChange: onReceiptSelectedChange, selectItems: receiptOptions, variant: variant }, receipt))), hasRoomType && (_jsx(ReceiptItemAssigned, Object.assign({ onChange: () => handleItemSelect(receipt._id), onRoomClick: onRoomClick, isChecked: isItemSelected(receipt._id), onSelectedChange: onReceiptSelectedChange, initialSelectValue: receiptOptions === null || receiptOptions === void 0 ? void 0 : receiptOptions[1], selectItems: receiptOptions, variant: variant }, receipt)))] }, receipt._id));
13
+ return (_jsxs(Box, { children: [!hasRoomType && (_jsx(ReceiptItem, Object.assign({ onChange: () => handleItemSelect(receipt._id), isChecked: isItemSelected(receipt._id), onSelectedChange: onReceiptSelectedChange, onEditClick: () => onEditReceipt === null || onEditReceipt === void 0 ? void 0 : onEditReceipt(receipt._id), selectItems: receiptOptions, variant: variant }, receipt))), hasRoomType && (_jsx(ReceiptItemAssigned, Object.assign({ onChange: () => handleItemSelect(receipt._id), onRoomClick: onRoomClick, isChecked: isItemSelected(receipt._id), onSelectedChange: onReceiptSelectedChange, initialSelectValue: receiptOptions === null || receiptOptions === void 0 ? void 0 : receiptOptions[1], selectItems: receiptOptions, variant: variant }, receipt)))] }, receipt._id));
14
14
  })] }));
15
15
  };
@@ -1,6 +1,6 @@
1
1
  interface DetailRowI {
2
- label: string;
3
- value: string | number | Date;
2
+ label?: string;
3
+ value?: string | number | Date;
4
4
  }
5
5
  export interface DetailsColumnI {
6
6
  align?: 'left' | 'right';
@@ -1,4 +1,4 @@
1
- import { SelectItemI } from "../..";
1
+ import { SelectItemI } from '../..';
2
2
  export interface ReceiptItemFeaturesI {
3
3
  description: string;
4
4
  icon?: string;
@@ -15,6 +15,7 @@ export type VariantTypes = 'secondary' | 'tertiary';
15
15
  export interface ReceiptItemI extends ReceiptItemFeaturesI {
16
16
  isChecked?: boolean;
17
17
  initialSelectValue?: string;
18
+ onEditClick?: () => void;
18
19
  onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
19
20
  onSelectedChange?: (value: string | SelectItemI) => void;
20
21
  onRoomClick?: (roomId: string) => void;
@@ -4,6 +4,7 @@ export interface ReceiptItemsI extends DoubleSelectsI {
4
4
  onItemSelectedChange: (_ids: string[]) => void;
5
5
  onReceiptSelectedChange?: (value: string | SelectItemI) => void;
6
6
  onRoomClick?: (roomId: string) => void;
7
+ onEditReceipt?: (receiptId: string) => void;
7
8
  receiptOptions?: string[];
8
9
  receipts: ReceiptItemFeaturesI[];
9
10
  title?: string;
@@ -12,6 +12,8 @@ export declare const ReceiptDetailsComponent: {
12
12
  tax: string;
13
13
  store: string;
14
14
  storePhone: string;
15
+ name: string;
15
16
  total: string;
17
+ onEdit: import("@storybook/addon-actions").HandlerFunction;
16
18
  };
17
19
  };
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { action } from '@storybook/addon-actions';
2
3
  import { Box } from '@chakra-ui/react';
3
4
  import { ReceiptDetails } from '../../../components';
4
5
  export default {
@@ -16,5 +17,7 @@ ReceiptDetailsComponent.args = {
16
17
  tax: '0.5',
17
18
  store: '8418',
18
19
  storePhone: '1234567890',
20
+ name: 'Home Depot',
19
21
  total: '41.65',
22
+ onEdit: action('onEdit'),
20
23
  };
@@ -6,6 +6,7 @@ export declare const ReceiptItemComponent: {
6
6
  (args: ReceiptItemI): import("react/jsx-runtime").JSX.Element;
7
7
  args: {
8
8
  onChange: import("@storybook/addon-actions").HandlerFunction;
9
+ onEditClick: import("@storybook/addon-actions").HandlerFunction;
9
10
  description: string;
10
11
  icon?: string;
11
12
  itemPrice: string;
@@ -10,4 +10,4 @@ export default {
10
10
  export const ReceiptItemComponent = (args) => {
11
11
  return (_jsx(Box, { width: ['full', '30rem'], p: "base", children: _jsx(ReceiptItem, Object.assign({}, args)) }));
12
12
  };
13
- ReceiptItemComponent.args = Object.assign(Object.assign({}, receiptList[0]), { onChange: action('onChange') });
13
+ ReceiptItemComponent.args = Object.assign(Object.assign({}, receiptList[0]), { onChange: action('onChange'), onEditClick: action('onEditClick') });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homefile/components-v2",
3
- "version": "2.23.9",
3
+ "version": "2.23.11",
4
4
  "author": "Homefile",
5
5
  "license": "UNLICENSED",
6
6
  "typings": "dist/index.d.ts",
@@ -1,12 +1,12 @@
1
1
  import { t } from 'i18next'
2
- import { Box, Divider, Flex, Image } from '@chakra-ui/react'
3
- import { ReceiptBg } from '@/assets/images'
2
+ import { Box, Divider, Flex, IconButton, Image, Text } from '@chakra-ui/react'
4
3
  import { formatDate } from '@/utils'
5
- import { DetailsColumn } from '@/components'
4
+ import { DetailsColumn, Edit } from '@/components'
6
5
  import { ColumnDetailsType, ReceiptDetailsDBI } from '@/interfaces'
7
6
  import { receiptOrigins } from '@/helpers'
8
7
 
9
8
  export const ReceiptDetails = ({
9
+ name,
10
10
  cashier = '',
11
11
  itemQuantity,
12
12
  paymentMethod,
@@ -16,11 +16,12 @@ export const ReceiptDetails = ({
16
16
  receiptOrigin = 'homeDepot',
17
17
  storePhone = '',
18
18
  total,
19
- }: ReceiptDetailsDBI) => {
19
+ onEdit,
20
+ }: Partial<ReceiptDetailsDBI> & { onEdit?: () => void }) => {
20
21
  const storeImage = receiptOrigins[receiptOrigin]
21
22
  const leftLabels = t('receipts.columnLeft').split(',')
22
23
  const rightLabels = t('receipts.columnRight').split(',')
23
- const leftColumn: ColumnDetailsType[] = [
24
+ const leftColumn: Partial<ColumnDetailsType>[] = [
24
25
  {
25
26
  label: leftLabels[0],
26
27
  value: formatDate({ date: purchaseDate }).replace(' ', ' @ '),
@@ -39,7 +40,7 @@ export const ReceiptDetails = ({
39
40
  },
40
41
  ]
41
42
 
42
- const rightColumn: ColumnDetailsType[] = [
43
+ const rightColumn: Partial<ColumnDetailsType>[] = [
43
44
  {
44
45
  label: rightLabels[0],
45
46
  value: itemQuantity,
@@ -65,6 +66,19 @@ export const ReceiptDetails = ({
65
66
  borderBottom="1px solid"
66
67
  borderColor="lightBlue.2"
67
68
  >
69
+ {onEdit && (
70
+ <Flex align="center" justify="space-between" p="base">
71
+ <Text>{name}</Text>
72
+ <IconButton
73
+ variant="menuIconWithShadow"
74
+ maxW="fit-content"
75
+ aria-label={t('ariaLabels.edit')}
76
+ p="1"
77
+ icon={<Edit />}
78
+ onClick={onEdit}
79
+ />
80
+ </Flex>
81
+ )}
68
82
  <Box
69
83
  w="100%"
70
84
  h="10px"
@@ -1,7 +1,9 @@
1
- import { Stack } from '@chakra-ui/react'
1
+ import { t } from 'i18next'
2
+ import { Flex, IconButton, Stack } from '@chakra-ui/react'
2
3
  import { ReceiptItemI } from '@/interfaces'
3
4
  import { Price } from '@/assets/images'
4
5
  import {
6
+ Edit,
5
7
  ReceiptItemBody,
6
8
  ReceiptItemContainer,
7
9
  ReceiptItemHeader,
@@ -13,6 +15,7 @@ export const ReceiptItem = ({
13
15
  itemPrice,
14
16
  onChange,
15
17
  onSelectedChange = () => {},
18
+ onEditClick,
16
19
  total,
17
20
  quantity,
18
21
  sku,
@@ -27,12 +30,24 @@ export const ReceiptItem = ({
27
30
  spacing="1"
28
31
  justify="space-between"
29
32
  >
30
- <ReceiptItemHeader
31
- icon={icon}
32
- sku={sku}
33
- onSelectedChange={onSelectedChange}
34
- variant="tertiary"
35
- />
33
+ <Flex align="center" justify="space-between">
34
+ <ReceiptItemHeader
35
+ icon={icon}
36
+ sku={sku}
37
+ onSelectedChange={onSelectedChange}
38
+ variant="tertiary"
39
+ />
40
+ {onEditClick && (
41
+ <IconButton
42
+ variant="menuIconWithShadow"
43
+ maxW="fit-content"
44
+ aria-label={t('ariaLabels.edit')}
45
+ p="1"
46
+ icon={<Edit />}
47
+ onClick={onEditClick}
48
+ />
49
+ )}
50
+ </Flex>
36
51
  <ReceiptItemBody
37
52
  itemPrice={itemPrice}
38
53
  quantity={quantity}
@@ -12,6 +12,7 @@ export const ReceiptItems = ({
12
12
  onReceiptSelectedChange,
13
13
  onRightSelectChange = () => null,
14
14
  onRoomClick = () => null,
15
+ onEditReceipt,
15
16
  receipts,
16
17
  receiptOptions,
17
18
  rightOptions = [],
@@ -50,6 +51,7 @@ export const ReceiptItems = ({
50
51
  onChange={() => handleItemSelect(receipt._id)}
51
52
  isChecked={isItemSelected(receipt._id)}
52
53
  onSelectedChange={onReceiptSelectedChange}
54
+ onEditClick={() => onEditReceipt?.(receipt._id)}
53
55
  selectItems={receiptOptions}
54
56
  variant={variant}
55
57
  {...receipt}
@@ -1,6 +1,6 @@
1
1
  interface DetailRowI {
2
- label: string
3
- value: string | number | Date
2
+ label?: string
3
+ value?: string | number | Date
4
4
  }
5
5
 
6
6
  export interface DetailsColumnI {
@@ -1,4 +1,4 @@
1
- import { SelectItemI } from "@/interfaces"
1
+ import { SelectItemI } from '@/interfaces'
2
2
 
3
3
  export interface ReceiptItemFeaturesI {
4
4
  description: string
@@ -18,6 +18,7 @@ export type VariantTypes = 'secondary' | 'tertiary'
18
18
  export interface ReceiptItemI extends ReceiptItemFeaturesI {
19
19
  isChecked?: boolean
20
20
  initialSelectValue?: string
21
+ onEditClick?: () => void
21
22
  onChange: (event: React.ChangeEvent<HTMLInputElement>) => void
22
23
  onSelectedChange?: (value: string | SelectItemI) => void
23
24
  onRoomClick?: (roomId: string) => void
@@ -5,6 +5,7 @@ export interface ReceiptItemsI extends DoubleSelectsI {
5
5
  onItemSelectedChange: (_ids: string[]) => void
6
6
  onReceiptSelectedChange?: (value: string | SelectItemI) => void
7
7
  onRoomClick?: (roomId: string) => void
8
+ onEditReceipt?: (receiptId: string) => void
8
9
  receiptOptions?: string[]
9
10
  receipts: ReceiptItemFeaturesI[]
10
11
  title?: string
@@ -1,4 +1,5 @@
1
1
  import { Meta } from '@storybook/react'
2
+ import { action } from '@storybook/addon-actions'
2
3
  import { Box } from '@chakra-ui/react'
3
4
  import { ReceiptDetails } from '@/components'
4
5
  import { ReceiptDetailsDBI } from '@/interfaces'
@@ -24,5 +25,7 @@ ReceiptDetailsComponent.args = {
24
25
  tax: '0.5',
25
26
  store: '8418',
26
27
  storePhone: '1234567890',
28
+ name: 'Home Depot',
27
29
  total: '41.65',
30
+ onEdit: action('onEdit'),
28
31
  }
@@ -21,4 +21,5 @@ export const ReceiptItemComponent = (args: ReceiptItemI) => {
21
21
  ReceiptItemComponent.args = {
22
22
  ...receiptList[0],
23
23
  onChange: action('onChange'),
24
+ onEditClick: action('onEditClick'),
24
25
  }