Skip to content

Commit ca03b24

Browse files
author
Nika Kolesnikova
committed
debug: comment out useUrgency logic in components and tests
1 parent 7ff6b5e commit ca03b24

File tree

3 files changed

+55
-52
lines changed

3 files changed

+55
-52
lines changed

src/components/ListItem.jsx

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,42 +8,42 @@ import { DeleteIconWithTooltip, tooltipStyle } from './DeleteIconWithTooltip';
88
import {
99
ListItem as MaterialListItem,
1010
Tooltip,
11-
IconButton,
11+
// IconButton,
1212
ListItemButton,
1313
ListItemIcon,
1414
ListItemText,
1515
Checkbox,
1616
} from '@mui/material';
17-
import {
18-
Restore as OverdueIcon,
19-
RestartAlt as SoonIcon,
20-
RadioButtonUnchecked as KindOfSoonIcon,
21-
RemoveCircle as NotSoonIcon,
22-
RadioButtonChecked as InactiveIcon,
23-
} from '@mui/icons-material';
17+
// import {
18+
// Restore as OverdueIcon,
19+
// RestartAlt as SoonIcon,
20+
// RadioButtonUnchecked as KindOfSoonIcon,
21+
// RemoveCircle as NotSoonIcon,
22+
// RadioButtonChecked as InactiveIcon,
23+
// } from '@mui/icons-material';
2424

2525
import './ListItem.css';
2626

2727
const currentDate = new Date();
2828

29-
const urgencyStatusIcons = {
30-
overdue: OverdueIcon,
31-
soon: SoonIcon,
32-
kindOfSoon: KindOfSoonIcon,
33-
notSoon: NotSoonIcon,
34-
inactive: InactiveIcon,
35-
};
36-
37-
const urgencyStatusStyle = {
38-
fontSize: '2.5rem',
39-
color: 'white',
40-
};
41-
42-
const toolTipStyle = {
43-
fontSize: '1.5rem',
44-
marginBlockStart: '0',
45-
marginBlockEnd: '0',
46-
};
29+
// const urgencyStatusIcons = {
30+
// overdue: OverdueIcon,
31+
// soon: SoonIcon,
32+
// kindOfSoon: KindOfSoonIcon,
33+
// notSoon: NotSoonIcon,
34+
// inactive: InactiveIcon,
35+
// };
36+
37+
// const urgencyStatusStyle = {
38+
// fontSize: '2.5rem',
39+
// color: 'white',
40+
// };
41+
42+
// const toolTipStyle = {
43+
// fontSize: '1.5rem',
44+
// marginBlockStart: '0',
45+
// marginBlockEnd: '0',
46+
// };
4747

4848
const calculateIsPurchased = (dateLastPurchased) => {
4949
if (!dateLastPurchased) {
@@ -57,7 +57,8 @@ const calculateIsPurchased = (dateLastPurchased) => {
5757
return currentDate < oneDayLater;
5858
};
5959

60-
export function ListItem({ item, listPath, itemUrgencyStatus }) {
60+
export function ListItem({ item, listPath }) {
61+
// export function ListItem({ item, listPath, itemUrgencyStatus }) {
6162
const { open, isOpen, toggleDialog } = useConfirmDialog();
6263
const [isPurchased, setIsPurchased] = useState(() =>
6364
calculateIsPurchased(item.dateLastPurchased),
@@ -96,7 +97,7 @@ export function ListItem({ item, listPath, itemUrgencyStatus }) {
9697
return;
9798
};
9899

99-
const UrgencyStatusIcon = urgencyStatusIcons[itemUrgencyStatus];
100+
// const UrgencyStatusIcon = urgencyStatusIcons[itemUrgencyStatus];
100101

101102
const props = {
102103
handleDelete: handleDeleteItem,
@@ -113,7 +114,7 @@ export function ListItem({ item, listPath, itemUrgencyStatus }) {
113114
<>
114115
{open && <ConfirmDialog props={props} />}
115116
<MaterialListItem className="ListItem">
116-
{UrgencyStatusIcon && (
117+
{/* {UrgencyStatusIcon && (
117118
<Tooltip
118119
title={<p style={toolTipStyle}>{itemUrgencyStatus}</p>}
119120
placement="left"
@@ -123,7 +124,7 @@ export function ListItem({ item, listPath, itemUrgencyStatus }) {
123124
<UrgencyStatusIcon sx={urgencyStatusStyle} fontSize="large" />
124125
</IconButton>
125126
</Tooltip>
126-
)}
127+
)} */}
127128
<ListItemButton role={undefined} onClick={handleChange} dense>
128129
<ListItemIcon>
129130
<Tooltip

src/views/List.jsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, { useState } from 'react';
2-
import { useEnsureListPath, useUrgency } from '../hooks';
3-
import { getUrgency } from '../utils/urgencyUtils';
2+
import { useEnsureListPath } from '../hooks';
3+
// import { useEnsureListPath, useUrgency } from '../hooks';
4+
// import { getUrgency } from '../utils/urgencyUtils';
45
// import { List as UnorderedList, Box } from '@mui/material';
56
// import Grid from '@mui/material/Grid2';
67
import { ListItem, AddItems, TextInputElement } from '../components';
@@ -11,20 +12,21 @@ import { ListItem, AddItems, TextInputElement } from '../components';
1112
// operations like filtering and sorting items.
1213

1314
export const List = React.memo(function List({ data, listPath }) {
14-
const { urgencyObject } = useUrgency(data);
15+
// const { urgencyObject } = useUrgency(data);
1516
const [searchItem, setSearchItem] = useState('');
1617

1718
// Redirect to home if no list path is nulls
1819
if (useEnsureListPath()) return <></>;
1920
const listName = listPath.slice(listPath.indexOf('/') + 1);
2021

21-
const sortedItems = Object.values(urgencyObject).flat();
22+
// const sortedItems = Object.values(urgencyObject).flat();
2223

2324
const handleTextChange = (event) => {
2425
setSearchItem(event.target.value);
2526
};
2627

27-
const filteredItems = sortedItems.filter((item) =>
28+
const filteredItems = data.filter((item) =>
29+
// const filteredItems = sortedItems.filter((item) =>
2830
item?.name?.toLowerCase().includes(searchItem.toLowerCase()),
2931
);
3032

@@ -70,13 +72,13 @@ export const List = React.memo(function List({ data, listPath }) {
7072

7173
<ul>
7274
{filteredItems.map((item) => {
73-
const itemUrgencyStatus = getUrgency(item.name, urgencyObject);
75+
// const itemUrgencyStatus = getUrgency(item.name, urgencyObject);
7476
return (
7577
<ListItem
7678
key={item.id}
7779
item={item}
7880
listPath={listPath}
79-
itemUrgencyStatus={itemUrgencyStatus}
81+
// itemUrgencyStatus={itemUrgencyStatus}
8082
/>
8183
);
8284
})}

tests/List.test.jsx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { render, screen } from '@testing-library/react';
22
import { MemoryRouter } from 'react-router-dom';
33
import { List } from '../src/views/List';
44
import { mockShoppingListData } from '../src/mocks/__fixtures__/shoppingListData';
5-
import { useStateWithStorage, useEnsureListPath } from '../src/hooks';
5+
import { useStateWithStorage } from '../src/hooks';
66
import {
77
getDateLastPurchasedOrDateCreated,
88
getDaysFromDate,
@@ -12,20 +12,20 @@ import {
1212
vi.mock('../src/hooks', () => ({
1313
useEnsureListPath: vi.fn(),
1414
useStateWithStorage: vi.fn(),
15-
useUrgency: vi.fn(() => ({
16-
getUrgency: vi.fn((name) => {
17-
if (name === 'nutella') return 'soon';
18-
if (name === 'Cheese') return 'overdue';
19-
return 'notSoon';
20-
}),
21-
urgencyObject: {
22-
overdue: [{ name: 'nutella', id: '0T1ByXr8YJSOzujOlLMI' }],
23-
soon: [{ name: 'Cheese', id: '1MFWOWMCzDtEHQboFZfR' }],
24-
kindOfSoon: [],
25-
notSoon: [{ name: 'Jam', id: 'MnUiYUmhg8iCzX1eMxW8' }],
26-
inactive: [],
27-
},
28-
})),
15+
// useUrgency: vi.fn(() => ({
16+
// getUrgency: vi.fn((name) => {
17+
// if (name === 'nutella') return 'soon';
18+
// if (name === 'Cheese') return 'overdue';
19+
// return 'notSoon';
20+
// }),
21+
// urgencyObject: {
22+
// overdue: [{ name: 'nutella', id: '0T1ByXr8YJSOzujOlLMI' }],
23+
// soon: [{ name: 'Cheese', id: '1MFWOWMCzDtEHQboFZfR' }],
24+
// kindOfSoon: [],
25+
// notSoon: [{ name: 'Jam', id: 'MnUiYUmhg8iCzX1eMxW8' }],
26+
// inactive: [],
27+
// },
28+
// })),
2929
}));
3030

3131
vi.mock('../src/utils', () => ({

0 commit comments

Comments
 (0)