Skip to content

Commit a9d3373

Browse files
author
Nika Kolesnikova
committed
Merge branch 'main' of https://github.com/the-collab-lab/tcl-75-smart-shopping-list into nk-add-mui-throughout-app
2 parents 2d12b86 + 69c1c17 commit a9d3373

File tree

2 files changed

+45
-11
lines changed

2 files changed

+45
-11
lines changed

src/views/List.jsx

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import React, { useState } from 'react';
22
import { useEnsureListPath, useUrgency } from '../hooks';
33
import { getUrgency } from '../utils/urgencyUtils';
4-
import { List as UnorderedList, Paper, Typography } from '@mui/material';
4+
import {
5+
List as UnorderedList,
6+
Box,
7+
Grid,
8+
Paper,
9+
Typography,
10+
} from '@mui/material';
511
import { ListItem, AddItems, TextInputElement } from '../components';
612

713
const paperStyle = {
@@ -52,17 +58,31 @@ export const List = React.memo(function List({ data, listPath }) {
5258
<Typography variant="h3" my="2rem">
5359
{listName}
5460
</Typography>
61+
<Box sx={{ flexGrow: 1 }}>
62+
<Grid
63+
container
64+
spacing={8}
65+
columns={16}
66+
justifyContent="space-between"
67+
>
68+
<Grid item size={{ xs: 2, sm: 4, md: 4 }}>
69+
<AddItems items={data} />
70+
</Grid>
71+
<Grid item size={{ xs: 2, sm: 4, md: 4 }}>
72+
<form onSubmit={(event) => event.preventDefault()}>
73+
<TextInputElement
74+
id="search-item"
75+
type="search"
76+
placeholder="Search item..."
77+
required={true}
78+
onChange={handleTextChange}
79+
label="Search item:"
80+
/>
81+
</form>
82+
</Grid>
83+
</Grid>
84+
</Box>
5585

56-
<form onSubmit={(event) => event.preventDefault()}>
57-
<TextInputElement
58-
id="search-item"
59-
type="search"
60-
placeholder="Search item..."
61-
required={true}
62-
onChange={handleTextChange}
63-
label="Search item:"
64-
/>
65-
</form>
6686
<UnorderedList>
6787
{filteredItems.map((item) => {
6888
const itemUrgencyStatus = getUrgency(item.name, urgencyObject);

tests/List.test.jsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,18 @@ describe('List Component', () => {
108108
'It seems like you landed here without first creating a list or selecting an existing one. Please select or create a new list first. Redirecting to Home.',
109109
);
110110
});
111+
112+
test('shows AddItems component with existing items', () => {
113+
render(
114+
<MemoryRouter>
115+
<List data={mockShoppingListData} listPath={'/groceries'} />
116+
</MemoryRouter>,
117+
);
118+
119+
expect(screen.getByLabelText('Item Name:')).toBeInTheDocument();
120+
expect(screen.getByLabelText('Soon')).toBeInTheDocument();
121+
expect(screen.getByLabelText('Kind of soon')).toBeInTheDocument();
122+
expect(screen.getByLabelText('Not soon')).toBeInTheDocument();
123+
expect(screen.getByText('Submit')).toBeInTheDocument();
124+
});
111125
});

0 commit comments

Comments
 (0)