(e: React.FormEvent)
| 90 | } |
| 91 | |
| 92 | const handleSignupSubmit = async (e: React.FormEvent) => { |
| 93 | e.preventDefault() |
| 94 | |
| 95 | const result = signupSchema.safeParse(signupFormData) |
| 96 | |
| 97 | if (!result.success) { |
| 98 | const errors: { username?: string; password?: string } = {} |
| 99 | |
| 100 | result.error.issues.forEach((err) => { |
| 101 | errors[err.path[0] as 'username' | 'password'] = err.message |
| 102 | }) |
| 103 | setSignupFormErrors(errors) |
| 104 | |
| 105 | return |
| 106 | } |
| 107 | |
| 108 | const { username, password } = signupFormData |
| 109 | |
| 110 | try { |
| 111 | await request( |
| 112 | endpointFormData.endpointURL, |
| 113 | graphql(` |
| 114 | mutation CreateUser($username: String!, $password: String!) { |
| 115 | createUser(username: $username, password: $password) |
| 116 | } |
| 117 | `), |
| 118 | { |
| 119 | username, |
| 120 | password, |
| 121 | }, |
| 122 | ) |
| 123 | |
| 124 | const numberUsers = await getNumberUsers(endpointFormData.endpointURL) |
| 125 | |
| 126 | setNumberUsers(numberUsers) |
| 127 | } catch (err) { |
| 128 | toast.error((err as Error).message) |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | const handleLoginSubmit = async (e: React.FormEvent) => { |
| 133 | e.preventDefault() |
nothing calls this directly
no test coverage detected