@homefile/components-v2 2.8.43 → 2.8.45

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.
@@ -8,5 +8,5 @@ export const PartnerCatalogPanel = ({ config, onClose, onPartnerAdd, partners, }
8
8
  const { codeValue, displayType, handleSearchByCode, handleCategoryFilter, handleSearch, partnerList, searchTerm, setDisplayType, } = usePartnerCatalogPanel({
9
9
  partners,
10
10
  });
11
- return (_jsxs(DrawerContent, { bg: "lightBlue.1", children: [_jsxs(DrawerHeader, { p: "0", children: [_jsx(PanelHeader, { handleCloseButton: onClose, title: t('partner.add'), icon: Catalog }), (config === null || config === void 0 ? void 0 : config.showCode) && (_jsx(PartnerCode, { code: codeValue, onCodeChange: handleSearchByCode })), _jsx(CatalogFilters, { onCategoryClick: handleCategoryFilter, onSearchChange: handleSearch, searchValue: searchTerm, showCategories: config === null || config === void 0 ? void 0 : config.showCategories })] }), _jsxs(DrawerBody, { p: "0", children: [_jsx(CatalogDisplay, { initialDisplay: displayType, onDisplayClick: setDisplayType, totalItems: partners.length, totalShowing: partnerList.length }), displayType === 'grid' && (_jsx(Grid, { templateColumns: ['repeat(2, 1fr)', 'repeat(3, 1fr)'], gap: "base", px: "base", pb: "40px", children: partnerList.map((partner) => (_jsx(CatalogPartnerCard, Object.assign({}, partner, { onAdd: onPartnerAdd })))) })), displayType === 'list' && (_jsx(Stack, { spacing: "1", px: "base", pb: "40px", children: partnerList.map((partner) => (_jsx(CatalogPartnerList, Object.assign({}, partner, { onAdd: onPartnerAdd })))) }))] })] }));
11
+ return (_jsxs(DrawerContent, { bg: "lightBlue.1", children: [_jsxs(DrawerHeader, { p: "0", children: [_jsx(PanelHeader, { handleCloseButton: onClose, title: t('partner.add'), icon: Catalog }), (config === null || config === void 0 ? void 0 : config.showCode) && (_jsx(PartnerCode, { code: codeValue, onCodeChange: handleSearchByCode })), _jsx(CatalogFilters, { onCategoryClick: handleCategoryFilter, onSearchChange: handleSearch, searchValue: searchTerm, showCategories: config === null || config === void 0 ? void 0 : config.showCategories })] }), _jsxs(DrawerBody, { p: "0", children: [_jsx(CatalogDisplay, { initialDisplay: displayType, onDisplayClick: setDisplayType, totalItems: partners.length, totalShowing: partnerList.length }), displayType === 'grid' && (_jsx(Grid, { templateColumns: ['repeat(2, 1fr)', 'repeat(3, 1fr)'], gap: "base", px: "base", pb: "40px", children: partnerList.map((partner) => (_jsx(CatalogPartnerCard, Object.assign({}, partner, { onAdd: onPartnerAdd }), partner._id))) })), displayType === 'list' && (_jsx(Stack, { spacing: "1", px: "base", pb: "40px", children: partnerList.map((partner) => (_jsx(CatalogPartnerList, Object.assign({}, partner, { onAdd: onPartnerAdd })))) }))] })] }));
12
12
  };
@@ -4,11 +4,9 @@ import { Divider, Flex, Image, Show, Text } from '@chakra-ui/react';
4
4
  import { IconMenu, MoreHorizontal } from '..';
5
5
  import { Group } from '../../assets/images';
6
6
  import { GroupIcons } from '../../helpers';
7
- import { useGroupCardHeader } from '../../hooks';
7
+ import { getIconAltText } from '../../utils';
8
8
  export const GroupCardHeader = ({ title, totalAmount, menuItems, }) => {
9
- const { haveNoMenuItems, iconAlt } = useGroupCardHeader({
10
- menuItems,
11
- title,
12
- });
13
- return (_jsxs(Flex, { justifyContent: "space-between", bg: "neutral.white", align: "center", children: [_jsxs(Flex, { gap: "base", id: "organizeByGroup", bg: "neutral.white", p: "4", children: [_jsx(Image, { src: GroupIcons[title] || Group, alt: iconAlt, w: "1rem", h: "auto" }), _jsx(Text, { noOfLines: 1, children: title })] }), _jsxs(Flex, { align: "center", gap: "base", p: "4", id: "trackGroupValue", bg: "neutral.white", children: [_jsx(Show, { breakpoint: "(min-width: 600px)", children: _jsx(Text, { textColor: "gray.4", fontWeight: "semibold", fontSize: "xs", mr: "3", children: t('groups.total') }) }), _jsx(Text, { textColor: "blue.8", fontWeight: "semibold", fontSize: ['md', 'lg'], children: totalAmount }), menuItems && menuItems.length > 0 && (_jsxs(_Fragment, { children: [_jsx(Show, { breakpoint: "(min-width: 600px)", children: _jsx(Divider, { orientation: "vertical", h: "6" }) }), _jsx(IconMenu, { icon: _jsx(MoreHorizontal, { size: 38 }), menuItems: menuItems, disabled: haveNoMenuItems })] }))] })] }));
9
+ const iconAlt = getIconAltText(GroupIcons[title]);
10
+ const hasMenuItems = Number(menuItems === null || menuItems === void 0 ? void 0 : menuItems.length) > 0;
11
+ return (_jsxs(Flex, { justifyContent: "space-between", bg: "neutral.white", align: "center", children: [_jsxs(Flex, { gap: "base", id: "organizeByGroup", bg: "neutral.white", p: "4", children: [_jsx(Image, { src: GroupIcons[title] || Group, alt: iconAlt, w: "1rem", h: "auto" }), _jsx(Text, { noOfLines: 1, children: title })] }), _jsxs(Flex, { align: "center", gap: "base", p: "4", id: "trackGroupValue", bg: "neutral.white", children: [_jsx(Show, { breakpoint: "(min-width: 600px)", children: _jsx(Text, { textColor: "gray.4", fontWeight: "semibold", fontSize: "xs", mr: "3", children: t('groups.total') }) }), _jsx(Text, { textColor: "blue.8", fontWeight: "semibold", fontSize: ['md', 'lg'], children: totalAmount }), hasMenuItems && (_jsxs(_Fragment, { children: [_jsx(Show, { breakpoint: "(min-width: 600px)", children: _jsx(Divider, { orientation: "vertical", h: "6" }) }), _jsx(IconMenu, { icon: _jsx(MoreHorizontal, { size: 38 }), menuItems: menuItems, disabled: !hasMenuItems })] }))] })] }));
14
12
  };
@@ -9,7 +9,6 @@ export declare const usePartnerCatalogPanel: ({ partners, }: UsePartnerCatalogPa
9
9
  handleCategoryFilter: (category: string) => void;
10
10
  handleSearch: (input: React.ChangeEvent<HTMLInputElement>) => void;
11
11
  partnerList: {
12
- key: string;
13
12
  _id: string;
14
13
  bgColor: string;
15
14
  category: string;
@@ -4,7 +4,7 @@ import { categoryColors, partnerCategoriesIcons } from '../../../helpers';
4
4
  export const usePartnerCatalogPanel = ({ partners, }) => {
5
5
  const partnerListMapped = partners.map((partner) => {
6
6
  var _a, _b, _c;
7
- return Object.assign(Object.assign({}, partner), { key: partner._id, _id: partner._id, bgColor: categoryColors[(_a = partner.category) !== null && _a !== void 0 ? _a : 'other'], category: t(`partner.categories.${(_b = partner.category) !== null && _b !== void 0 ? _b : 'other'}`), description: partner.description, icon: partnerCategoriesIcons[(_c = partner.category) !== null && _c !== void 0 ? _c : 'other'], name: partner.name, code: partner.code });
7
+ return Object.assign(Object.assign({}, partner), { _id: partner._id, bgColor: categoryColors[(_a = partner.category) !== null && _a !== void 0 ? _a : 'other'], category: t(`partner.categories.${(_b = partner.category) !== null && _b !== void 0 ? _b : 'other'}`), description: partner.description, icon: partnerCategoriesIcons[(_c = partner.category) !== null && _c !== void 0 ? _c : 'other'], name: partner.name, code: partner.code });
8
8
  });
9
9
  const [displayType, setDisplayType] = useState('grid');
10
10
  const [partnerList, setPartnerList] = useState(partnerListMapped);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homefile/components-v2",
3
- "version": "2.8.43",
3
+ "version": "2.8.45",
4
4
  "author": "Homefile",
5
5
  "license": "UNLICENSED",
6
6
  "typings": "dist/index.d.ts",
@@ -69,7 +69,7 @@ export const PartnerCatalogPanel = ({
69
69
  pb="40px"
70
70
  >
71
71
  {partnerList.map((partner) => (
72
- <CatalogPartnerCard {...partner} onAdd={onPartnerAdd} />
72
+ <CatalogPartnerCard key={partner._id} {...partner} onAdd={onPartnerAdd} />
73
73
  ))}
74
74
  </Grid>
75
75
  )}
@@ -4,17 +4,15 @@ import { IconMenu, MoreHorizontal } from '@/components'
4
4
  import { GroupCardHeaderI } from '@/interfaces'
5
5
  import { Group } from '@/assets/images'
6
6
  import { GroupIcons } from '@/helpers'
7
- import { useGroupCardHeader } from '@/hooks'
7
+ import { getIconAltText } from '@/utils'
8
8
 
9
9
  export const GroupCardHeader = ({
10
10
  title,
11
11
  totalAmount,
12
12
  menuItems,
13
13
  }: GroupCardHeaderI) => {
14
- const { haveNoMenuItems, iconAlt } = useGroupCardHeader({
15
- menuItems,
16
- title,
17
- })
14
+ const iconAlt = getIconAltText(GroupIcons[title])
15
+ const hasMenuItems = Number(menuItems?.length) > 0
18
16
 
19
17
  return (
20
18
  <Flex justifyContent="space-between" bg="neutral.white" align="center">
@@ -42,7 +40,7 @@ export const GroupCardHeader = ({
42
40
  <Text textColor="blue.8" fontWeight="semibold" fontSize={['md', 'lg']}>
43
41
  {totalAmount}
44
42
  </Text>
45
- {menuItems && menuItems.length > 0 && (
43
+ {hasMenuItems && (
46
44
  <>
47
45
  <Show breakpoint="(min-width: 600px)">
48
46
  <Divider orientation="vertical" h="6" />
@@ -50,7 +48,7 @@ export const GroupCardHeader = ({
50
48
  <IconMenu
51
49
  icon={<MoreHorizontal size={38} />}
52
50
  menuItems={menuItems}
53
- disabled={haveNoMenuItems}
51
+ disabled={!hasMenuItems}
54
52
  />
55
53
  </>
56
54
  )}
@@ -13,7 +13,6 @@ export const usePartnerCatalogPanel = ({
13
13
  const partnerListMapped = partners.map((partner) => {
14
14
  return {
15
15
  ...partner,
16
- key: partner._id,
17
16
  _id: partner._id,
18
17
  bgColor: categoryColors[partner.category ?? 'other'],
19
18
  category: t(`partner.categories.${partner.category ?? 'other'}`),