Skip to content

Commit

Permalink
update join party ux
Browse files Browse the repository at this point in the history
  • Loading branch information
minhd-vu committed Feb 27, 2024
1 parent 7edec85 commit 60597a1
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions components/JoinParty.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import { useContext } from "react";
import { SubmitHandler, useForm } from "react-hook-form";
import { Controller, SubmitHandler, useForm } from "react-hook-form";
import { useSWRConfig } from "swr";
import { ErrorContext } from "./App";

Expand All @@ -11,7 +11,7 @@ type Inputs = {

export default function JoinParty() {
const { mutate } = useSWRConfig();
const { register, handleSubmit } = useForm<Inputs>();
const { handleSubmit, control } = useForm<Inputs>();
const { setError } = useContext(ErrorContext);

const onSubmit: SubmitHandler<Inputs> = async ({ code }) => {
Expand All @@ -33,11 +33,18 @@ export default function JoinParty() {

return (
<form onSubmit={handleSubmit(onSubmit)}>
<input
{...register("code")}
className="input input-bordered"
placeholder="Party Code"
required
<Controller
name="code"
control={control}
render={({ field }) => (
<input
{...field}
onChange={(e) => field.onChange(e.target.value.toUpperCase())}
className="input input-bordered"
placeholder="Party Code"
required
/>
)}
/>
<button className="btn btn-primary">Join Party</button>
</form>
Expand Down

0 comments on commit 60597a1

Please sign in to comment.