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
b9757167
Commit
b9757167
authored
May 07, 2021
by
Shanelle Valencia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[AFP-24]
🚧
Fix search issues with backend data [
@svalencia
]
parent
77f707cc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
19 deletions
+10
-19
SearchOrder.tsx
src/components/SearchOrder.tsx
+9
-18
OrderIndexPage.tsx
src/pages/OrderIndexPage.tsx
+1
-1
No files found.
src/components/SearchOrder.tsx
View file @
b9757167
import
React
,
{
useState
,
useEffect
}
from
'react'
import
{
Link
}
from
'react-router-dom'
// import { Order } from 'Order';
import
{
useAllOrders
}
from
'hooks'
//
import { useAllOrders } from 'hooks'
const
SearchOrder
=
(
props
:
any
)
=>
{
// const orders = props.orders;
const
{
orders
}
=
useAllOrders
();
const
{
orders
}
=
props
;
const
[
searchInput
,
setSearchInput
]
=
useState
(
""
);
const
[
searchResult
,
setSearchResult
]
=
useState
([]);
const
[
searchResult
,
setSearchResult
]
=
useState
<
string
[]
>
([]);
console
.
log
(
"ORDERS"
,
orders
)
// console.log("props", props)
const
handleSearchInput
=
(
event
:
any
)
=>
{
setSearchInput
(
event
.
target
.
value
);
}
const
resetInputField
=
()
=>
{
setSearchInput
(
""
);
}
useEffect
(()
=>
{
if
(
orders
.
length
>
0
)
{
const
res
=
orders
.
filter
((
order
:
any
)
=>
order
.
id
.
includes
(
searchInput
)
//|| order.date.includes(searchInput)
// console.log(orderNum)
);
// debugger
// setSearchResult(res);
}
const
filtered
=
orders
.
filter
((
order
:
any
)
=>
order
.
id
.
includes
(
searchInput
)
//|| order.date.includes(searchInput)
);
// debugger
setSearchResult
(
filtered
);
},
[
searchInput
]);
...
...
@@ -52,7 +43,7 @@ const SearchOrder = (props: any) => {
// debugger
return
(
<
li
key=
{
idx
}
>
<
Link
to=
{
"/orders/"
+
item
.
orderNumber
}
>
{
item
.
orderNumber
}
</
Link
>
<
Link
to=
{
"/orders/"
+
item
.
id
}
>
{
item
.
id
}
</
Link
>
</
li
>
)
})
}
...
...
src/pages/OrderIndexPage.tsx
View file @
b9757167
...
...
@@ -28,6 +28,7 @@ const OrderIndexPage = () => {
return
(
<
div
className=
"table-div"
>
<
SearchOrder
orders=
{
orders
}
/>
<
Table
variant=
"striped"
colorScheme=
"linkedin"
size=
"lg"
>
<
Tbody
>
<
Tr
>
...
...
@@ -38,7 +39,6 @@ const OrderIndexPage = () => {
{
orderDetailsArr
}
</
Tbody
>
</
Table
>
<
SearchOrder
orders=
{
orders
}
/>
</
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