I would like to set the state of a checkbox to true in a custom component for Atlassian Jira when a button is clicked. I am using the UI kit with Forge.
So what do I have to write in the line // todo: check Checkbox "V2"?
import ForgeUI, { CustomField, CustomFieldEdit, render, Text, TextField, useProductContext, CheckboxGroup, Checkbox, Select, Option, Button } from "@forge/ui";
const View = () => {
const { extensionContext: { fieldValue } } = useProductContext();
return (
<CustomField>
<Text
content={`Hello ${fieldValue || "world"}!`}
/>
</CustomField>
);
};
const Edit = () => {
const onSubmit = values => {
return values.text
};
const onClick = () => {
// todo: check Checkbox "V2"
};
return (
<CustomFieldEdit onSubmit={onSubmit}>
<CheckboxGroup label="Products" name="products">
<Checkbox value="V1" label="V1" />
<Checkbox value="V2" label="V2" />
<Checkbox value="V3" label="V3" />
</CheckboxGroup>
<Button text="button" onClick={onClick} />
</ CustomFieldEdit>
);
}
export const runView = render(
<View/>
);
export const runEdit = render(<Edit/>)