@homefile/components-v2 2.36.16 → 2.36.18
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.
|
@@ -15,11 +15,13 @@ import { Box, Flex, Wrap } from '@chakra-ui/react';
|
|
|
15
15
|
import { ItemCard, GroupCardHeader, LeftButtonAnimated, AddItemCard, SearchInput, TileTooltip, } from '../../components';
|
|
16
16
|
import { handleMapMedia } from '../../utils';
|
|
17
17
|
import { useGroupCard } from '../../hooks';
|
|
18
|
-
import {
|
|
18
|
+
import { Group } from '../../assets/images';
|
|
19
|
+
import { getReceiptOrigin, GroupIcons } from '../../helpers';
|
|
19
20
|
const storageUrl = import.meta.env.VITE_STORAGE_URL;
|
|
20
21
|
export const GroupCard = (_a) => {
|
|
21
22
|
var { items, menuItems, onAddItem, onAddImage, onClickDelete, onClickDetails, title, totalAmount, disabled, itemsDisabled } = _a, props = __rest(_a, ["items", "menuItems", "onAddItem", "onAddImage", "onClickDelete", "onClickDetails", "title", "totalAmount", "disabled", "itemsDisabled"]);
|
|
22
23
|
const { filteredResults, handleAddItem, handleChange, isItemsEmpty, searchValue, totalAmountFormatted, } = useGroupCard({ items, onAddItem, title, totalAmount });
|
|
24
|
+
const groupTitle = title;
|
|
23
25
|
return (_jsx(TileTooltip, { label: title, children: _jsxs(Box, { backgroundColor: "lightBlue.1", boxShadow: "base", w: "100%", children: [_jsx(GroupCardHeader, { menuItems: menuItems, title: title, totalAmount: totalAmountFormatted }), _jsxs(Flex, { justify: items.length >= 10 ? 'space-between' : 'flex-end', pl: "base", my: "base", align: "center", gap: "base", children: [items.length >= 10 && (_jsx(SearchInput, { value: searchValue, onChange: handleChange })), _jsx(LeftButtonAnimated, { onClick: handleAddItem, label: t('addHomeItem.btnLabel'), disabled: disabled, id: "addingItems" })] }), _jsxs(Box, { pb: "10", px: "base", children: [isItemsEmpty && _jsx(AddItemCard, { disabled: itemsDisabled, onClick: handleAddItem }), !isItemsEmpty && (_jsx(Wrap, { spacing: "base", children: filteredResults.map(({ _id, title, report, images, receipt, metadata, type, subType, room, }) => {
|
|
24
26
|
var _a, _b, _c, _d;
|
|
25
27
|
const reportData = {
|
|
@@ -38,6 +40,8 @@ export const GroupCard = (_a) => {
|
|
|
38
40
|
const storeImage = (metadata === null || metadata === void 0 ? void 0 : metadata.origin)
|
|
39
41
|
? getReceiptOrigin(metadata === null || metadata === void 0 ? void 0 : metadata.origin)
|
|
40
42
|
: '';
|
|
43
|
+
const existingImage = hasImage ? imageUrl : storeImage;
|
|
44
|
+
const groupImage = GroupIcons[groupTitle] || Group;
|
|
41
45
|
const handleImage = (files) => {
|
|
42
46
|
if (files) {
|
|
43
47
|
const fileMapped = handleMapMedia({
|
|
@@ -47,6 +51,6 @@ export const GroupCard = (_a) => {
|
|
|
47
51
|
onAddImage(fileMapped);
|
|
48
52
|
}
|
|
49
53
|
};
|
|
50
|
-
return (_jsx(ItemCard, Object.assign({ brandLabel: String(brand), imageUrl:
|
|
54
|
+
return (_jsx(ItemCard, Object.assign({ brandLabel: String(brand), imageUrl: existingImage ? existingImage : groupImage, onAddImage: handleImage, onClickDelete: onClickDelete, onClickDetails: onClickDetails, disabled: itemsDisabled }, props, reportData), _id));
|
|
51
55
|
}) }))] })] }) }));
|
|
52
56
|
};
|
|
@@ -2,7 +2,8 @@ import { formatCurrency } from '../../utils';
|
|
|
2
2
|
export const useDisplayReceipts = ({ receipts }) => {
|
|
3
3
|
const formattedReceipts = receipts.map((receipt) => {
|
|
4
4
|
const { total } = receipt;
|
|
5
|
-
const
|
|
5
|
+
const numericTotal = total.replace(/[^0-9.-]/g, "");
|
|
6
|
+
const totalFormatted = formatCurrency({ value: numericTotal });
|
|
6
7
|
return Object.assign(Object.assign({}, receipt), { total: totalFormatted });
|
|
7
8
|
});
|
|
8
9
|
return { formattedReceipts };
|