-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
63 additions
and
79 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
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,46 @@ | ||
// @ts-check | ||
/** | ||
* This is a file used especially in this `taxonomy` module. | ||
* | ||
* We are using a new approach, using `useQuery` to build and execute the queries to the APIs. | ||
* This approach accelerates the development. | ||
* | ||
* In this file you will find two types of hooks: | ||
* - Hooks that builds the query with `useQuery`. These hooks are not used outside of this file. | ||
* Ex. useTaxonomyListData. | ||
* - Hooks that calls the query hook, prepare and return the data. | ||
* Ex. useTaxonomyListDataResponse & useIsTaxonomyListDataLoaded. | ||
*/ | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { getTaxonomyListData } from './api'; | ||
|
||
/** | ||
* Builds the query yo get the taxonomy list | ||
* @returns {import("./types.mjs").UseQueryResult} | ||
*/ | ||
const useTaxonomyListData = () => ( | ||
useQuery({ | ||
queryKey: ['taxonomyList'], | ||
queryFn: getTaxonomyListData, | ||
}) | ||
); | ||
|
||
/** | ||
* Gets the taxonomy list data | ||
* @returns {import("./types.mjs").TaxonomyListData | undefined} | ||
*/ | ||
export const useTaxonomyListDataResponse = () => { | ||
const response = useTaxonomyListData(); | ||
if (response.status === 'success') { | ||
return response.data; | ||
} | ||
return undefined; | ||
}; | ||
|
||
/** | ||
* Returns the status of the taxonomy list query | ||
* @returns {boolean} | ||
*/ | ||
export const useIsTaxonomyListDataLoaded = () => ( | ||
useTaxonomyListData().status === 'success' | ||
); |
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 was deleted.
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 was deleted.
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