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
3e7f9f97
Commit
3e7f9f97
authored
Feb 22, 2024
by
Venkaiah Naidu Singamchetty
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed cart errors
parent
7f41d87b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
6 deletions
+16
-6
Cart.tsx
src/components/Cart/Cart.tsx
+13
-3
NavButtons.tsx
src/components/Navbar/NavButtons.tsx
+1
-1
Product.tsx
src/components/catelog/Product.tsx
+1
-1
index.tsx
src/index.tsx
+1
-0
cartSlice.ts
src/reduxstore/cartSlice.ts
+0
-1
No files found.
src/components/Cart/Cart.tsx
View file @
3e7f9f97
...
@@ -25,6 +25,16 @@ const Cart = memo(() => {
...
@@ -25,6 +25,16 @@ const Cart = memo(() => {
dispatch
(
updateCartItems
({
userId
:
user
.
userId
,
updateCartItems
:
cartItems
}))
dispatch
(
updateCartItems
({
userId
:
user
.
userId
,
updateCartItems
:
cartItems
}))
}
}
}
}
const
handleDontSave
=
()
=>
{
if
(
user
)
{
if
(
Object
.
keys
(
user
).
length
===
0
)
{
navigate
(
'/login'
)
}
else
{
dispatch
(
fetchCartItems
(
user
.
userId
))
}
}
}
const
totalPay
=
useMemo
(()
=>
{
const
totalPay
=
useMemo
(()
=>
{
return
cartItems
.
reduce
((
acc
,
curr
)
=>
{
return
cartItems
.
reduce
((
acc
,
curr
)
=>
{
return
acc
=
acc
+
(
parseInt
(
curr
.
price
)
*
parseInt
(
curr
.
qty
));
return
acc
=
acc
+
(
parseInt
(
curr
.
price
)
*
parseInt
(
curr
.
qty
));
...
@@ -38,12 +48,12 @@ const Cart = memo(() => {
...
@@ -38,12 +48,12 @@ const Cart = memo(() => {
<
button
type=
"button"
className=
"btn btn-primary mx-2"
data
-
bs
-
toggle=
"modal"
data
-
bs
-
target=
"#cartModal"
>
<
button
type=
"button"
className=
"btn btn-primary mx-2"
data
-
bs
-
toggle=
"modal"
data
-
bs
-
target=
"#cartModal"
>
<
span
className=
'bi bi-cart'
></
span
>
Cart
<
span
className=
'bi bi-cart'
></
span
>
Cart
</
button
>
</
button
>
<
div
className=
"modal fade"
id=
"cartModal"
tabIndex=
{
-
1
}
aria
-
labelledby=
"cartModalLabel"
aria
-
hidden=
"true"
>
<
div
className=
"modal fade"
data
-
bs
-
backdrop=
"static"
id=
"cartModal"
tabIndex=
{
-
1
}
aria
-
labelledby=
"cartModalLabel"
aria
-
hidden=
"true"
>
<
div
className=
"modal-dialog"
>
<
div
className=
"modal-dialog"
>
<
div
className=
"modal-content"
>
<
div
className=
"modal-content"
>
<
div
className=
"modal-header"
>
<
div
className=
"modal-header"
>
<
h1
className=
"modal-title fs-5"
id=
"cartModalLabel"
>
{
capitalizedUserId
}
's Cart
</
h1
>
<
h1
className=
"modal-title fs-5"
id=
"cartModalLabel"
>
{
capitalizedUserId
}
's Cart
</
h1
>
<
button
type=
"button"
className=
"btn-close"
data
-
bs
-
dismiss=
"modal"
aria
-
label=
"Close"
></
button
>
{
/* <button type="button" className="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> */
}
</
div
>
</
div
>
<
div
className=
"modal-body"
>
<
div
className=
"modal-body"
>
<
table
className=
'table table-hover m-0'
>
<
table
className=
'table table-hover m-0'
>
...
@@ -82,7 +92,7 @@ const Cart = memo(() => {
...
@@ -82,7 +92,7 @@ const Cart = memo(() => {
</
table
>
</
table
>
</
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-secondary"
onClick=
{
handleDontSave
}
data
-
bs
-
dismiss=
"modal"
>
Dont Save Changes
</
button
>
<
button
type=
"button"
className=
"btn btn-primary"
onClick=
{
handleCartChanges
}
>
Save Changes
</
button
>
<
button
type=
"button"
className=
"btn btn-primary"
onClick=
{
handleCartChanges
}
>
Save Changes
</
button
>
</
div
>
</
div
>
</
div
>
</
div
>
...
...
src/components/Navbar/NavButtons.tsx
View file @
3e7f9f97
...
@@ -14,7 +14,7 @@ const NavButtons = memo((props:NavButtonsProps) => {
...
@@ -14,7 +14,7 @@ const NavButtons = memo((props:NavButtonsProps) => {
const
user
=
useSelector
((
state
:
RootState
)
=>
state
.
userDetails
.
userDetails
);
const
user
=
useSelector
((
state
:
RootState
)
=>
state
.
userDetails
.
userDetails
);
return
(
return
(
<
div
className=
'd-flex'
>
<
div
className=
'd-flex'
>
{
user
&&
(
Object
.
keys
(
user
).
length
===
0
&&
user
.
constructor
===
Object
)
?(
{
user
===
null
?(
<
div
className=
'nav-login-cart'
>
<
div
className=
'nav-login-cart'
>
<
Link
to=
"/login"
><
button
>
Login
</
button
></
Link
>
<
Link
to=
"/login"
><
button
>
Login
</
button
></
Link
>
<
Link
to=
"/register"
>
<
Link
to=
"/register"
>
...
...
src/components/catelog/Product.tsx
View file @
3e7f9f97
...
@@ -39,7 +39,7 @@ const Product = memo((props: ProductPropsType) => {
...
@@ -39,7 +39,7 @@ const Product = memo((props: ProductPropsType) => {
return
(<
div
className=
'col-lg-4 col-md-2 col-sm-1 my-2'
style=
{
{
width
:
"300px"
}
}
>
return
(<
div
className=
'col-lg-4 col-md-2 col-sm-1 my-2'
style=
{
{
width
:
"300px"
}
}
>
<
div
className=
"card"
>
<
div
className=
"card"
>
<
img
src=
{
image
}
className=
"img-fluid"
style=
{
{
width
:
"100%"
,
height
:
"200px"
}
}
alt=
"..."
/>
<
img
src=
{
image
}
className=
"img-fluid"
style=
{
{
width
:
"100%"
,
height
:
"200px"
}
}
alt=
"..."
/>
<
div
className=
"card-body"
style=
{
{
width
:
"100%"
,
height
:
"1
3
0px"
,
overflowY
:
"scroll"
}
}
>
<
div
className=
"card-body"
style=
{
{
width
:
"100%"
,
height
:
"1
0
0px"
,
overflowY
:
"scroll"
}
}
>
<
p
className=
"card-title fw-bolder"
>
Title:
{
title
}
</
p
>
<
p
className=
"card-title fw-bolder"
>
Title:
{
title
}
</
p
>
<
p
className=
"card-text"
style=
{
{
fontSize
:
"10px"
}
}
><
span
className=
'fw-bold'
>
Description:
</
span
><
br
/>
{
description
}
</
p
>
<
p
className=
"card-text"
style=
{
{
fontSize
:
"10px"
}
}
><
span
className=
'fw-bold'
>
Description:
</
span
><
br
/>
{
description
}
</
p
>
</
div
>
</
div
>
...
...
src/index.tsx
View file @
3e7f9f97
...
@@ -6,6 +6,7 @@ import reportWebVitals from './reportWebVitals';
...
@@ -6,6 +6,7 @@ import reportWebVitals from './reportWebVitals';
import
'../node_modules/bootstrap/dist/css/bootstrap.min.css'
;
import
'../node_modules/bootstrap/dist/css/bootstrap.min.css'
;
import
'../node_modules/bootstrap/dist/js/bootstrap.bundle'
import
'../node_modules/bootstrap/dist/js/bootstrap.bundle'
import
'../node_modules/bootstrap-icons/font/bootstrap-icons.css'
import
'../node_modules/bootstrap-icons/font/bootstrap-icons.css'
// import '../node_modules/jquery/dist/jquery'
const
root
=
ReactDOM
.
createRoot
(
const
root
=
ReactDOM
.
createRoot
(
document
.
getElementById
(
'root'
)
as
HTMLElement
document
.
getElementById
(
'root'
)
as
HTMLElement
...
...
src/reduxstore/cartSlice.ts
View file @
3e7f9f97
...
@@ -52,7 +52,6 @@ const cartSlice = createSlice({
...
@@ -52,7 +52,6 @@ const cartSlice = createSlice({
removeFromCart
:
(
state
,
action
)
=>
{
removeFromCart
:
(
state
,
action
)
=>
{
state
.
loading
=
true
;
state
.
loading
=
true
;
const
removeItem
=
action
.
payload
;
const
removeItem
=
action
.
payload
;
console
.
log
(
removeItem
)
const
filteredItems
=
state
.
cartItems
.
filter
((
item
)
=>
item
.
id
!==
removeItem
.
id
);
const
filteredItems
=
state
.
cartItems
.
filter
((
item
)
=>
item
.
id
!==
removeItem
.
id
);
state
.
cartItems
=
filteredItems
;
state
.
cartItems
=
filteredItems
;
},
},
...
...
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