@@ -4,10 +4,10 @@ import { useState, useMemo, useRef } from "react";
4
4
import { ListItemCheckBox } from "../../components/ListItem" ;
5
5
import { FilterListInput } from "../../components/FilterListInput" ;
6
6
import { ListItem , comparePurchaseUrgency } from "../../api" ;
7
- import { Container , Modal } from "react-bootstrap" ;
7
+ import { Container } from "react-bootstrap" ;
8
8
import Button from "react-bootstrap/Button" ;
9
9
import ShareListForm from "../../components/forms/ShareListForm" ;
10
- import { FaRegShareSquare } from "react-icons/fa " ;
10
+ import { AddItemForm } from "../../components/forms/AddItemForm " ;
11
11
12
12
interface Props {
13
13
data : ListItem [ ] ;
@@ -18,7 +18,6 @@ export function List({ data: unfilteredListItems, listPath }: Props) {
18
18
const navigate = useNavigate ( ) ;
19
19
const [ searchTerm , setSearchTerm ] = useState < string > ( "" ) ;
20
20
const { listName } = useParams < { listName : string } > ( ) ;
21
- const [ showShareModal , setShowShareModal ] = useState ( false ) ;
22
21
23
22
const filteredListItems = useMemo ( ( ) => {
24
23
return unfilteredListItems
@@ -81,24 +80,7 @@ export function List({ data: unfilteredListItems, listPath }: Props) {
81
80
< h2 className = "ListName p-1 m-2 mt-2" > { listName } </ h2 >
82
81
</ header >
83
82
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" >
102
84
{ unfilteredListItems . length > 0 && (
103
85
< FilterListInput
104
86
searchTerm = { searchTerm }
@@ -108,26 +90,18 @@ export function List({ data: unfilteredListItems, listPath }: Props) {
108
90
</ section >
109
91
110
92
< 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 >
114
101
</ section >
115
102
</ div >
116
103
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 } />
131
105
< Button className = "d-md-none mt-3" onClick = { scrollToViewList } >
132
106
{ "View List" }
133
107
</ Button >
0 commit comments