| @@ -67,6 +67,7 @@ export type ItemsResult = { | |||||
| export type Result = { | export type Result = { | ||||
| item: ItemsResult; | item: ItemsResult; | ||||
| qcChecks: ItemQc[]; | qcChecks: ItemQc[]; | ||||
| qcType?: string; | |||||
| }; | }; | ||||
| export const fetchAllItems = cache(async () => { | export const fetchAllItems = cache(async () => { | ||||
| return serverFetchJson<ItemsResult[]>(`${BASE_API_URL}/items`, { | return serverFetchJson<ItemsResult[]>(`${BASE_API_URL}/items`, { | ||||
| @@ -51,6 +51,7 @@ const CreateItemWrapper: React.FC<Props> & SubComponents = async ({ id }) => { | |||||
| qcChecks: qcChecks, | qcChecks: qcChecks, | ||||
| qcChecks_active: activeRows, | qcChecks_active: activeRows, | ||||
| qcCategoryId: item.qcCategory?.id, | qcCategoryId: item.qcCategory?.id, | ||||
| qcType: result.qcType, | |||||
| store_id: item?.store_id, | store_id: item?.store_id, | ||||
| warehouse: item?.warehouse, | warehouse: item?.warehouse, | ||||
| area: item?.area, | area: item?.area, | ||||
| @@ -124,12 +124,13 @@ const ItemsSearch: React.FC<Props> = ({ items }) => { | |||||
| ); | ); | ||||
| useEffect(() => { | useEffect(() => { | ||||
| refetchData(filterObj); | |||||
| // Only refetch when paging changes AND we have already searched (filterObj has been set by search) | |||||
| if (Object.keys(filterObj).length > 0 || filteredItems.length > 0) { | |||||
| refetchData(filterObj); | |||||
| } | |||||
| }, [ | }, [ | ||||
| filterObj, | |||||
| pagingController.pageNum, | pagingController.pageNum, | ||||
| pagingController.pageSize, | pagingController.pageSize, | ||||
| refetchData, | |||||
| ]); | ]); | ||||
| const columns = useMemo<Column<ItemsResultWithStatus>[]>( | const columns = useMemo<Column<ItemsResultWithStatus>[]>( | ||||
| @@ -181,25 +182,20 @@ const ItemsSearch: React.FC<Props> = ({ items }) => { | |||||
| ); | ); | ||||
| const onReset = useCallback(() => { | const onReset = useCallback(() => { | ||||
| setFilteredItems(items); | |||||
| }, [items]); | |||||
| setFilteredItems([]); | |||||
| setFilterObj({}); | |||||
| setTotalCount(0); | |||||
| }, []); | |||||
| return ( | return ( | ||||
| <> | <> | ||||
| <SearchBox | <SearchBox | ||||
| criteria={searchCriteria} | criteria={searchCriteria} | ||||
| onSearch={(query) => { | onSearch={(query) => { | ||||
| // setFilteredItems( | |||||
| // items.filter((pm) => { | |||||
| // return ( | |||||
| // pm.code.toLowerCase().includes(query.code.toLowerCase()) && | |||||
| // pm.name.toLowerCase().includes(query.name.toLowerCase()) | |||||
| // ); | |||||
| // }) | |||||
| // ); | |||||
| setFilterObj({ | setFilterObj({ | ||||
| ...query, | ...query, | ||||
| }); | }); | ||||
| refetchData(query); | |||||
| }} | }} | ||||
| onReset={onReset} | onReset={onReset} | ||||
| /> | /> | ||||
| @@ -65,7 +65,7 @@ | |||||
| "Last updated": "最後更新", | "Last updated": "最後更新", | ||||
| "Truck Schedule": "車輛班次", | "Truck Schedule": "車輛班次", | ||||
| "Time Remaining": "剩餘時間", | "Time Remaining": "剩餘時間", | ||||
| "No. of Shops": "門店數量", | |||||
| "No. of Shops": "門店數量[提票數量]", | |||||
| "Total Items": "總貨品數", | "Total Items": "總貨品數", | ||||
| "Tickets Released": "已發放成品出倉單", | "Tickets Released": "已發放成品出倉單", | ||||
| "First Ticket Start": "首單開始時間", | "First Ticket Start": "首單開始時間", | ||||
| @@ -36,7 +36,7 @@ | |||||
| "LocationCode": "預設位置", | "LocationCode": "預設位置", | ||||
| "DefaultLocationCode": "預設位置", | "DefaultLocationCode": "預設位置", | ||||
| "Special Type": "特殊類型", | "Special Type": "特殊類型", | ||||
| "None": "無", | |||||
| "None": "正常", | |||||
| "isEgg": "雞蛋", | "isEgg": "雞蛋", | ||||
| "isFee": "費用", | "isFee": "費用", | ||||
| "isBag": "袋子", | "isBag": "袋子", | ||||