Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
warehouse-management
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
1
Merge Requests
1
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
Ascend
warehouse-management
Commits
a3090b84
Commit
a3090b84
authored
May 06, 2021
by
Darrick Yong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update frontend with working backend routes
parent
f9d7b5e3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
87 additions
and
148 deletions
+87
-148
order_actions.js
frontend/src/actions/order_actions.js
+2
-14
OrderDetails.jsx
frontend/src/components/order/OrderDetails.jsx
+1
-42
orders_reducer.js
frontend/src/reducers/entities/orders_reducer.js
+0
-6
orders_api_util.jsx
frontend/src/util/orders_api_util.jsx
+84
-86
No files found.
frontend/src/actions/order_actions.js
View file @
a3090b84
import
*
as
OrderAPIUtil
from
'../util/orders_api_util'
;
export
const
RECEIVE_ORDERS
=
'RECEIVE_ORDERS'
;
export
const
RECEIVE_ORDER
=
'RECEIVE_ORDER'
;
export
const
UPDATE_ORDER
=
'UPDATE_ORDER'
;
const
receiveOrders
=
(
orders
)
=>
({
...
...
@@ -9,11 +8,6 @@ const receiveOrders = (orders) => ({
orders
,
})
const
receiveOrder
=
(
order
)
=>
({
type
:
RECEIVE_ORDER
,
order
,
})
const
updateOrder
=
(
order
)
=>
({
type
:
UPDATE_ORDER
,
order
,
...
...
@@ -26,16 +20,10 @@ export const fetchOrders = () => (dispatch) => {
});
}
export
const
createOrder
=
(
order
)
=>
(
dispatch
)
=>
OrderAPIUtil
.
createOrder
(
order
)
.
then
(
res
=>
{
dispatch
(
receiveOrder
(
res
.
data
))
});
export
const
editOrder
=
(
order
)
=>
(
dispatch
)
=>
{
OrderAPIUtil
.
editOrder
(
order
)
.
then
(
res
=>
{
//
debugger
dispatch
(
updateOrder
(
res
))
debugger
dispatch
(
updateOrder
(
res
.
data
))
});
}
\ No newline at end of file
frontend/src/components/order/OrderDetails.jsx
View file @
a3090b84
...
...
@@ -2,45 +2,6 @@ import ItemDetails from "./ItemDetails";
const
OrderDetails
=
({
order
,
showDetails
})
=>
{
const
sampleItems
=
[
{
itemId
:
"17"
,
itemName
:
"Apple iPhone"
,
itemQuantity
:
4
,
itemPrice
:
17.99
,
itemSku
:
8765309
,
},
{
itemId
:
"12"
,
itemName
:
"Google Pixel"
,
itemQuantity
:
42
,
itemPrice
:
17.99
,
itemSku
:
8715309
,
},
{
itemId
:
"123"
,
itemName
:
"Google Pixel"
,
itemQuantity
:
42
,
itemPrice
:
17.99
,
itemSku
:
8715309
,
},
{
itemId
:
"124"
,
itemName
:
"Google Pixel"
,
itemQuantity
:
42
,
itemPrice
:
17.99
,
itemSku
:
8715309
,
},
{
itemId
:
"125"
,
itemName
:
"Google Pixel"
,
itemQuantity
:
42
,
itemPrice
:
17.99
,
itemSku
:
8715309
,
},
];
return
(
<
div
className=
{
`order-details ${showDetails ? "animate" : ""}`
}
>
<
div
className=
"order-details-container"
>
...
...
@@ -48,12 +9,10 @@ const OrderDetails = ({ order, showDetails }) => {
{
`Order Details - Warehouse Order #: ${order.id}`
}
</
div
>
<
ul
>
{
sample
Items
.
map
(
item
=>
(
{
order
.
order
Items
.
map
(
item
=>
(
<
ItemDetails
key=
{
item
.
itemId
}
item=
{
item
}
/>
))
}
</
ul
>
</
div
>
</
div
>
)
...
...
frontend/src/reducers/entities/orders_reducer.js
View file @
a3090b84
import
{
RECEIVE_ORDER
,
RECEIVE_ORDERS
,
UPDATE_ORDER
,
}
from
"../../actions/order_actions"
;
...
...
@@ -13,7 +12,6 @@ const OrdersReducer = (oldState = initialState, action) => {
Object
.
freeze
(
oldState
);
const
newState
=
{
...
oldState
};
const
order
=
action
.
order
||
null
;
switch
(
action
.
type
)
{
case
RECEIVE_ORDERS
:
const
orderState
=
{
...
...
@@ -27,10 +25,6 @@ const OrdersReducer = (oldState = initialState, action) => {
orderState
.
byOrderId
[
order
.
orderId
]
=
order
;
})
return
orderState
;
case
RECEIVE_ORDER
:
newState
.
byId
[
order
.
id
]
=
order
;
newState
.
allIds
.
push
(
order
.
id
);
return
newState
;
case
UPDATE_ORDER
:
newState
.
byId
[
order
.
id
]
=
order
;
return
newState
;
...
...
frontend/src/util/orders_api_util.jsx
View file @
a3090b84
import
axios
from
'axios'
;
const
RECEIVED
=
"RECEIVED"
;
//
const RECEIVED = "RECEIVED";
// const FULFILLED = "FULFILLED";
// const CANCELLED = "CANCELLED";
const
sampleGetAll
=
[
// allIds: ["1", "2", "3"],
// byId: {
{
id
:
"1"
,
orderId
:
"o1"
,
status
:
RECEIVED
,
orderItems
:
[
{
itemId
:
"17"
,
itemName
:
"Apple iPhone"
,
itemQuantity
:
4
,
itemPrice
:
17.99
,
itemSku
:
8765309
,
},
{
itemId
:
"Google Pixel"
,
itemName
:
"Item 2"
,
itemQuantity
:
42
,
itemPrice
:
17.99
,
itemSku
:
8715309
,
},
],
},
{
id
:
"2"
,
orderId
:
"o2"
,
status
:
RECEIVED
,
orderItems
:
[
{
itemId
:
"17"
,
itemName
:
"Item 1"
,
itemQuantity
:
3
,
itemPrice
:
17.99
,
itemSku
:
8765309
,
},
{
itemId
:
"18"
,
itemName
:
"Item 2"
,
itemQuantity
:
41
,
itemPrice
:
17.99
,
itemSku
:
8715309
,
},
],
},
{
id
:
"3"
,
orderId
:
"o3"
,
status
:
RECEIVED
,
orderItems
:
[
{
itemId
:
"17"
,
itemName
:
"Item 1"
,
itemQuantity
:
2
,
itemPrice
:
17.99
,
itemSku
:
8765309
,
},
{
itemId
:
"18"
,
itemName
:
"Item 2"
,
itemQuantity
:
40
,
itemPrice
:
17.99
,
itemSku
:
8715309
,
},
],
},
// },
];
//
const sampleGetAll = [
//
// allIds: ["1", "2", "3"],
//
// byId: {
//
{
//
id: "1",
//
orderId: "o1",
//
status: RECEIVED,
//
orderItems: [
//
{
//
itemId: "17",
//
itemName: "Apple iPhone",
//
itemQuantity: 4,
//
itemPrice: 17.99,
//
itemSku: 8765309,
//
},
//
{
//
itemId: "Google Pixel",
//
itemName: "Item 2",
//
itemQuantity: 42,
//
itemPrice: 17.99,
//
itemSku: 8715309,
//
},
//
],
//
},
//
{
//
id: "2",
//
orderId: "o2",
//
status: RECEIVED,
//
orderItems: [
//
{
//
itemId: "17",
//
itemName: "Item 1",
//
itemQuantity: 3,
//
itemPrice: 17.99,
//
itemSku: 8765309,
//
},
//
{
//
itemId: "18",
//
itemName: "Item 2",
//
itemQuantity: 41,
//
itemPrice: 17.99,
//
itemSku: 8715309,
//
},
//
],
//
},
//
{
//
id: "3",
//
orderId: "o3",
//
status: RECEIVED,
//
orderItems: [
//
{
//
itemId: "17",
//
itemName: "Item 1",
//
itemQuantity: 2,
//
itemPrice: 17.99,
//
itemSku: 8765309,
//
},
//
{
//
itemId: "18",
//
itemName: "Item 2",
//
itemQuantity: 40,
//
itemPrice: 17.99,
//
itemSku: 8715309,
//
},
//
],
//
},
//
// },
//
];
const
sampleNew
=
{
id
:
"4"
,
orderId
:
"o4"
,
status
:
RECEIVED
,
};
//
const sampleNew = {
//
id: "4",
//
orderId: "o4",
//
status: RECEIVED,
//
};
// const getAllPromise = new Promise( (resolve, reject) => {
// resolve(sampleGetAll)
// })
const
createNewPromise
=
new
Promise
(
(
resolve
,
reject
)
=>
{
resolve
(
sampleNew
)
})
//
const createNewPromise = new Promise( (resolve, reject) => {
//
resolve(sampleNew)
//
})
// export const getOrders = () => {
// return getAllPromise;
// };
export
const
createOrder
=
(
order
)
=>
{
return
createNewPromise
;
// export const createOrder = (order) => {
// return createNewPromise;
// }
export
const
getOrders
=
()
=>
{
return
axios
.
get
(
`http://localhost:8080/api/orders`
);
}
export
const
editOrder
=
(
order
)
=>
{
return
new
Promise
(
(
resolve
,
reject
)
=>
{
resolve
(
order
);
})
debugger
;
return
axios
.
put
(
`http://localhost:8080/api/orders/
${
order
.
id
}
`
,
order
)
}
export
const
getOrders
=
()
=>
{
return
axios
.
get
(
"http://localhost:8080/api/orders"
);
}
\ No newline at end of file
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