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() {
11
11
const [ name , setName ] = useState ( '' ) ;
12
12
const [ email , setEmail ] = useState ( '' ) ;
13
13
const { mutate } = trpc . user . createUser . useMutation ( ) ;
14
-
14
+
15
15
const handleSubmit = ( e : React . MouseEvent < HTMLButtonElement , MouseEvent > ) => {
16
16
e . preventDefault ( ) ;
17
17
// grab the information of name and email
18
18
// bundle those together to be an object to be sent to backend
19
19
mutate ( { name, email} ) ;
20
+ setName ( '' ) ;
21
+ setEmail ( '' ) ;
20
22
}
21
23
22
24
return (
Original file line number Diff line number Diff line change @@ -4,10 +4,10 @@ import { router, publicProcedure } from "../trpc";
4
4
5
5
export const userRouter = router ( {
6
6
createUser : publicProcedure
7
- . input ( z . object ( {
8
- name : z . string ( ) ,
7
+ . input ( z . object ( {
8
+ name : z . string ( ) ,
9
9
email : z . string ( ) . email ( ) } ) ,
10
-
10
+
11
11
) // name and email
12
12
. mutation ( async ( { input, ctx } ) => {
13
13
// 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({
17
17
email : input . email ,
18
18
}
19
19
} )
20
- } )
20
+ } ) ,
21
+ getAllUsers : publicProcedure
22
+ . query ( )
21
23
} ) ;
22
24
23
25
You can’t perform that action at this time.
0 commit comments