Skip to content

Commit dc39f2b

Browse files
author
Jovert Lota Palonpon
committed
Utilized avatar pictures, closes #30
1 parent 48188d1 commit dc39f2b

File tree

2 files changed

+55
-24
lines changed

2 files changed

+55
-24
lines changed

resources/js/views/__backoffice/partials/Header.js

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import {
3737
Settings as SettingsIcon,
3838
} from '@material-ui/icons';
3939

40+
import * as RandomUtils from '../../../utils/Random';
4041
import {
4142
LightbulbOff as LightbulbOffIcon,
4243
LightbulbOn as LightbulbOnIcon,
@@ -507,13 +508,34 @@ const Header = props => {
507508
}
508509
color="inherit"
509510
>
510-
<Avatar className={classes.avatar}>
511-
<Typography>
512-
{`${user.firstname.charAt(
513-
0,
514-
)}${user.lastname.charAt(0)}`}
515-
</Typography>
516-
</Avatar>
511+
{user.hasOwnProperty('thumbnail_url') &&
512+
user.thumbnail_url !== null ? (
513+
<Avatar
514+
alt={user.name}
515+
src={user.thumbnail_url}
516+
/>
517+
) : (
518+
<Avatar
519+
style={{
520+
fontSize: 17,
521+
backgroundColor: RandomUtils._color(
522+
user.firstname.length -
523+
user.created_at.charAt(
524+
user.created_at
525+
.length - 2,
526+
),
527+
),
528+
}}
529+
>
530+
<Typography>
531+
{`${user.firstname.charAt(
532+
0,
533+
)}${user.lastname.charAt(
534+
0,
535+
)}`}
536+
</Typography>
537+
</Avatar>
538+
)}
517539
</IconButton>
518540

519541
<AccountMenu {...props} />

resources/js/views/__backoffice/users/List.js

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -403,23 +403,32 @@ class List extends Component {
403403
wrap="nowrap"
404404
>
405405
<Grid item style={{ marginRight: 10 }}>
406-
<Avatar
407-
style={{
408-
fontSize: 17,
409-
backgroundColor: RandomUtils._color(
410-
user.firstname.length -
411-
user.created_at.charAt(
412-
user.created_at.length - 2,
413-
),
414-
),
415-
}}
416-
>
417-
<Typography>
418-
{`${user.firstname.charAt(
419-
0,
420-
)}${user.lastname.charAt(0)}`}
421-
</Typography>
422-
</Avatar>
406+
{user.hasOwnProperty('thumbnail_url') &&
407+
user.thumbnail_url !== null ? (
408+
<Avatar
409+
alt={user.name}
410+
src={user.thumbnail_url}
411+
/>
412+
) : (
413+
<Avatar
414+
style={{
415+
fontSize: 17,
416+
backgroundColor: RandomUtils._color(
417+
user.firstname.length -
418+
user.created_at.charAt(
419+
user.created_at.length -
420+
2,
421+
),
422+
),
423+
}}
424+
>
425+
<Typography>
426+
{`${user.firstname.charAt(
427+
0,
428+
)}${user.lastname.charAt(0)}`}
429+
</Typography>
430+
</Avatar>
431+
)}
423432
</Grid>
424433

425434
<Grid item>{user.name}</Grid>

0 commit comments

Comments
 (0)