Hi,
I am trying to assemble an Atlaskit component with React Hooks that will display a table with all the issues for a chosen Jira board.
This is what I came up with:
const Table = () => {
const [issues, setIssues] = useState([])
const [isRefreshed, setIsRefreshed] = useState(false)
useEffect(() => {
AP.request({
url: "/rest/agile/1.0/board/1/issue",
type: "GET",
fields: {
summary: "",
description: ""
},
success: response => {
response = JSON.parse(response)
setIssues(response)
console.log(response)
console.log(issues)
},
error: () => {
console.log(arguments);
}
})
},[isRefreshed])
const refreshBtn = () => {
setIsRefreshed(!isRefreshed)
}
return (
<div>
<TableTree>
<Headers>
<Header width="300">Summary</Header>
<Header width="130">Project</Header>
<Header width="130">Issue Type</Header>
</Headers>
<Button onClick={refreshBtn}>
<RefreshIcon />
</Button>
<Rows
items{issues.issues}
render{({ summary, project, issueType, hasChildren, children }) => ( <Row>
<Cell singleLine>{summary}</Cell>
<Cell singleLine>{project}</Cell>
<Cell singleLine>{issueType}</Cell>
</Row>
)}
/>
</TableTree>
</div>
)}
Or, find it here. A bit more readable version: https://codesandbox.io/s/trusting-nash-pnqmz?file=/src/App.js
I have used these documentation pieces:
Table Tree - https://atlaskit.atlassian.com/packages/design-system/table-tree
Get Issues for Board - https://developer.atlassian.com/cloud/jira/software/rest/api-group-board/#api-agile-1-0-board-boardid-issue-get
AP Request - https://developer.atlassian.com/cloud/jira/platform/jsapi/request/
In the end, I do receive an object with all the data I need, however I can't use that data to fill in the table.
Please, let me know what am I missing here. Thanks.