1
1
import { useNavigate } from 'react-router-dom' ;
2
- import { deleteList } from '../api/firebase ' ;
2
+ import DeleteList from './DeleteList ' ;
3
3
4
4
export function SingleList ( { userEmail, name, path, setListPath, userId } ) {
5
5
const navigate = useNavigate ( ) ;
@@ -8,29 +8,6 @@ export function SingleList({ userEmail, name, path, setListPath, userId }) {
8
8
navigate ( `/list/${ path } ` ) ;
9
9
}
10
10
11
- function handleDelete ( user , email , listPath , listName ) {
12
- if ( listPath . includes ( user ) ) {
13
- if (
14
- window . confirm (
15
- `Do you really want to delete ${ listName . toUpperCase ( ) } list?` ,
16
- )
17
- ) {
18
- deleteList ( user , email , listPath , listName ) ;
19
- setListPath ( '' ) ;
20
- }
21
- return ;
22
- }
23
- if (
24
- window . confirm (
25
- `Do you really want to stop using ${ listName . toUpperCase ( ) } list?` ,
26
- )
27
- ) {
28
- deleteList ( user , email , listPath , listName ) ;
29
- setListPath ( '' ) ;
30
- }
31
- return ;
32
- }
33
-
34
11
return (
35
12
< li className = "mb-8 bg-lightPurple w-full text-puurWhite flex justify-end shadow-lg rounded-md transition ease-in-out relative text-lg sm:text-xl hover:bg-hoverPurple" >
36
13
< button
@@ -39,14 +16,13 @@ export function SingleList({ userEmail, name, path, setListPath, userId }) {
39
16
>
40
17
{ name }
41
18
</ button >
42
- < button
43
- className = "rounded-md transition ease-in-out hover:text-alertRed focus:text-alertRed px-4 py-2"
44
- onClick = { ( ) => handleDelete ( userId , userEmail , path , name ) }
45
- aria-label = { `Delete ${ name } List` }
46
- title = { `Delete ${ name } List` }
47
- >
48
- < i className = "fa-solid fa-trash" > </ i >
49
- </ button >
19
+ < DeleteList
20
+ user = { userId }
21
+ email = { userEmail }
22
+ listPath = { path }
23
+ listName = { name }
24
+ setListPath = { setListPath }
25
+ />
50
26
</ li >
51
27
) ;
52
28
}
0 commit comments