Skip to content

Commit b8fc1ac

Browse files
committed
chore: update login button
1 parent f162674 commit b8fc1ac

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

ch10/devjobs/apps/devjobs-frontend/src/app/Login/index.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export function Login() {
1212

1313
const { login } = useAuth();
1414

15-
1615
const handleSubmit = async (e: React.FormEvent) => {
1716
try {
1817
e.preventDefault();
@@ -22,13 +21,12 @@ export function Login() {
2221
data: { email, password },
2322
});
2423

25-
2624
login(response.access_token);
2725

28-
navigate('/jobs');
26+
navigate('/jobs');
2927
} catch (error) {
30-
// you can use your custom loggers here to handle the error in a better way
31-
console.error('Login failed:', error); //
28+
// you can use your custom loggers here to handle the error in a better way
29+
console.error('Login failed:', error); //
3230
}
3331
};
3432

@@ -60,9 +58,8 @@ export function Login() {
6058
onChange={(e) => setPassword(e.target.value)}
6159
/>
6260
</div>
63-
64-
<button type='submit' className='w-full border py-2 rounded'>
65-
Login
61+
<button type='submit' disabled={loginMutation.isPending}>
62+
{loginMutation.isPending ? 'Logging in...' : 'Login'}
6663
</button>
6764
{loginMutation.isError && (
6865
<p className='text-sm'>

ch10/devjobs/libs/api-client/src/generated/authentication.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@ export const postAuthLogin = (
3434
loginRequest: LoginRequest,
3535
signal?: AbortSignal
3636
) => {
37-
38-
37+
38+
3939
return api<LoginResponse>(
4040
{url: `/auth/login`, method: 'POST',
4141
headers: {'Content-Type': 'application/json', },
4242
data: loginRequest, signal
4343
},
4444
);
4545
}
46-
46+
4747

4848

4949
export const getPostAuthLoginMutationOptions = <TError = ErrorResponse,
@@ -57,7 +57,7 @@ const {mutation: mutationOptions} = options ?
5757
: {...options, mutation: {...options.mutation, mutationKey}}
5858
: {mutation: { mutationKey, }};
5959

60-
60+
6161

6262

6363
const mutationFn: MutationFunction<Awaited<ReturnType<typeof postAuthLogin>>, {data: LoginRequest}> = (props) => {
@@ -66,7 +66,7 @@ const {mutation: mutationOptions} = options ?
6666
return postAuthLogin(data,)
6767
}
6868

69-
69+
7070

7171

7272
return { mutationFn, ...mutationOptions }}
@@ -91,4 +91,3 @@ export const usePostAuthLogin = <TError = ErrorResponse,
9191

9292
return useMutation(mutationOptions, queryClient);
9393
}
94-

0 commit comments

Comments
 (0)