Skip to content

Commit

Permalink
chore: update files
Browse files Browse the repository at this point in the history
  • Loading branch information
haru52 committed May 25, 2024
1 parent d29e871 commit cf36e4e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/app/_components/signup-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ import { api } from "~/trpc/react";
export function SignupForm() {
const router = useRouter();
const [screenName, setScreenName] = useState("");
const { mutate, error, isPending } = api.user.update.useMutation({
const [isDisabled, setIsDisabled] = useState(false);
const { mutate, error } = api.user.update.useMutation({
onSuccess: () => {
router.push(`/`);
router.refresh();
},
onError: () => {
setIsDisabled(false);
},
});
const screenNameErrors: string[] = [];
if (error?.data?.zodError?.fieldErrors.screenName !== undefined) {
Expand All @@ -26,6 +30,7 @@ export function SignupForm() {
<form
onSubmit={async (e) => {
e.preventDefault();
setIsDisabled(true);
mutate({
screenName,
});
Expand All @@ -47,9 +52,9 @@ export function SignupForm() {
<div className="form-control mx-auto mt-7 w-full max-w-xs">
<input
type="submit"
value={isPending ? "サインアップ中…" : "サインアップ"}
value={isDisabled ? "サインアップ中…" : "サインアップ"}
className="btn btn-primary btn-block"
disabled={isPending}
disabled={isDisabled}
/>
</div>
</form>
Expand Down

0 comments on commit cf36e4e

Please sign in to comment.