I have a UI Kit ModalDialog with a Form inside, I can capture the form data with my onSubmit function but I need to add the current issue title and the current user email, how can I get that information before making the POST request to my API?
I started with a jira-issue-panel template and this is my code so far:
import ForgeUI, { render, Fragment, Text, IssuePanel, Form, ModalDialog, Range, Button, useState } from '@forge/ui';
const App = () => {
const [isOpen, setOpen] = useState(false);
// Handles form submission, which is a good place to call APIs, or to set component state...
const onSubmit = async (formData) => {
// get the issue title and user email to POST request
formData['issue'] = 'TEST';
formData['userEmail'] = 'TEST@TEST.COM';
console.log(formData);
// close the modal window
setOpen(false);
};
return (
<Fragment>
<Button
text={`Open form`}
onClick={() => setOpen(true)}
/>
{isOpen && (
<ModalDialog header="Rating" onClose={() => setOpen(false)}>
<Form onSubmit={onSubmit}>
<Text>Give your rating</Text>
<Range label="Your rating" name="rating" min={0} max={10} step={1} />
</Form>
</ModalDialog>
)}
</Fragment>
);
};
export const run = render(
<IssuePanel>
<App />
</IssuePanel>
);