useSelectedAnalyticsBucket.ts19 lines · main
| 1 | import { useParams } from 'common' |
| 2 | |
| 3 | import { useIsAnalyticsBucketsEnabled } from '@/data/config/project-storage-config-query' |
| 4 | import { useAnalyticsBucketsQuery } from '@/data/storage/analytics-buckets-query' |
| 5 | |
| 6 | export const useSelectedAnalyticsBucket = () => { |
| 7 | const { ref, bucketId } = useParams() |
| 8 | const hasIcebergEnabled = useIsAnalyticsBucketsEnabled({ projectRef: ref }) |
| 9 | |
| 10 | return useAnalyticsBucketsQuery( |
| 11 | { projectRef: ref }, |
| 12 | { |
| 13 | enabled: hasIcebergEnabled, |
| 14 | select(data) { |
| 15 | return data.find((x) => x.name === bucketId) |
| 16 | }, |
| 17 | } |
| 18 | ) |
| 19 | } |