From 1fdff72c6eeece51d24fb5889a2a1e23a4619dec Mon Sep 17 00:00:00 2001 From: iMADi-ARCH Date: Sat, 20 Apr 2024 21:33:56 +0530 Subject: [PATCH] feat: use form for demo --- www/src/components/Demo.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/www/src/components/Demo.tsx b/www/src/components/Demo.tsx index 36b5fbb..7f6e8c5 100644 --- a/www/src/components/Demo.tsx +++ b/www/src/components/Demo.tsx @@ -2,7 +2,7 @@ import { checkProfanity } from '@/actions' import { useMutation } from '@tanstack/react-query' -import { useState } from 'react' +import { FormEvent, useState } from 'react' import { Button } from './ui/button' import { Input } from './ui/input' import { Icons } from './Icons' @@ -12,6 +12,11 @@ const Demo = () => { 'this is definitely not a swear word' ) + const handleSubmit = (e: FormEvent) => { + e.preventDefault(); + mutate({ message }); + } + const { data, mutate, isPending, error } = useMutation({ mutationKey: ['check-profanity'], mutationFn: checkProfanity, @@ -36,7 +41,7 @@ const Demo = () => {

https://vector.profanity.dev

-
+
{ -
+
{successData ? (