Skip to content
This repository was archived by the owner on Mar 7, 2024. It is now read-only.

Commit 7b43807

Browse files
Add Circular Progress till the Firebase Data is fetched (#79)
* Add Circular Progress till the Firebase Data is fetched * revision 1: Add Circular Progress till the Firebase Data is fetched * renamed OpenSource to Account
1 parent d413a6e commit 7b43807

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

src/layouts/MainLayout/TopBar/Account.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,26 @@ import {
1212
Avatar,
1313
Menu,
1414
MenuItem,
15-
Hidden
15+
Hidden,
16+
CircularProgress,
17+
makeStyles
1618
} from '@material-ui/core';
1719
import authService from 'src/services/authService';
1820
import StyledFirebaseAuth from 'react-firebaseui/StyledFirebaseAuth';
1921
import { login, dismissLogin, logout } from 'src/actions/accountActions';
2022

23+
const useStyles = makeStyles(theme => ({
24+
button: {
25+
minWidth: '120px'
26+
}
27+
}));
28+
2129
function Account() {
2230
const user = useSelector(state => state.account.user);
2331
const loginFlag = useSelector(state => state.account.login);
2432
const [anchorEl, setAnchorEl] = React.useState(null);
2533
const dispatch = useDispatch();
34+
const classes = useStyles();
2635

2736
const handleLogout = () => {
2837
handleCloseMenu();
@@ -70,7 +79,7 @@ function Account() {
7079
color: '#000000'
7180
}}
7281
>
73-
{!!user ? (
82+
{user ? (
7483
<Box
7584
display="flex"
7685
flexDirection="row"
@@ -121,12 +130,17 @@ function Account() {
121130
<Button
122131
variant="contained"
123132
color="secondary"
133+
className={classes.button}
124134
onClick={handleLoginOpen}
125135
style={{
126136
textTransform: 'capitalize'
127137
}}
128138
>
129-
<Typography variant="h6">Login</Typography>
139+
{user === undefined ? (
140+
<CircularProgress size="24px" color="inherit" />
141+
) : (
142+
<Typography variant="h6">Login</Typography>
143+
)}
130144
</Button>
131145
)}
132146

src/layouts/MainLayout/TopBar/index.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
} from '@material-ui/core';
1313
import Logo from 'src/components/Logo';
1414
import Item from './Item';
15-
import OpenSource from './Account';
15+
import Account from './Account';
1616
import IconButton from '@material-ui/core/IconButton';
1717
import MenuIcon from '@material-ui/icons/Menu';
1818
import CloseIcon from '@material-ui/icons/Close';
@@ -143,10 +143,9 @@ function TopBar({ className, onMobileNavOpen, ...rest }) {
143143
link={item.link}
144144
/>
145145
))}
146-
;
147146
<Box ml={2} flexGrow={0.05} />
148147
<Box ml={2}>
149-
<OpenSource />
148+
<Account />
150149
</Box>
151150
<Box ml={2} flexGrow={0.05} />
152151
</Hidden>
@@ -157,7 +156,7 @@ function TopBar({ className, onMobileNavOpen, ...rest }) {
157156
alignItems="center"
158157
style={{ position: 'absolute', right: '0px'}}
159158
>
160-
<OpenSource />
159+
<Account />
161160

162161
<IconButton
163162
edge="end"

src/reducers/accountReducer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import {
1111
} from 'src/actions/accountActions';
1212

1313
const initialState = {
14-
user: null,
15-
login: null
14+
user: undefined,
15+
login: undefined
1616
};
1717

1818
const accountReducer = (state = initialState, action) => {

0 commit comments

Comments
 (0)