Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
order-management-react
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
Ascend
order-management-react
Commits
98cf432e
Commit
98cf432e
authored
May 05, 2021
by
Shanelle Valencia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[AFP-24]
🚧
Fix search issues with order type [@valencia]
parent
73dddb6a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
11 deletions
+72
-11
SearchOrder.tsx
src/components/SearchOrder.tsx
+9
-8
mock-order-data.ts
src/services/mock-order-data.ts
+63
-3
No files found.
src/components/SearchOrder.tsx
View file @
98cf432e
import
React
,
{
useState
,
useEffect
}
from
'react'
import
{
Link
}
from
'react-router-dom'
import
{
Order
}
from
'Order'
;
const
SearchOrder
=
(
props
:
any
)
=>
{
const
orders
=
props
.
orders
;
...
...
@@ -8,6 +9,7 @@ const SearchOrder = (props: any) => {
const
[
searchResult
,
setSearchResult
]
=
useState
([]);
console
.
log
(
"ORDERS"
,
orders
)
// console.log("props", props)
const
handleSearchInput
=
(
event
:
any
)
=>
{
setSearchInput
(
event
.
target
.
value
);
...
...
@@ -18,10 +20,9 @@ const SearchOrder = (props: any) => {
}
useEffect
(()
=>
{
if
(
orders
.
length
>
0
)
{
const
res
=
orders
.
filter
((
order
:
any
)
=>
order
.
orderNumber
.
includes
(
searchInput
)
||
order
.
date
.
includes
(
searchInput
)
// console.log(orderNum)
if
(
orders
.
length
>
0
)
{
const
res
=
orders
.
filter
((
order
:
Order
)
=>
order
.
orderNumber
.
includes
(
searchInput
)
//|| order.date.includes(searchInput)
);
// debugger
setSearchResult
(
res
);
...
...
@@ -39,12 +40,12 @@ const SearchOrder = (props: any) => {
onChange=
{
handleSearchInput
}
/>
<
ul
>
{
searchResult
.
map
((
item
,
idx
)
=>
{
{
searchResult
.
map
((
item
:
any
,
idx
)
=>
{
// debugger
return
(
<
tr
key=
{
idx
}
>
<
Link
to=
{
"/orders/"
+
item
}
>
item
</
Link
>
</
tr
>
<
li
key=
{
idx
}
>
<
Link
to=
{
"/orders/"
+
item
.
orderNumber
}
>
{
item
.
orderNumber
}
</
Link
>
</
li
>
)
})
}
</
ul
>
...
...
src/services/mock-order-data.ts
View file @
98cf432e
...
...
@@ -3,7 +3,7 @@ import { Order } from 'Order'
const
orders
:
Order
[]
=
[
{
"date"
:
"01/01/01"
,
"orderNumber"
:
"0"
,
"orderNumber"
:
"0
25412
"
,
"orderItems"
:
[
{
"_id"
:
"x588s78xvhs"
,
...
...
@@ -33,7 +33,7 @@ const orders: Order[] = [
},
{
"date"
:
"01/02/03"
,
"orderNumber"
:
"1"
,
"orderNumber"
:
"1
887215
"
,
"orderItems"
:
[
{
"_id"
:
"apsdifua"
,
...
...
@@ -60,7 +60,67 @@ const orders: Order[] = [
"category"
:
"paper weights"
}
]
}
},
{
"date"
:
"07/17/07"
,
"orderNumber"
:
"587125"
,
"orderItems"
:
[
{
"_id"
:
"851adsafa6"
,
"sku"
:
"9563285"
,
"upc"
:
"18118181818"
,
"productName"
:
"Keyboard"
,
"productDescription"
:
"what you use to type"
,
"price"
:
1999.99
,
"quantity"
:
20
,
"productImageUrl"
:
"https://picsum.photos/100/100"
,
"brand"
:
"Apple"
,
"category"
:
"Electronics"
},
{
"_id"
:
"adv2515"
,
"sku"
:
"282828"
,
"upc"
:
"9892956"
,
"productName"
:
"Trackpad"
,
"productDescription"
:
"apple trackpad"
,
"price"
:
599.99
,
"quantity"
:
10
,
"productImageUrl"
:
"https://picsum.photos/100/100"
,
"brand"
:
"Apple"
,
"category"
:
"Electronics"
}
]
},
{
"date"
:
"10/11/21"
,
"orderNumber"
:
"852634"
,
"orderItems"
:
[
{
"_id"
:
"855adf4s"
,
"sku"
:
"5311469"
,
"upc"
:
"271156325"
,
"productName"
:
"Notepad"
,
"productDescription"
:
"something to write on"
,
"price"
:
25.50
,
"quantity"
:
39
,
"productImageUrl"
:
"https://picsum.photos/100/100"
,
"brand"
:
"Notes"
,
"category"
:
"Office supplies"
},
{
"_id"
:
"csd125"
,
"sku"
:
"256324"
,
"upc"
:
"8775632"
,
"productName"
:
"Pen"
,
"productDescription"
:
"pennnn"
,
"price"
:
10.50
,
"quantity"
:
50
,
"productImageUrl"
:
"https://picsum.photos/100/100"
,
"brand"
:
"Notes"
,
"category"
:
"Office supplies"
}
]
},
]
...
...
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