()
| 146 | |
| 147 | useEffect(() => { |
| 148 | const fetchItems = async () => { |
| 149 | setFetching(true) |
| 150 | const f = { query: debouncedQuery || '', page, limit: globalPageSize ?? pageSize } |
| 151 | if (tabs.find(t => t.name === queryTab)) { |
| 152 | f.tab = queryTab |
| 153 | } else { |
| 154 | setQueryTab(defaultTab) |
| 155 | f.tab = undefined |
| 156 | } |
| 157 | |
| 158 | if (orderValidator(order)) { |
| 159 | f.order = order |
| 160 | } else { |
| 161 | if (isMounted.current) { |
| 162 | setOrder(defaultOrder) |
| 163 | } |
| 164 | f.order = defaultOrder |
| 165 | } |
| 166 | |
| 167 | try { |
| 168 | if (f.query && searchItemsAction) { |
| 169 | await dispatch(attachPromise(searchItemsAction(f))) |
| 170 | } else { |
| 171 | await dispatch(attachPromise(getItemsAction(f))) |
| 172 | setTab(f.tab) |
| 173 | } |
| 174 | if (isMounted.current) { |
| 175 | setFetching(false) |
| 176 | setInitialFetch(false) |
| 177 | } |
| 178 | } catch (error) { |
| 179 | if (isMounted.current) { |
| 180 | setError(error) |
| 181 | setFetching(false) |
| 182 | } |
| 183 | } |
| 184 | } |
| 185 | fetchItems() |
| 186 | }, [ |
| 187 | debouncedQuery, |
no test coverage detected