From the course: Next.js Ecommerce: Build a Shopping Platform from Scratch

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Connect review form to action

Connect review form to action

Okay, so we have our review list, we have our form, we have our action, now we just need to connect it all together. So we need that form to submit to that action. And we can do that by going into our review form. Let's bring in the action that we created in the last video. So that's called create update, create update review. And then, let's see, we have our form right here, method post, but we don't have a handler. So let's add a handler for onSubmit. And since we're using React hook form, we set that to form.handleSubmit. But then we pass in our own handler, which we'll call onSubmit. So let's come up here. Now the handle form open, this calls when we open the form, right? We click the button and we open the form. This runs, which sets the open to true, which gets passed into the dialog. And we're going to add a couple lines to this in a minute, but let's handle the submit first. And I'm just going to put a comment here. So this is the, let's say, open form handler. And then this…

Contents