I have a basic search form that when the action is submitted I would like to update the resource with the filtered result. Is there a simple way to do this? Here's my code as an example:
export const useRestaurants = routeLoader$(async () => {
return await prisma.restaurant.findMany();
});
export const useSearchFormLoader = routeLoader$<InitialValues<SearchForm>>(() => ({
searchPhrase: "",
}));
export const useSearchFormAction = formAction$<SearchForm>((values) => {
// I've got the search values here, but I don't know how to use them to update the restaurants list
}, zodForm$(searchSchema));
export default component$(() => {
return (
<Main>
<H1>Discover Northern Ireland's Best Restaurants</H1>
<P>
Find the perfect spot for your next meal in Belfast, Derry, or anywhere in between
with our directory of top-rated restaurants in Northern Ireland. Simply enter your
address or location to browse our listings and discover everything from cozy local
favorites to fine dining experiences. Our comprehensive directory makes it easy to
treat your taste buds to a culinary adventure, with something for every taste and
budget. Start exploring today!
</P>
<SearchForm />
<DivGrid>
<Resource
value={useRestaurants()}
onPending={() => <div>Loading restaurants...</div>}
onResolved={(restaurants) => (
<>
{restaurants &&
restaurants.map((restaurant) => (
<RestaurantCard restaurant={restaurant} />
))}
</>
)}
/>
</DivGrid>
</Main>
);
});