| 1 |
import { getSitePlugins } from '@page-creator/api/DataApi'; |
| 2 |
import { usePageProfile } from '@page-creator/hooks/usePageProfile'; |
| 3 |
import useSWR from 'swr'; |
| 4 |
|
| 5 |
export const useSitePlugins = ({ disableFetch = false } = {}) => { |
| 6 |
const { loading, pageProfile } = usePageProfile(); |
| 7 |
|
| 8 |
const params = { |
| 9 |
key: 'site-plugins-page-creator', |
| 10 |
pageProfile, |
| 11 |
}; |
| 12 |
const { data, error } = useSWR( |
| 13 |
loading || disableFetch ? null : params, |
| 14 |
getSitePlugins, |
| 15 |
); |
| 16 |
|
| 17 |
return { sitePlugins: data, error, loading: !data && !error }; |
| 18 |
}; |
| 19 |
|