Skip to content

Commit

Permalink
Merge pull request #5 from gitautoai/wes
Browse files Browse the repository at this point in the history
Update UI as a test
  • Loading branch information
hiroshinishio authored Nov 27, 2024
2 parents 7a133f1 + 2447b18 commit a94b252
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions src/frontend/index.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
import React, { useEffect, useState } from 'react';
import ForgeReconciler, { Text } from '@forge/react';
import { invoke } from '@forge/bridge';
import React, { useEffect, useState } from "react";
import ForgeReconciler, { Text, useProductContext } from "@forge/react";
import { requestJira } from "@forge/bridge";

const App = () => {
const [data, setData] = useState(null);
const context = useProductContext();
const [comments, setComments] = useState();
console.log(`Number of comments on this issue: ${comments?.length}`);

const fetchCommentsForIssue = async (issueIdOrKey) => {
const res = await requestJira(`/rest/api/3/issue/${issueIdOrKey}/comment`);
const data = await res.json();
return data.comments;
};

// This is a test of the requestJira function
useEffect(() => {
invoke('getText', { example: 'my-invoke-variable' }).then(setData);
}, []);
if (context) {
const issueId = context.extension.issue.id;
fetchCommentsForIssue(issueId).then(setComments);
}
}, [context]);

return (
<>
<Text>Hello world!</Text>
<Text>{data ? data : 'Loading...'}</Text>
<Text>Number of comments on this issue: {comments?.length}</Text>
</>
);
};
Expand Down

0 comments on commit a94b252

Please sign in to comment.