import { useQuery } from '@tanstack/react-query';
import supabase from './supabase';
import { Listing } from './types';
export async function getListings() {
const query = `
id,
title,
price,
photos,
seller: profiles (id, name, city, state),
categories (name, slug)
`;
return supabase.from<Listing>('listings').select(query);
}
export const useGetListings = () => {
return useQuery(['home', 'listings'], () => getListings());
};
import { useQuery } from '@tanstack/react-query';
import supabase from './supabase';
import { Listing } from './types';
export async function getListings() {
const query = `
id,
title,
price,
photos,
seller: profiles (id, name, city, state),
categories (name, slug)
`;
return supabase.from<Listing>('listings').select(query);
}
export const useGetListings = () => {
return useQuery(['home', 'listings'], () => getListings());
};