Commit 98cf432e authored by Shanelle Valencia's avatar Shanelle Valencia

[AFP-24] 🚧 Fix search issues with order type [@valencia]

parent 73dddb6a
import React, { useState, useEffect } from 'react' import React, { useState, useEffect } from 'react'
import { Link } from 'react-router-dom' import { Link } from 'react-router-dom'
import { Order } from 'Order';
const SearchOrder = (props: any) => { const SearchOrder = (props: any) => {
const orders = props.orders; const orders = props.orders;
...@@ -8,6 +9,7 @@ const SearchOrder = (props: any) => { ...@@ -8,6 +9,7 @@ const SearchOrder = (props: any) => {
const [searchResult, setSearchResult] = useState([]); const [searchResult, setSearchResult] = useState([]);
console.log("ORDERS", orders) console.log("ORDERS", orders)
// console.log("props", props)
const handleSearchInput = (event: any) => { const handleSearchInput = (event: any) => {
setSearchInput(event.target.value); setSearchInput(event.target.value);
...@@ -18,10 +20,9 @@ const SearchOrder = (props: any) => { ...@@ -18,10 +20,9 @@ const SearchOrder = (props: any) => {
} }
useEffect(() => { useEffect(() => {
if (orders.length > 0) { if (orders.length > 0) {
const res = orders.filter((order: any) => const res = orders.filter((order: Order) =>
order.orderNumber.includes(searchInput) || order.date.includes(searchInput) order.orderNumber.includes(searchInput) //|| order.date.includes(searchInput)
// console.log(orderNum)
); );
// debugger // debugger
setSearchResult(res); setSearchResult(res);
...@@ -39,12 +40,12 @@ const SearchOrder = (props: any) => { ...@@ -39,12 +40,12 @@ const SearchOrder = (props: any) => {
onChange={handleSearchInput} onChange={handleSearchInput}
/> />
<ul> <ul>
{searchResult.map((item, idx) => { {searchResult.map((item: any, idx) => {
// debugger // debugger
return ( return (
<tr key={idx}> <li key={idx}>
<Link to={"/orders/" + item}>item</Link> <Link to={"/orders/" + item.orderNumber}>{item.orderNumber}</Link>
</tr> </li>
) )
})} })}
</ul> </ul>
......
...@@ -3,7 +3,7 @@ import { Order } from 'Order' ...@@ -3,7 +3,7 @@ import { Order } from 'Order'
const orders: Order[] = [ const orders: Order[] = [
{ {
"date": "01/01/01", "date": "01/01/01",
"orderNumber": "0", "orderNumber": "025412",
"orderItems": [ "orderItems": [
{ {
"_id": "x588s78xvhs", "_id": "x588s78xvhs",
...@@ -33,7 +33,7 @@ const orders: Order[] = [ ...@@ -33,7 +33,7 @@ const orders: Order[] = [
}, },
{ {
"date": "01/02/03", "date": "01/02/03",
"orderNumber": "1", "orderNumber": "1887215",
"orderItems": [ "orderItems": [
{ {
"_id": "apsdifua", "_id": "apsdifua",
...@@ -60,7 +60,67 @@ const orders: Order[] = [ ...@@ -60,7 +60,67 @@ const orders: Order[] = [
"category": "paper weights" "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"
}
]
},
] ]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment