Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mernStack
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Venkaiah Naidu Singamchetty
mernStack
Commits
bb7b63ee
Commit
bb7b63ee
authored
Feb 20, 2024
by
Venkaiah Naidu Singamchetty
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user profile
parent
6bcdeeec
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
16 deletions
+25
-16
Cart.tsx
src/components/Cart/Cart.tsx
+7
-7
NavButtons.tsx
src/components/Navbar/NavButtons.tsx
+1
-1
Profile.tsx
src/components/Profile/Profile.tsx
+17
-8
No files found.
src/components/Cart/Cart.tsx
View file @
bb7b63ee
...
...
@@ -10,14 +10,14 @@ const Cart = memo(() => {
const
cartItems
=
useSelector
((
state
:
RootState
)
=>
state
.
cart
.
cartItems
);
const
user
=
useSelector
((
state
:
RootState
)
=>
state
.
userDetails
.
userDetails
);
const
capitalizedUserId
=
user
&&
user
.
userId
?
user
.
userId
.
charAt
(
0
).
toUpperCase
()
+
user
.
userId
.
slice
(
1
)
:
null
;
const
[
preCartItems
,
setPreCartItems
]
=
useState
(
cartItems
);
//
const [preCartItems,setPreCartItems]=useState(cartItems);
useEffect
(()
=>
{
if
(
Object
.
keys
(
user
).
length
===
0
){
navigate
(
'/login'
)
}
else
{
dispatch
(
fetchCartItems
(
user
.
userId
))
}
},[])
},[
cartItems
])
const
handleCartItems
=
()
=>
{
dispatch
(
fetchCartItems
(
user
.
userId
))
}
...
...
@@ -25,14 +25,14 @@ const Cart = memo(() => {
return
(
<
div
>
<
div
>
<
button
type=
"button"
onClick=
{
handleCartItems
}
className=
"btn btn-primary mx-2"
data
-
bs
-
toggle=
"modal"
data
-
bs
-
target=
"#
example
Modal"
>
<
button
type=
"button"
onClick=
{
handleCartItems
}
className=
"btn btn-primary mx-2"
data
-
bs
-
toggle=
"modal"
data
-
bs
-
target=
"#
cart
Modal"
>
<
span
className=
'bi bi-cart'
></
span
>
Cart
</
button
>
<
div
className=
"modal fade"
id=
"
exampleModal"
tabIndex=
{
-
1
}
aria
-
labelledby=
"example
ModalLabel"
aria
-
hidden=
"true"
>
<
div
className=
"modal fade"
id=
"
cartModal"
tabIndex=
{
-
1
}
aria
-
labelledby=
"cart
ModalLabel"
aria
-
hidden=
"true"
>
<
div
className=
"modal-dialog"
>
<
div
className=
"modal-content"
>
<
div
className=
"modal-header"
>
<
h1
className=
"modal-title fs-5"
id=
"
example
ModalLabel"
>
{
capitalizedUserId
}
's Cart
</
h1
>
<
h1
className=
"modal-title fs-5"
id=
"
cart
ModalLabel"
>
{
capitalizedUserId
}
's Cart
</
h1
>
<
button
type=
"button"
className=
"btn-close"
data
-
bs
-
dismiss=
"modal"
aria
-
label=
"Close"
></
button
>
</
div
>
<
div
className=
"modal-body"
>
...
...
@@ -57,10 +57,10 @@ const Cart = memo(() => {
</
tbody
>
</
table
>
</
div
>
<
div
className=
"modal-footer"
>
{
/*
<div className="modal-footer">
<button type="button" className="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" className="btn btn-primary">Save changes</button>
</
div
>
</div>
*/
}
</
div
>
</
div
>
</
div
>
...
...
src/components/Navbar/NavButtons.tsx
View file @
bb7b63ee
...
...
@@ -21,7 +21,7 @@ const NavButtons = memo((props:NavButtonsProps) => {
<
button
>
Register
</
button
></
Link
>
</
div
>
):
(<>
<
Profile
/>
<
Profile
/>
<
Cart
/>
<
Link
to=
"/"
>
<
button
className=
'btn btn-danger'
onClick=
{
props
.
handleLogout
}
>
Logout
</
button
>
...
...
src/components/Profile/Profile.tsx
View file @
bb7b63ee
import
React
,
{
memo
}
from
'react'
;
import
React
,
{
memo
,
useEffect
}
from
'react'
;
import
{
useSelector
}
from
'react-redux'
;
import
{
RootState
}
from
'../../reduxstore/store'
;
const
Profile
=
memo
(()
=>
{
const
userData
=
useSelector
((
state
:
RootState
)
=>
state
.
userDetails
.
userDetails
);
useEffect
(()
=>
{
console
.
log
(
userData
)},[
userData
])
return
(
<
div
>
<
button
type=
"button"
className=
"btn btn-primary"
data
-
bs
-
toggle=
"modal"
data
-
bs
-
target=
"#
examp
leModal"
>
<
button
type=
"button"
className=
"btn btn-primary"
data
-
bs
-
toggle=
"modal"
data
-
bs
-
target=
"#
profi
leModal"
>
<
span
className=
'bi bi-person'
></
span
>
</
button
>
<
div
className=
"modal fade"
id=
"
exampleModal"
tabIndex=
{
-
1
}
aria
-
labelledby=
"examp
leModalLabel"
aria
-
hidden=
"true"
>
<
div
className=
"modal fade"
id=
"
profileModal"
tabIndex=
{
-
1
}
aria
-
labelledby=
"profi
leModalLabel"
aria
-
hidden=
"true"
>
<
div
className=
"modal-dialog"
>
<
div
className=
"modal-content"
>
<
div
className=
"modal-header"
>
<
h1
className=
"modal-title fs-5"
id=
"
exampleModalLabel"
>
Modal tit
le
</
h1
>
<
h1
className=
"modal-title fs-5"
id=
"
profileModalLabel"
>
My Profi
le
</
h1
>
<
button
type=
"button"
className=
"btn-close"
data
-
bs
-
dismiss=
"modal"
aria
-
label=
"Close"
></
button
>
</
div
>
<
div
className=
"modal-body"
>
...
<
div
className=
"modal-body d-flex justify-content-center align-items-center"
>
{
userData
&&
<
div
>
<
p
className=
'text-center'
><
span
className=
'bi bi-person fs-1'
></
span
></
p
>
<
p
>
User :
{
userData
.
userId
}
</
p
>
<
p
>
Email:
{
userData
.
email
}
</
p
>
<
p
>
Mobile:
{
userData
.
mobile
}
</
p
>
</
div
>
}
</
div
>
<
div
className=
"modal-footer"
>
{
/*
<div className="modal-footer">
<button type="button" className="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" className="btn btn-primary">Save changes</button>
</
div
>
</div>
*/
}
</
div
>
</
div
>
</
div
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment