-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Form validation Thomas + Joanna (#45)
* Update NewAssetForm with zod validation * added routes for getting list of asset names and deleting asset by id * Implement Joanna's form validation * Update assets.py * Speed up read_asset_names query, format files --------- Co-authored-by: Thomas Shaw <printer.83mph@gmail.com>
- Loading branch information
1 parent
86ccc92
commit e3dc131
Showing
7 changed files
with
197 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import useSWR, { useSWRConfig } from 'swr'; | ||
|
||
import fetchClient from '@renderer/lib/fetch-client'; | ||
|
||
export function useAssetNames() { | ||
const { | ||
data: assetNames, | ||
error, | ||
isLoading, | ||
isValidating, | ||
mutate, | ||
} = useSWR('/api/v1/assets/names', async () => { | ||
const { data, error, response } = await fetchClient.GET('/api/v1/assets/names'); | ||
|
||
if (error) throw error; | ||
if (!response.status.toString().startsWith('2')) | ||
throw new Error(`Non-OK response with code ${response.status}: ${response.statusText}`); | ||
|
||
return data; | ||
}); | ||
|
||
return { assetNames, error, isLoading, isValidating, mutate }; | ||
} | ||
|
||
// (probably don't need this function) | ||
export function useAssetNamesRefetch() { | ||
const { mutate } = useSWRConfig(); | ||
|
||
return async () => { | ||
await mutate('/api/v1/assets/names'); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters