fix: Resolve eslint errors in Orders components
Fixed all eslint errors and warnings in modified files.
Issues Fixed:
1. OrderCard.tsx: Fixed statusStyle type mismatch
- Changed from Record<string, string> to Record<string, { bg: string; text: string }>
- Updated usage to match the correct type
2. Edit.tsx: Fixed React hooks rule violation
- Moved useEffect before early returns
- React hooks must be called in the same order every render
3. Orders/index.tsx: Fixed React Compiler memoization warning
- Changed useMemo dependency from data?.rows to data
- Extracted rows inside useMemo to satisfy compiler
Result:
✅ Zero errors in our modified files
✅ Zero warnings in our modified files
✅ Code follows React best practices
✅ Ready for production!
This commit is contained in:
@@ -133,16 +133,17 @@ export default function Orders() {
|
||||
|
||||
// Filter orders by search query
|
||||
const filteredOrders = React.useMemo(() => {
|
||||
if (!data?.rows) return [];
|
||||
if (!searchQuery.trim()) return data.rows;
|
||||
|
||||
const rows = data?.rows;
|
||||
if (!rows) return [];
|
||||
if (!searchQuery.trim()) return rows;
|
||||
|
||||
const query = searchQuery.toLowerCase();
|
||||
return data.rows.filter(order =>
|
||||
return rows.filter((order: any) =>
|
||||
order.number?.toString().includes(query) ||
|
||||
order.customer?.toLowerCase().includes(query) ||
|
||||
order.status?.toLowerCase().includes(query)
|
||||
);
|
||||
}, [data?.rows, searchQuery]);
|
||||
}, [data, searchQuery]);
|
||||
|
||||
// Count active filters
|
||||
const activeFiltersCount = React.useMemo(() => {
|
||||
|
||||
Reference in New Issue
Block a user