File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed
Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -11,12 +11,14 @@ export default function LandingPage() {
1111 const [ name , setName ] = useState ( '' ) ;
1212 const [ email , setEmail ] = useState ( '' ) ;
1313 const { mutate } = trpc . user . createUser . useMutation ( ) ;
14-
14+
1515 const handleSubmit = ( e : React . MouseEvent < HTMLButtonElement , MouseEvent > ) => {
1616 e . preventDefault ( ) ;
1717 // grab the information of name and email
1818 // bundle those together to be an object to be sent to backend
1919 mutate ( { name, email} ) ;
20+ setName ( '' ) ;
21+ setEmail ( '' ) ;
2022 }
2123
2224 return (
Original file line number Diff line number Diff line change @@ -4,10 +4,10 @@ import { router, publicProcedure } from "../trpc";
44
55export const userRouter = router ( {
66 createUser : publicProcedure
7- . input ( z . object ( {
8- name : z . string ( ) ,
7+ . input ( z . object ( {
8+ name : z . string ( ) ,
99 email : z . string ( ) . email ( ) } ) ,
10-
10+
1111 ) // name and email
1212 . mutation ( async ( { input, ctx } ) => {
1313 // we want to add to our database with the name, email, admin defaulted to false as column values
@@ -17,7 +17,9 @@ export const userRouter = router({
1717 email : input . email ,
1818 }
1919 } )
20- } )
20+ } ) ,
21+ getAllUsers : publicProcedure
22+ . query ( )
2123} ) ;
2224
2325
You can’t perform that action at this time.
0 commit comments