Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
clone_excelso
Project
Project
Details
Activity
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
Prasetya Saputra
clone_excelso
Commits
e309e7c4
Commit
e309e7c4
authored
Apr 22, 2020
by
Afid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
coba yu
parent
ce1583f3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
17 deletions
+24
-17
globalReducer.js
redux/globalReducer.js
+24
-17
No files found.
redux/globalReducer.js
View file @
e309e7c4
...
@@ -210,32 +210,39 @@ const rootReducer = (state = globalState, action) => {
...
@@ -210,32 +210,39 @@ const rootReducer = (state = globalState, action) => {
let
addedItem
=
action
.
data
.
item
let
addedItem
=
action
.
data
.
item
let
is_exist
=
state
.
order_item
.
find
(
item
=>
addedItem
.
id
==
item
.
id
)
let
is_exist
=
state
.
order_item
.
find
(
item
=>
addedItem
.
id
==
item
.
id
)
let
order_item
=
state
.
order_item
;
let
order_item
=
[]
if
(
is_exist
)
{
if
(
is_exist
)
{
// update
// update
addedItem
.
quantity
+=
1
addedItem
.
quantity
+=
1
console
.
log
(
'Update : '
+
JSON
.
stringify
(
addedItem
))
console
.
log
(
'Update : '
+
JSON
.
stringify
(
addedItem
))
let
quantity
=
state
.
order_quantity
+
1
let
total
=
parseInt
(
state
.
order_total
)
+
parseInt
(
addedItem
.
price
)
updated_data
=
[]
for
(
let
i
=
0
;
i
<
state
.
order_item
.
length
;
i
++
)
{
return
{
const
old_data
=
state
.
order_item
[
i
];
...
state
,
const
data
=
old_data
;
order_quantity
:
quantity
,
if
(
old_data
.
id
==
addedItem
.
id
)
{
order_total
:
total
data
=
{...
old_data
,
...
addedItem
}
}
updated_data
.
push
(
data
)
}
}
order_item
=
updated_data
}
else
{
}
else
{
// add
// add
addedItem
.
quantity
=
1
addedItem
.
quantity
=
1
console
.
log
(
'Baru : '
+
JSON
.
stringify
(
addedItem
))
console
.
log
(
'Baru : '
+
JSON
.
stringify
(
addedItem
))
let
quantity
=
state
.
order_quantity
+
1
order_item
=
[...
state
.
order_item
,
addedItem
]
let
total
=
parseInt
(
state
.
order_total
)
+
parseInt
(
addedItem
.
price
)
}
return
{
let
quantity
=
state
.
order_quantity
+
1
...
state
,
let
total
=
parseInt
(
state
.
order_total
)
+
parseInt
(
addedItem
.
price
)
order_item
:
[...
state
.
order_item
,
addedItem
],
order_quantity
:
quantity
,
return
{
order_total
:
total
...
state
,
}
order_item
:
order_item
,
order_quantity
:
quantity
,
order_total
:
total
}
}
}
}
...
...
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