| 1 |
import { getSitePlugins } from '@launch/api/DataApi'; |
| 2 |
import { useSiteProfile } from '@launch/hooks/useSiteProfile'; |
| 3 |
import { useUserSelectionStore } from '@launch/state/user-selections'; |
| 4 |
import useSWR from 'swr'; |
| 5 |
|
| 6 |
export const useSitePlugins = ({ disableFetch = false } = {}) => { |
| 7 |
const { loading, siteProfile } = useSiteProfile(); |
| 8 |
const { siteQA } = useUserSelectionStore(); |
| 9 |
|
| 10 |
const params = { |
| 11 |
key: 'site-plugins', |
| 12 |
siteProfile, |
| 13 |
siteQA, |
| 14 |
}; |
| 15 |
const { data, error } = useSWR( |
| 16 |
loading || disableFetch ? null : params, |
| 17 |
getSitePlugins, |
| 18 |
); |
| 19 |
|
| 20 |
return { sitePlugins: data, error, loading: !data && !error }; |
| 21 |
}; |
| 22 |
|