1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24import { queryOptions } from '@tanstack/react-query';
import { getProperties, getPropertyById } from '~/services';
// Query for all properties
export const propertiesQuery = () => queryOptions({
queryKey: ['properties'],
queryFn: getProperties,
});
// Query for a specific property
export const propertyQuery = (propertyId: string) => queryOptions({
queryKey: ['property', propertyId],
queryFn: async () => {
const property = await getPropertyById(propertyId);
if (!property) {
throw new Response('', {
status: 404,
statusText: 'Property Not Found',
});
}
return property;
},
});