Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 4x 4x 4x 183x 183x 183x 183x 4x 4x 1x 3x 183x | import { request } from '@procore/core-http';
import { useQuery } from '@tanstack/react-query';
import { useAddCompanyContext } from '../Context/AddCompanyContext';
import { ListSubregionsResponse } from '../models/ListSubregionsResponse';
export function useListSubregionsQuery(regionId: string | undefined) {
Iif (!regionId) {
regionId = 'US';
}
const { companyId } = useAddCompanyContext();
const query = useQuery<ListSubregionsResponse[]>({
queryKey: ['regions', regionId],
queryFn: async () => {
const response = await request(
`/rest/v1.0/internal/regions/${regionId}/subregions`,
{
headers: {
'Procore-Company-ID': companyId.toString(),
},
}
);
if (response.status >= 400) {
throw new Error('Failed to fetch subregions');
}
return response.json();
},
enabled: true,
retry: false,
refetchOnMount: false,
});
return query;
}
|