Skip to content

Commit b998305

Browse files
committed
refactor: disregard additem navigation logic
1 parent 52db7a1 commit b998305

File tree

5 files changed

+25
-44
lines changed

5 files changed

+25
-44
lines changed

src/components/forms/AddItemForm.scss

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
color: #001f3f; /* Optional: text color */
1515
position: relative;
1616
top: -40px;
17-
left: 10px;
17+
left: 60px;
1818
background-color: rgb(241, 230, 204);
19-
width: 80%;
19+
width: 60%;
2020
}

src/components/forms/AddItemForm.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ChangeEvent, FormEvent, useState } from "react";
2-
import { useNavigate, useParams } from "react-router-dom";
2+
import { useNavigate } from "react-router-dom";
33
import { addItem, ListItem } from "../../api";
44
import { validateItemName } from "../../utils";
55
import toast from "react-hot-toast";
@@ -181,7 +181,7 @@ export function AddItemForm({ listPath, data: unfilteredListItems }: Props) {
181181
Not soon -- Within {purchaseTimelines[PurchaseTime.notSoon]} days!
182182
</Form.Label>
183183
<Button type="submit" aria-label="Add item to shopping list">
184-
Submit Item
184+
Add Item
185185
</Button>
186186
</fieldset>
187187
</Form>

src/components/forms/ShareListForm.scss

+4
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@
77
margin-top: 20px;
88
position: relative;
99
}
10+
11+
.Share-ListForm {
12+
background-color: rgb(241, 230, 204);
13+
}

src/components/forms/ShareListForm.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,13 @@ const ShareListForm = ({ listPath }: Props) => {
4545

4646
return (
4747
<Form
48-
className="d-flex flex-column align-items-center mt-3"
48+
className="Share-ListForm d-flex flex-column align-items-center mt-3"
4949
onSubmit={(e) => handleInvite(e, listPath)}
5050
>
51-
<Form.Label className="h3 text-center " htmlFor="recipient-email">
51+
<Form.Label
52+
className="h3 Share-ListForm text-center "
53+
htmlFor="recipient-email"
54+
>
5255
Invite friends and family to view your list!
5356
</Form.Label>
5457
<InputGroup>

src/views/authenticated/List.tsx

+12-38
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import { useState, useMemo, useRef } from "react";
44
import { ListItemCheckBox } from "../../components/ListItem";
55
import { FilterListInput } from "../../components/FilterListInput";
66
import { ListItem, comparePurchaseUrgency } from "../../api";
7-
import { Container, Modal } from "react-bootstrap";
7+
import { Container } from "react-bootstrap";
88
import Button from "react-bootstrap/Button";
99
import ShareListForm from "../../components/forms/ShareListForm";
10-
import { FaRegShareSquare } from "react-icons/fa";
10+
import { AddItemForm } from "../../components/forms/AddItemForm";
1111

1212
interface Props {
1313
data: ListItem[];
@@ -18,7 +18,6 @@ export function List({ data: unfilteredListItems, listPath }: Props) {
1818
const navigate = useNavigate();
1919
const [searchTerm, setSearchTerm] = useState<string>("");
2020
const { listName } = useParams<{ listName: string }>();
21-
const [showShareModal, setShowShareModal] = useState(false);
2221

2322
const filteredListItems = useMemo(() => {
2423
return unfilteredListItems
@@ -81,24 +80,7 @@ export function List({ data: unfilteredListItems, listPath }: Props) {
8180
<h2 className="ListName p-1 m-2 mt-2">{listName}</h2>
8281
</header>
8382

84-
<section className="list-functions mt-3 d-flex flex-column sticky-top align-items-center justify-content-center">
85-
<div>
86-
<Button
87-
className="ms-2"
88-
onClick={() => navigate("/manage-list")}
89-
aria-label="Navigate to add more items to your list"
90-
>
91-
<span className="text-nowrap">Add items</span>
92-
</Button>
93-
<Button
94-
className="ms-2"
95-
onClick={() => setShowShareModal(true)}
96-
aria-label="Share your list"
97-
>
98-
<FaRegShareSquare />
99-
<span className="text-nowrap ms-1">Share</span>
100-
</Button>
101-
</div>
83+
<section className="list-functions mt-3 d-flex sticky-top align-items-center justify-content-center">
10284
{unfilteredListItems.length > 0 && (
10385
<FilterListInput
10486
searchTerm={searchTerm}
@@ -108,26 +90,18 @@ export function List({ data: unfilteredListItems, listPath }: Props) {
10890
</section>
10991

11092
<section ref={viewListRef}>
111-
{filteredListItems.map((item) => (
112-
<ListItemCheckBox key={item.id} item={item} listPath={listPath} />
113-
))}
93+
<section className="AddItemForm">
94+
<AddItemForm listPath={listPath} data={unfilteredListItems || []} />
95+
</section>
96+
<section className="ListItemCheckBox">
97+
{filteredListItems.map((item) => (
98+
<ListItemCheckBox key={item.id} item={item} listPath={listPath} />
99+
))}
100+
</section>
114101
</section>
115102
</div>
116103

117-
<Modal show={showShareModal} onHide={() => setShowShareModal(false)}>
118-
<Modal.Header closeButton>
119-
<Modal.Title>Share Your List</Modal.Title>
120-
</Modal.Header>
121-
<Modal.Body>
122-
<ShareListForm listPath={listPath} />
123-
</Modal.Body>
124-
<Modal.Footer>
125-
<Button variant="secondary" onClick={() => setShowShareModal(false)}>
126-
Close
127-
</Button>
128-
</Modal.Footer>
129-
</Modal>
130-
104+
<ShareListForm listPath={listPath} />
131105
<Button className="d-md-none mt-3" onClick={scrollToViewList}>
132106
{"View List"}
133107
</Button>

0 commit comments

Comments
 (0)