@homefile/components-v2 2.23.2 → 2.23.4
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.
- package/dist/components/householdItems/ItemNameHeader.d.ts +1 -1
- package/dist/components/householdItems/ItemNameHeader.js +2 -2
- package/dist/components/receipts/receipt/ReceiptItem.js +2 -1
- package/dist/components/receipts/receipt/ReceiptItemAssigned.js +2 -1
- package/dist/interfaces/headers/ItemNameHeader.interface.d.ts +1 -0
- package/dist/stories/receipts/receipt/AddReceiptPanel.stories.js +45 -3
- package/package.json +1 -1
- package/src/components/householdItems/ItemNameHeader.tsx +2 -1
- package/src/components/receipts/receipt/ReceiptItem.tsx +2 -1
- package/src/components/receipts/receipt/ReceiptItemAssigned.tsx +2 -1
- package/src/interfaces/headers/ItemNameHeader.interface.ts +1 -0
- package/src/stories/receipts/receipt/AddReceiptPanel.stories.tsx +50 -14
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ItemNameHeaderI } from '../../interfaces';
|
|
2
|
-
export declare const ItemNameHeader: ({ id, value, onSave, onValueChange, padding, }: ItemNameHeaderI) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const ItemNameHeader: ({ id, value, onSave, onValueChange, padding, required, }: ItemNameHeaderI) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -4,7 +4,7 @@ import { Box, Flex, Button } from '@chakra-ui/react';
|
|
|
4
4
|
import { TextInput } from '..';
|
|
5
5
|
import { isEmptyField } from '../../utils';
|
|
6
6
|
import { useState, useEffect } from 'react';
|
|
7
|
-
export const ItemNameHeader = ({ id = '', value = '', onSave, onValueChange, padding = 'base', }) => {
|
|
7
|
+
export const ItemNameHeader = ({ id = '', value = '', onSave, onValueChange, padding = 'base', required = true, }) => {
|
|
8
8
|
const [name, setName] = useState(value);
|
|
9
9
|
useEffect(() => {
|
|
10
10
|
setName(value);
|
|
@@ -13,5 +13,5 @@ export const ItemNameHeader = ({ id = '', value = '', onSave, onValueChange, pad
|
|
|
13
13
|
setName(e.target.value);
|
|
14
14
|
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(e.target.value);
|
|
15
15
|
};
|
|
16
|
-
return (_jsx(Box, { bg: "lightBlue.2", p: padding, w: "100%", children: _jsxs(Flex, { gap: "base", align: "center", children: [_jsx(TextInput, { errorMessage: `${t('householdItems.headers.itemName')} ${t('forms.required')}`, hasError: isEmptyField(name), id: id, handleChange: handleChange, placeholder: t('householdItems.headers.placeholder'), value: name }), name && (_jsx(Button, { variant: "secondary", maxW: "fit-content", maxH: "input.md", onClick: () => onSave(name), children: t('createDocument.buttons.save') }))] }) }));
|
|
16
|
+
return (_jsx(Box, { bg: "lightBlue.2", p: padding, w: "100%", children: _jsxs(Flex, { gap: "base", align: "center", children: [_jsx(TextInput, { errorMessage: `${t('householdItems.headers.itemName')} ${t('forms.required')}`, hasError: required && isEmptyField(name), id: id, handleChange: handleChange, placeholder: t('householdItems.headers.placeholder'), value: name }), name && (_jsx(Button, { variant: "secondary", maxW: "fit-content", maxH: "input.md", onClick: () => onSave(name), children: t('createDocument.buttons.save') }))] }) }));
|
|
17
17
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Stack } from '@chakra-ui/react';
|
|
3
|
+
import { Price } from '../../../assets/images';
|
|
3
4
|
import { ReceiptItemBody, ReceiptItemContainer, ReceiptItemHeader, } from '../..';
|
|
4
|
-
export const ReceiptItem = ({ icon, isChecked, itemPrice, onChange, onSelectedChange = () => { }, total, quantity, sku, title, }) => {
|
|
5
|
+
export const ReceiptItem = ({ icon = Price, isChecked, itemPrice, onChange, onSelectedChange = () => { }, total, quantity, sku, title, }) => {
|
|
5
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 })] }) }));
|
|
6
7
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Flex, Stack } from '@chakra-ui/react';
|
|
3
|
+
import { Price } from '../../../assets/images';
|
|
3
4
|
import { Overlay, ReceiptItemBody, ReceiptItemContainer, ReceiptItemHeader, ReceiptRoom, } from '../..';
|
|
4
|
-
export const ReceiptItemAssigned = ({ icon, isChecked, itemPrice, onChange, onSelectedChange = () => { }, onRoomClick = () => { }, total, quantity, roomId = '', roomType, sku, title, variant = 'secondary', }) => {
|
|
5
|
+
export const ReceiptItemAssigned = ({ icon = Price, isChecked, itemPrice, onChange, onSelectedChange = () => { }, onRoomClick = () => { }, total, quantity, roomId = '', roomType, sku, title, variant = 'secondary', }) => {
|
|
5
6
|
return (_jsx(ReceiptItemContainer, { isChecked: isChecked, onChange: onChange, children: _jsxs(Flex, { flex: "auto", children: [roomType && (_jsx(ReceiptRoom, { roomType: roomType, roomId: roomId, onClick: onRoomClick })), _jsxs(Stack, { p: "base", bg: "lightGreen.1", spacing: "1", justify: "space-between", position: "relative", flex: "1", children: [!isChecked && (_jsx(Overlay, { position: "absolute", w: "inherit", h: "inherit", bg: "#F0F8F080" })), _jsx(ReceiptItemHeader, { icon: icon, sku: sku, onSelectedChange: onSelectedChange, variant: variant }), _jsx(ReceiptItemBody, { isTitleItalic: !isChecked, itemPrice: itemPrice, quantity: quantity, title: title, total: total })] })] }) }));
|
|
6
7
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { action } from '@storybook/addon-actions';
|
|
3
3
|
import { RightPanel, ReceiptContent, ReceiptItems, ReceiptDetails, TabsHeader, PdfButton, PanelHeader, DynamicForm, EditItemName, ReceiptBody, SearchItemLoader, FooterButtons, FooterDrawer, } from '../../../components';
|
|
4
|
-
import { receiptList } from '../../../helpers';
|
|
5
4
|
import { Register } from '../../../assets/images';
|
|
6
5
|
import { receiptFieldsMock } from '../../../mocks';
|
|
7
6
|
import { useState } from 'react';
|
|
@@ -35,10 +34,10 @@ function StepOne({ onSave }) {
|
|
|
35
34
|
} }) }) })] }));
|
|
36
35
|
}
|
|
37
36
|
function StepThree() {
|
|
38
|
-
return (_jsxs(_Fragment, { children: [_jsxs(ReceiptBody, { children: [_jsx(ReceiptDetails, {
|
|
37
|
+
return (_jsxs(_Fragment, { children: [_jsxs(ReceiptBody, { children: [_jsx(ReceiptDetails, Object.assign({}, receiptSchemaMock.receipt, { purchaseDate: new Date(receiptSchemaMock.receipt.purchaseDate) })), _jsx(TabsHeader, { rightButton: _jsx(PdfButton, { onClick: action('Pdf click') }), tabList: [
|
|
39
38
|
{
|
|
40
39
|
label: 'Items',
|
|
41
|
-
component: (_jsx(ReceiptItems, { isSelectDisabled: true, receipts:
|
|
40
|
+
component: (_jsx(ReceiptItems, { isSelectDisabled: true, receipts: receiptSchemaMock.receipt.items, leftOptions: receiptSchemaMock.options.leftOptions, rightOptions: receiptSchemaMock.options.rightOptions, receiptOptions: receiptSchemaMock.options.receiptOptions, onItemSelectedChange: action('onItemSelectedChange'), onLeftSelectChange: action('onLeftSelectChange'), onReceiptSelectedChange: action('onReceiptSelectedChange'), onRightSelectChange: action('onRightSelectChange') })),
|
|
42
41
|
},
|
|
43
42
|
{
|
|
44
43
|
label: 'Notes',
|
|
@@ -54,3 +53,46 @@ function StepThree() {
|
|
|
54
53
|
onClick: action('onConfirm'),
|
|
55
54
|
} }) }) })] }));
|
|
56
55
|
}
|
|
56
|
+
const receiptSchemaMock = {
|
|
57
|
+
receipt: {
|
|
58
|
+
_id: '1',
|
|
59
|
+
name: 'Receipt for Palmgain Palm Fertilizer',
|
|
60
|
+
cashier: 'Rochelle',
|
|
61
|
+
itemQuantity: 4,
|
|
62
|
+
paymentMethod: 'Debit',
|
|
63
|
+
purchaseDate: '2024-06-18T00:00:00.000Z',
|
|
64
|
+
tax: '3.17',
|
|
65
|
+
store: '8418',
|
|
66
|
+
storePhone: '512.258.7914',
|
|
67
|
+
total: '41.65',
|
|
68
|
+
items: [
|
|
69
|
+
{
|
|
70
|
+
description: 'Palmgain Palm Fertilizer 10LB',
|
|
71
|
+
title: 'Palmgain Palm Fertilizer 10LB Palmgain Palm Fertilizer 10LB',
|
|
72
|
+
itemPrice: '1.99',
|
|
73
|
+
total: '31.99',
|
|
74
|
+
quantity: 1,
|
|
75
|
+
sku: '1234567890',
|
|
76
|
+
_id: '1',
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
description: 'Palmgain Palm Fertilizer 10LB',
|
|
80
|
+
title: 'Palmgain Palm Fertilizer 10LB',
|
|
81
|
+
itemPrice: '4.99',
|
|
82
|
+
total: '33.99',
|
|
83
|
+
quantity: 1,
|
|
84
|
+
roomType: 'living_room',
|
|
85
|
+
roomId: 'room-1',
|
|
86
|
+
sku: '1234567890',
|
|
87
|
+
_id: '2',
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
notes: '',
|
|
91
|
+
pdfUrl: 'https://url-do-pdf.com/receipt.pdf',
|
|
92
|
+
},
|
|
93
|
+
options: {
|
|
94
|
+
leftOptions: ['Project', 'Room', 'Folder'],
|
|
95
|
+
rightOptions: ['Kitchen', 'Landscape', 'Bedroom'],
|
|
96
|
+
receiptOptions: ['unassigned', 'inventory', 'incidentals'],
|
|
97
|
+
},
|
|
98
|
+
};
|
package/package.json
CHANGED
|
@@ -11,6 +11,7 @@ export const ItemNameHeader = ({
|
|
|
11
11
|
onSave,
|
|
12
12
|
onValueChange,
|
|
13
13
|
padding = 'base',
|
|
14
|
+
required = true,
|
|
14
15
|
}: ItemNameHeaderI) => {
|
|
15
16
|
const [name, setName] = useState(value)
|
|
16
17
|
|
|
@@ -29,7 +30,7 @@ export const ItemNameHeader = ({
|
|
|
29
30
|
errorMessage={`${t('householdItems.headers.itemName')} ${t(
|
|
30
31
|
'forms.required'
|
|
31
32
|
)}`}
|
|
32
|
-
hasError={isEmptyField(name)}
|
|
33
|
+
hasError={required && isEmptyField(name)}
|
|
33
34
|
id={id}
|
|
34
35
|
handleChange={handleChange}
|
|
35
36
|
placeholder={t('householdItems.headers.placeholder')}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Stack } from '@chakra-ui/react'
|
|
2
2
|
import { ReceiptItemI } from '@/interfaces'
|
|
3
|
+
import { Price } from '@/assets/images'
|
|
3
4
|
import {
|
|
4
5
|
ReceiptItemBody,
|
|
5
6
|
ReceiptItemContainer,
|
|
@@ -7,7 +8,7 @@ import {
|
|
|
7
8
|
} from '@/components'
|
|
8
9
|
|
|
9
10
|
export const ReceiptItem = ({
|
|
10
|
-
icon,
|
|
11
|
+
icon = Price,
|
|
11
12
|
isChecked,
|
|
12
13
|
itemPrice,
|
|
13
14
|
onChange,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Flex, Stack } from '@chakra-ui/react'
|
|
2
2
|
import { ReceiptItemI } from '@/interfaces'
|
|
3
|
+
import { Price } from '@/assets/images'
|
|
3
4
|
import {
|
|
4
5
|
Overlay,
|
|
5
6
|
ReceiptItemBody,
|
|
@@ -9,7 +10,7 @@ import {
|
|
|
9
10
|
} from '@/components'
|
|
10
11
|
|
|
11
12
|
export const ReceiptItemAssigned = ({
|
|
12
|
-
icon,
|
|
13
|
+
icon = Price,
|
|
13
14
|
isChecked,
|
|
14
15
|
itemPrice,
|
|
15
16
|
onChange,
|
|
@@ -15,7 +15,6 @@ import {
|
|
|
15
15
|
FooterButtons,
|
|
16
16
|
FooterDrawer,
|
|
17
17
|
} from '@/components'
|
|
18
|
-
import { receiptList } from '@/helpers'
|
|
19
18
|
import { Register } from '@/assets/images'
|
|
20
19
|
import { ReceiptContentI } from '@/interfaces'
|
|
21
20
|
import { receiptFieldsMock } from '@/mocks'
|
|
@@ -102,15 +101,8 @@ function StepThree() {
|
|
|
102
101
|
<>
|
|
103
102
|
<ReceiptBody>
|
|
104
103
|
<ReceiptDetails
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
itemQuantity={4}
|
|
108
|
-
paymentMethod="Debit"
|
|
109
|
-
purchaseDate={new Date()}
|
|
110
|
-
tax="3.17"
|
|
111
|
-
store="8418"
|
|
112
|
-
storePhone="512.258.7914"
|
|
113
|
-
total="41.65"
|
|
104
|
+
{...receiptSchemaMock.receipt}
|
|
105
|
+
purchaseDate={new Date(receiptSchemaMock.receipt.purchaseDate)}
|
|
114
106
|
/>
|
|
115
107
|
|
|
116
108
|
<TabsHeader
|
|
@@ -121,10 +113,10 @@ function StepThree() {
|
|
|
121
113
|
component: (
|
|
122
114
|
<ReceiptItems
|
|
123
115
|
isSelectDisabled={true}
|
|
124
|
-
receipts={
|
|
125
|
-
leftOptions={
|
|
126
|
-
rightOptions={
|
|
127
|
-
receiptOptions={
|
|
116
|
+
receipts={receiptSchemaMock.receipt.items}
|
|
117
|
+
leftOptions={receiptSchemaMock.options.leftOptions}
|
|
118
|
+
rightOptions={receiptSchemaMock.options.rightOptions}
|
|
119
|
+
receiptOptions={receiptSchemaMock.options.receiptOptions}
|
|
128
120
|
onItemSelectedChange={action('onItemSelectedChange')}
|
|
129
121
|
onLeftSelectChange={action('onLeftSelectChange')}
|
|
130
122
|
onReceiptSelectedChange={action('onReceiptSelectedChange')}
|
|
@@ -158,3 +150,47 @@ function StepThree() {
|
|
|
158
150
|
</>
|
|
159
151
|
)
|
|
160
152
|
}
|
|
153
|
+
|
|
154
|
+
const receiptSchemaMock = {
|
|
155
|
+
receipt: {
|
|
156
|
+
_id: '1',
|
|
157
|
+
name: 'Receipt for Palmgain Palm Fertilizer',
|
|
158
|
+
cashier: 'Rochelle',
|
|
159
|
+
itemQuantity: 4,
|
|
160
|
+
paymentMethod: 'Debit',
|
|
161
|
+
purchaseDate: '2024-06-18T00:00:00.000Z',
|
|
162
|
+
tax: '3.17',
|
|
163
|
+
store: '8418',
|
|
164
|
+
storePhone: '512.258.7914',
|
|
165
|
+
total: '41.65',
|
|
166
|
+
items: [
|
|
167
|
+
{
|
|
168
|
+
description: 'Palmgain Palm Fertilizer 10LB',
|
|
169
|
+
title: 'Palmgain Palm Fertilizer 10LB Palmgain Palm Fertilizer 10LB',
|
|
170
|
+
itemPrice: '1.99',
|
|
171
|
+
total: '31.99',
|
|
172
|
+
quantity: 1,
|
|
173
|
+
sku: '1234567890',
|
|
174
|
+
_id: '1',
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
description: 'Palmgain Palm Fertilizer 10LB',
|
|
178
|
+
title: 'Palmgain Palm Fertilizer 10LB',
|
|
179
|
+
itemPrice: '4.99',
|
|
180
|
+
total: '33.99',
|
|
181
|
+
quantity: 1,
|
|
182
|
+
roomType: 'living_room',
|
|
183
|
+
roomId: 'room-1',
|
|
184
|
+
sku: '1234567890',
|
|
185
|
+
_id: '2',
|
|
186
|
+
},
|
|
187
|
+
],
|
|
188
|
+
notes: '',
|
|
189
|
+
pdfUrl: 'https://url-do-pdf.com/receipt.pdf',
|
|
190
|
+
},
|
|
191
|
+
options: {
|
|
192
|
+
leftOptions: ['Project', 'Room', 'Folder'],
|
|
193
|
+
rightOptions: ['Kitchen', 'Landscape', 'Bedroom'],
|
|
194
|
+
receiptOptions: ['unassigned', 'inventory', 'incidentals'],
|
|
195
|
+
},
|
|
196
|
+
}
|