1
- import { useState } from ' react' ;
2
- import { NavLink , Link } from ' react-router-dom' ;
3
- import { useSelector , useDispatch } from ' react-redux' ;
1
+ import { useState } from " react" ;
2
+ import { NavLink , Link } from " react-router-dom" ;
3
+ import { useSelector , useDispatch } from " react-redux" ;
4
4
5
- import Searchbar from ' ../../components/Searchbar/Searchbar' ;
6
- import Profile from ' ../../components/Profile/Profile' ;
7
- import Cart from ' ../../components/Cart/Cart' ;
8
- import { setAmount } from ' ../../helpers/setAmoun' ;
9
- import { setAmountProduct } from "../../helpers/getAmountProduct"
5
+ import Searchbar from " ../../components/Searchbar/Searchbar" ;
6
+ import Profile from " ../../components/Profile/Profile" ;
7
+ import Cart from " ../../components/Cart/Cart" ;
8
+ import { setAmount } from " ../../helpers/setAmoun" ;
9
+ import { setAmountProduct } from "../../helpers/getAmountProduct" ;
10
10
11
- import * as actionCreators from ' ../../ducks/actions/actionCreators' ;
11
+ import * as actionCreators from " ../../ducks/actions/actionCreators" ;
12
12
13
- import styles from ' ./_Navbar.module.scss' ;
13
+ import styles from " ./_Navbar.module.scss" ;
14
14
15
15
const Navbar = ( ) => {
16
16
const dispatch = useDispatch ( ) ;
17
17
const [ showCart , setShowCart ] = useState ( false ) ;
18
18
const [ showLogin , setShowLogin ] = useState ( false ) ;
19
- const amount = useSelector ( state => state . reducer . amount )
20
- const amountByPost = useSelector ( state => state . reducer . amountByPost )
19
+ const amount = useSelector ( ( state ) => state . reducer . amount ) ;
20
+ const amountByPost = useSelector ( ( state ) => state . reducer . amountByPost ) ;
21
21
const cart = useSelector ( ( state ) => state . reducer . cart ) ;
22
- console . log ( cart )
22
+ console . log ( cart ) ;
23
23
24
- const logged = localStorage . getItem ( ' logged' ) ;
24
+ const logged = localStorage . getItem ( " logged" ) ;
25
25
26
26
const show = ( ) => {
27
27
setShowLogin ( ! showLogin ) ;
28
28
} ;
29
29
30
30
const removePost = ( e ) => {
31
31
let id = Number ( e ) ;
32
- let posts = JSON . parse ( localStorage . getItem ( ' posts' ) ) ;
32
+ let posts = JSON . parse ( localStorage . getItem ( " posts" ) ) ;
33
33
posts . item = posts ?. item ?. filter ( ( e ) => e . id !== Number ( id ) ) ;
34
34
dispatch ( actionCreators . setCart ( posts ) ) ;
35
- localStorage . setItem ( ' posts' , JSON . stringify ( posts ) ) ;
36
- setAmount ( dispatch , actionCreators )
35
+ localStorage . setItem ( " posts" , JSON . stringify ( posts ) ) ;
36
+ setAmount ( dispatch , actionCreators ) ;
37
37
} ;
38
38
39
39
const incrementQuantity = ( e ) => {
40
40
let id = Number ( e ) ;
41
- let posts = JSON . parse ( localStorage . getItem ( ' posts' ) ) ;
41
+ let posts = JSON . parse ( localStorage . getItem ( " posts" ) ) ;
42
42
posts . item . forEach ( ( e ) => {
43
43
e . id === id && e . stock > e . quantity && e . quantity ++ ;
44
44
} ) ;
45
45
dispatch ( actionCreators . setCart ( posts ) ) ;
46
- localStorage . setItem ( 'posts' , JSON . stringify ( posts ) ) ;
47
- setAmount ( dispatch , actionCreators )
48
-
46
+ localStorage . setItem ( "posts" , JSON . stringify ( posts ) ) ;
47
+ setAmount ( dispatch , actionCreators ) ;
49
48
} ;
50
49
51
50
const decrementQuantity = ( e ) => {
52
51
let id = Number ( e ) ;
53
- let posts = JSON . parse ( localStorage . getItem ( ' posts' ) ) ;
52
+ let posts = JSON . parse ( localStorage . getItem ( " posts" ) ) ;
54
53
posts . item . forEach ( ( e ) => {
55
54
e . id === id && e . quantity > 1 && e . quantity -- ;
56
55
} ) ;
57
56
dispatch ( actionCreators . setCart ( posts ) ) ;
58
- localStorage . setItem ( ' posts' , JSON . stringify ( posts ) ) ;
59
- setAmount ( dispatch , actionCreators )
57
+ localStorage . setItem ( " posts" , JSON . stringify ( posts ) ) ;
58
+ setAmount ( dispatch , actionCreators ) ;
60
59
} ;
61
60
62
-
63
-
64
61
return (
65
62
< div className = { styles . navbar } >
66
63
{ /* Ecommerce */ }
67
64
< div className = { styles . containertitle } >
68
- < Link to = { '/' } className = { styles . market } >
69
- < h1 > Kwik-E-Mart</ h1 >
65
+ < Link to = { "/" } className = { styles . market } >
66
+ < h3 > Kwik-E-Mart</ h3 >
70
67
</ Link >
71
- < Link to = { ' /market' } className = { styles . market } >
68
+ < Link to = { " /market" } className = { styles . market } >
72
69
< h4 > Market</ h4 >
73
70
</ Link >
74
71
</ div >
@@ -80,27 +77,28 @@ const Navbar = () => {
80
77
{ /* Profile */ }
81
78
{ ! logged ? (
82
79
< div className = { styles . containerLogin } >
83
- < NavLink to = ' /login' className = { styles . login } >
84
- { ' ' }
80
+ < NavLink to = " /login" className = { styles . login } >
81
+ { " " }
85
82
Login
86
83
</ NavLink >
87
84
< div className = { styles . cart } >
88
85
< button onClick = { ( ) => setShowCart ( ! showCart ) } >
89
86
< svg
90
- width = '33'
91
- height = '21'
92
- viewBox = '0 0 33 21'
93
- fill = 'none'
94
- xmlns = 'http://www.w3.org/2000/svg' >
87
+ width = "33"
88
+ height = "21"
89
+ viewBox = "0 0 33 21"
90
+ fill = "none"
91
+ xmlns = "http://www.w3.org/2000/svg"
92
+ >
95
93
< path
96
- fillRule = ' evenodd'
97
- clipRule = ' evenodd'
98
- d = ' M10 0.359009L15 13.359H29L33 1.35901V0.359009H23V1.35901H31.9459L28.2792 12.359H15.6868L10.9333 2.97129e-05L10 0.359009ZM10 0.359009H0V1.35901H10V0.359009ZM17.5 19.359C18.3284 19.359 19 18.6874 19 17.859C19 17.0306 18.3284 16.359 17.5 16.359C16.6716 16.359 16 17.0306 16 17.859C16 18.6874 16.6716 19.359 17.5 19.359ZM17.5 20.359C18.8807 20.359 20 19.2397 20 17.859C20 16.4783 18.8807 15.359 17.5 15.359C16.1193 15.359 15 16.4783 15 17.859C15 19.2397 16.1193 20.359 17.5 20.359ZM28 17.859C28 18.6874 27.3284 19.359 26.5 19.359C25.6716 19.359 25 18.6874 25 17.859C25 17.0306 25.6716 16.359 26.5 16.359C27.3284 16.359 28 17.0306 28 17.859ZM29 17.859C29 19.2397 27.8807 20.359 26.5 20.359C25.1193 20.359 24 19.2397 24 17.859C24 16.4783 25.1193 15.359 26.5 15.359C27.8807 15.359 29 16.4783 29 17.859Z'
99
- fill = ' white'
94
+ fillRule = " evenodd"
95
+ clipRule = " evenodd"
96
+ d = " M10 0.359009L15 13.359H29L33 1.35901V0.359009H23V1.35901H31.9459L28.2792 12.359H15.6868L10.9333 2.97129e-05L10 0.359009ZM10 0.359009H0V1.35901H10V0.359009ZM17.5 19.359C18.3284 19.359 19 18.6874 19 17.859C19 17.0306 18.3284 16.359 17.5 16.359C16.6716 16.359 16 17.0306 16 17.859C16 18.6874 16.6716 19.359 17.5 19.359ZM17.5 20.359C18.8807 20.359 20 19.2397 20 17.859C20 16.4783 18.8807 15.359 17.5 15.359C16.1193 15.359 15 16.4783 15 17.859C15 19.2397 16.1193 20.359 17.5 20.359ZM28 17.859C28 18.6874 27.3284 19.359 26.5 19.359C25.6716 19.359 25 18.6874 25 17.859C25 17.0306 25.6716 16.359 26.5 16.359C27.3284 16.359 28 17.0306 28 17.859ZM29 17.859C29 19.2397 27.8807 20.359 26.5 20.359C25.1193 20.359 24 19.2397 24 17.859C24 16.4783 25.1193 15.359 26.5 15.359C27.8807 15.359 29 16.4783 29 17.859Z"
97
+ fill = " white"
100
98
/>
101
99
</ svg >
102
100
</ button >
103
- </ div >
101
+ </ div >
104
102
105
103
< Cart
106
104
showCart = { showCart }
@@ -119,16 +117,17 @@ const Navbar = () => {
119
117
< div className = { styles . cart } >
120
118
< button onClick = { ( ) => setShowCart ( ! showCart ) } >
121
119
< svg
122
- width = '33'
123
- height = '21'
124
- viewBox = '0 0 33 21'
125
- fill = 'none'
126
- xmlns = 'http://www.w3.org/2000/svg' >
120
+ width = "33"
121
+ height = "21"
122
+ viewBox = "0 0 33 21"
123
+ fill = "none"
124
+ xmlns = "http://www.w3.org/2000/svg"
125
+ >
127
126
< path
128
- fillRule = ' evenodd'
129
- clipRule = ' evenodd'
130
- d = ' M10 0.359009L15 13.359H29L33 1.35901V0.359009H23V1.35901H31.9459L28.2792 12.359H15.6868L10.9333 2.97129e-05L10 0.359009ZM10 0.359009H0V1.35901H10V0.359009ZM17.5 19.359C18.3284 19.359 19 18.6874 19 17.859C19 17.0306 18.3284 16.359 17.5 16.359C16.6716 16.359 16 17.0306 16 17.859C16 18.6874 16.6716 19.359 17.5 19.359ZM17.5 20.359C18.8807 20.359 20 19.2397 20 17.859C20 16.4783 18.8807 15.359 17.5 15.359C16.1193 15.359 15 16.4783 15 17.859C15 19.2397 16.1193 20.359 17.5 20.359ZM28 17.859C28 18.6874 27.3284 19.359 26.5 19.359C25.6716 19.359 25 18.6874 25 17.859C25 17.0306 25.6716 16.359 26.5 16.359C27.3284 16.359 28 17.0306 28 17.859ZM29 17.859C29 19.2397 27.8807 20.359 26.5 20.359C25.1193 20.359 24 19.2397 24 17.859C24 16.4783 25.1193 15.359 26.5 15.359C27.8807 15.359 29 16.4783 29 17.859Z'
131
- fill = ' white'
127
+ fillRule = " evenodd"
128
+ clipRule = " evenodd"
129
+ d = " M10 0.359009L15 13.359H29L33 1.35901V0.359009H23V1.35901H31.9459L28.2792 12.359H15.6868L10.9333 2.97129e-05L10 0.359009ZM10 0.359009H0V1.35901H10V0.359009ZM17.5 19.359C18.3284 19.359 19 18.6874 19 17.859C19 17.0306 18.3284 16.359 17.5 16.359C16.6716 16.359 16 17.0306 16 17.859C16 18.6874 16.6716 19.359 17.5 19.359ZM17.5 20.359C18.8807 20.359 20 19.2397 20 17.859C20 16.4783 18.8807 15.359 17.5 15.359C16.1193 15.359 15 16.4783 15 17.859C15 19.2397 16.1193 20.359 17.5 20.359ZM28 17.859C28 18.6874 27.3284 19.359 26.5 19.359C25.6716 19.359 25 18.6874 25 17.859C25 17.0306 25.6716 16.359 26.5 16.359C27.3284 16.359 28 17.0306 28 17.859ZM29 17.859C29 19.2397 27.8807 20.359 26.5 20.359C25.1193 20.359 24 19.2397 24 17.859C24 16.4783 25.1193 15.359 26.5 15.359C27.8807 15.359 29 16.4783 29 17.859Z"
130
+ fill = " white"
132
131
/>
133
132
</ svg >
134
133
</ button >
0 commit comments