Skip to content

Commit

Permalink
Setup hardcoded server action.
Browse files Browse the repository at this point in the history
  • Loading branch information
stuart-bradley committed Feb 12, 2024
1 parent ea3de11 commit fadc21a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 8 additions & 0 deletions src/actions/actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"use server";

import { redirect } from "next/navigation";

export async function generateBoard(formData: FormData) {
const serializedBoard = "RST-WBSB-WTDTR-WRWS-BOG";
redirect(`/${serializedBoard}`);
}
9 changes: 4 additions & 5 deletions src/app/components/ui/BoardForm.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
"use client";

import React from "react";
import { useForm, SubmitHandler, FieldValues } from "react-hook-form";
import { useForm } from "react-hook-form";
import { ALGORITHMS, EXPANSION_ITEMS, NUM_OF_PLAYERS } from "@/lib/constants";
import { generateBoard } from "@/actions/actions";

const BoardForm: React.FC = () => {
const { register, handleSubmit } = useForm();

const onSubmit: SubmitHandler<FieldValues> = (data) => console.log(data);
const { register } = useForm();

return (
<form onSubmit={handleSubmit(onSubmit)} className="max-w-sm mx-auto">
<form action={generateBoard} className="max-w-sm mx-auto">
<fieldset>
<label
htmlFor="expansions"
Expand Down

0 comments on commit fadc21a

Please sign in to comment.