-
Notifications
You must be signed in to change notification settings - Fork 5k
Expand file tree
/
Copy pathforumsTableData.js
More file actions
55 lines (49 loc) · 1.55 KB
/
Copy pathforumsTableData.js
File metadata and controls
55 lines (49 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import MDBox from "components/MDBox";
import MDTypography from "components/MDTypography";
import PropTypes from "prop-types";
export default function forumsTableData(forums) {
const ForumInfo = ({ title, questions, user }) => (
<MDBox lineHeight={1} textAlign="left">
<MDTypography display="block" variant="button" fontWeight="medium">
{title}
</MDTypography>
<MDTypography variant="caption">User: {user}</MDTypography>
</MDBox>
);
ForumInfo.propTypes = {
title: PropTypes.string.isRequired,
questions: PropTypes.string.isRequired,
user: PropTypes.string.isRequired,
};
const QuestionInfo = ({ questions }) => (
<MDBox lineHeight={1} textAlign="left">
<MDTypography variant="caption">Questions: {questions}</MDTypography>
</MDBox>
);
QuestionInfo.propTypes = {
questions: PropTypes.string.isRequired,
};
const formatRows = forums.map((forum) => ({
forumInfo: (
<ForumInfo
title={forum.title}
questions={forum.questions}
user={forum.user}
/>
),
questions: <QuestionInfo questions={forum.questions} />,
action: (
<MDTypography component="a" href="#" variant="caption" color="text" fontWeight="medium">
Edit
</MDTypography>
),
}));
return {
columns: [
{ Header: "forum", accessor: "forumInfo", width: "45%", align: "left" },
{ Header: "questions", accessor: "questions", width: "20%", align: "left" },
{ Header: "action", accessor: "action", align: "center" },
],
rows: formatRows,
};
}