Skip to content

Commit c95bd96

Browse files
author
Jovert Lota Palonpon
committed
wip
1 parent 2e2a8d9 commit c95bd96

File tree

4 files changed

+53
-9
lines changed

4 files changed

+53
-9
lines changed

resources/js/utils/Random.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/**
2-
* ? Get color from list.
2+
* Get color from list.
3+
*
34
* @param {int} key
5+
*
46
* @return {string}
57
*/
68
export const _color = key => {

resources/js/views/__backoffice/users/Create.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Master as MasterLayout } from '../layouts';
55
class Create extends Component {
66
render() {
77
return (
8-
<MasterLayout {...this.props} pageTitle="Create a user">
8+
<MasterLayout {...this.props} pageTitle="Create a user" tabs={[]}>
99
Create...
1010
</MasterLayout>
1111
);

resources/js/views/__backoffice/users/Edit.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ class Edit extends Component {
77
const { params } = this.props.match;
88

99
return (
10-
<MasterLayout {...this.props} pageTitle="Edit user">
11-
<h1>Edit user: {params.id}</h1>
10+
<MasterLayout {...this.props} pageTitle="Edit user" tabs={[]}>
11+
Edit user: {params.id}
1212
</MasterLayout>
1313
);
1414
}

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

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
import React, { Component } from 'react';
22

3-
import { IconButton, Tooltip } from '@material-ui/core';
3+
import {
4+
Avatar,
5+
Grid,
6+
IconButton,
7+
Tooltip,
8+
withStyles,
9+
} from '@material-ui/core';
410

511
import { Delete as DeleteIcon, Edit as EditIcon } from '@material-ui/icons';
612

13+
import * as RandomUtils from '../../../utils/Random';
14+
import * as NavigationUtils from '../../../utils/Navigation';
715
import * as UrlUtils from '../../../utils/URL';
816
import { Table } from '../../../ui';
917
import { Master as MasterLayout } from '../layouts';
@@ -366,14 +374,15 @@ class List extends Component {
366374
current_page: page,
367375
} = pagination;
368376

369-
const { pageProps } = this.props;
377+
const { pageProps, history } = this.props;
370378
const { user: authUser } = pageProps;
371379

372380
const primaryAction = {
373381
text: Lang.get('resources.create', {
374382
name: 'User',
375383
}),
376-
clicked: () => alert('As you wish...'),
384+
clicked: () =>
385+
history.push(NavigationUtils._route('backoffice.users.create')),
377386
};
378387

379388
const tabs = [
@@ -400,7 +409,29 @@ class List extends Component {
400409
rawData.map(user => {
401410
return {
402411
type: user.type,
403-
name: user.name,
412+
name: (
413+
<Grid container direction="row" alignItems="center">
414+
<Grid item style={{ marginRight: 10 }}>
415+
<Avatar
416+
style={{
417+
fontSize: 17,
418+
backgroundColor: RandomUtils._color(
419+
user.firstname.length -
420+
user.created_at.charAt(
421+
user.created_at.length - 2,
422+
),
423+
),
424+
}}
425+
>
426+
{`${user.firstname.charAt(
427+
0,
428+
)}${user.lastname.charAt(0)}`}
429+
</Avatar>
430+
</Grid>
431+
432+
<Grid item>{user.name}</Grid>
433+
</Grid>
434+
),
404435
email: user.email,
405436
actions: (
406437
<div style={{ width: '5rem' }}>
@@ -409,7 +440,18 @@ class List extends Component {
409440
name: 'User',
410441
})}
411442
>
412-
<IconButton>
443+
<IconButton
444+
onClick={() =>
445+
history.push(
446+
NavigationUtils._route(
447+
'backoffice.users.edit',
448+
{
449+
id: user.id,
450+
},
451+
),
452+
)
453+
}
454+
>
413455
<EditIcon />
414456
</IconButton>
415457
</Tooltip>

0 commit comments

Comments
 (0)