(page: number)
| 241 | } |
| 242 | |
| 243 | async function getParts(page: number) { |
| 244 | setLoading(true); |
| 245 | try { |
| 246 | const res = await fetch("/api/parts?page=" + page).then( |
| 247 | (response) => |
| 248 | response.json().then((data) => ({ |
| 249 | status: response.status, |
| 250 | body: data, |
| 251 | })) |
| 252 | ); |
| 253 | if (res.status !== 200) { |
| 254 | throw new Error(res.body.message); |
| 255 | } |
| 256 | const response = res.body.parts as PartState[]; |
| 257 | if (response) { |
| 258 | setParts(response); |
| 259 | } |
| 260 | // setParts(res.body); |
| 261 | } catch (e: ErrorCallback | any) { |
| 262 | console.error(e.message); |
| 263 | } |
| 264 | setLoading(false); |
| 265 | } |
| 266 | |
| 267 | async function clearSearch() { |
| 268 | setIsSearchResult(false); |
no outgoing calls
no test coverage detected