Hi!
Sure. I can post a whole index.jsx which does not work:
import { Fragment, ProjectPage, Text, render, useProductContext, useState } from "@forge/ui";
import api, { route } from "@forge/api";
const fetchWorklogs = async () => {
const res = await api
.asUser()
.requestJira(route`/rest/api/3/worklog/list`);
return await res.json();
};
const WorklogList = ({ items }) =>
items.length > 0 && (
<Fragment>
{items.map((item) => (
<Text>
Worked {item.timeSpent} on {item.issueId}
</Text>
))}
</Fragment>
);
const App = () => {
const context = useProductContext();
const [worklogs] = useState(async () => await fetchWorklogs());
console.log(`Number of worklogs you reported: ${worklogs.length}`);
return (
<Fragment>
<WorklogList items={worklogs}/>
</Fragment>
);
};
export const run = render(
<ProjectPage>
<App/>
</ProjectPage>
);
Here is the manifest:
modules:
jira:projectPage:
- key: worklog-project-page
function: main
title: Worklog
function:
- key: main
handler: index.run
app:
id: ari:cloud:ecosystem::app/47445c04-1d74-4dfa-a043-2120d4cd664b
runtime:
snapshots: true
permissions:
scopes:
- read:jira-work
- read:me