Skip to content

Commit

Permalink
add spinner
Browse files Browse the repository at this point in the history
  • Loading branch information
vadim9999 committed Oct 6, 2024
1 parent 5869d0b commit 0aa33aa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/pages/Login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState } from 'react';
import { Input, Button, Form, Row, Col, InputProps, FormProps } from 'antd';
// import Example from './Example'
import { LockOutlined, UserOutlined } from '@ant-design/icons';
import { useAppDispatch } from '../../redux/hooks/hooks';
import { useAppDispatch, useAppSelector } from '../../redux/hooks/hooks';
import { LOGIN } from '../../redux/constants/action-types';

// const mapStateToProps = (state: any) => ({
Expand All @@ -20,6 +20,7 @@ type FieldType = {
};

const Login = () => {
const { isLoading } = useAppSelector((state) => state.main.userInfo);
const dispatch = useAppDispatch();

const [state, setState] = useState({
Expand Down Expand Up @@ -79,6 +80,7 @@ const Login = () => {
onChange={onHandleChange}
value={state.email}
name="email"
disabled={isLoading}
prefix={
<UserOutlined />
}
Expand All @@ -91,13 +93,15 @@ const Login = () => {
value={state.password}
placeholder="Input password"
prefix={<LockOutlined />}
disabled={isLoading}
/>
</Form.Item>
<Form.Item>
<Button
type="primary"
htmlType="submit"
block
loading={isLoading}
>
Log in
</Button>
Expand Down
4 changes: 4 additions & 0 deletions src/redux/sagas/user-saga/user-saga.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ function* initWorker(requestFunction: any, { type, payload }: any) {
// console.log("data123", );
localStorage.setItem("token", token);

yield put(setUserInfo({
isLoading: false,
user: null,
}));
// yield put({ type: `${type}_SUCCESS`, payload: data });
} catch (e) {
// yield put({ type: `${type}_FAILED`, e });
Expand Down

0 comments on commit 0aa33aa

Please sign in to comment.