Next.js Discord

Discord Forum

using data from a form

Unanswered
Masai Lion posted this in #help-forum
Open in Discord
Masai LionOP
Sorry if this is a really beginner question but im trying to query my database based on a zipcode and im having trouble actually setting up the form


this is my form component located in src/app/components/FindStoreForm.tsx
export default function FindStoreForm() {
  return (
    <form action="/" className="flex flex-col mb-2">
      <h1 className="text-center">
        Enter your zip code to find a store local to you
      </h1>
      <div className="join w-full">
        <input
          type="text"
          className="input join-item flex-grow"
          placeholder="ex. 11201"
        />
        <button className="btn join-item">&#x1F50E;</button>
      </div>
    </form>
  );
}


all i want to do is

Redirect to this page located in src/app/store-locator/results and use the entered zipcode in this function that querys my db.

export default async function Results() {

  const stores = await getStores(*******ZIPCODEHERE******) as WithId<store>[];

  return (
    <div className="p-4 flex flex-col items-center">
      <h1 className="p-4 italic text-2xl font-bold">
        Store Locator Results
      </h1>
      <FindStoreForm />

      <List_Map stores={stores}/>
    </div>
  );
}


Any help is greatly appreciated!

0 Replies