Skip to content

Commit 54c7dc2

Browse files
committed
user edit in progress
1 parent f114219 commit 54c7dc2

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed

src/Administration/Administration.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ import React from 'react'
22
import PropTypes from 'prop-types'
33
import { Route } from 'react-router-dom'
44
import UsersList from './Users/UsersList'
5+
import UserEditor from "./Users/UsersEditor/UsersEditor";
56

67
const Administration = ({ match }) => {
78
return (
89
<>
9-
<Route path={`${match.path}/users`} component={UsersList} />
10+
<Route exact path={`${match.path}/users`} component={UsersList} />
11+
<Route path={`${match.path}/users/:userId/edit`} component={UserEditor} />
1012
</>
1113
)
1214
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import React, { useEffect, useState } from 'react'
2+
import PropTypes from 'prop-types'
3+
4+
import api from '@/_api'
5+
6+
const UserEditor = ({ match }) => {
7+
const [user, setUser] = useState([])
8+
9+
useEffect(() => {
10+
async function fetchUser() {
11+
const userId = match.params.userId;
12+
try {
13+
const userDataRes = await api.users.getOne(userId)
14+
setUser(userDataRes)
15+
} catch (err) {
16+
console.log('error', err.message)
17+
}
18+
}
19+
fetchUser()
20+
}, [])
21+
22+
return (
23+
<>
24+
UserEditor
25+
</>
26+
)
27+
}
28+
29+
UserEditor.propTypes = {}
30+
31+
export default UserEditor

src/Administration/Users/UsersList/UsersListTableItems.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react'
22
import PropTypes from 'prop-types'
33
import { FormattedDate } from 'react-intl'
4-
4+
import { Link } from 'react-router-dom'
55
import { makeStyles, TableCell, TableRow, Avatar } from '@material-ui/core'
66
import { Skeleton } from '@material-ui/lab'
77

@@ -60,7 +60,9 @@ const UsersListTableItems = ({ users, rowsPerPage = 10, rowsExpected = 10 }) =>
6060
/>
6161
</TableCell>
6262
<TableCell>
63-
<EditIcon />
63+
<Link to={{ pathname: `users/${row.id}/edit` }}>
64+
<EditIcon />
65+
</Link>
6466
<DeleteIcon />
6567
</TableCell>
6668
</TableRow>

0 commit comments

Comments
 (0)