How to get the checkboxes selected info on ModlaDialog form in IssueAction module


I’m new to Forge UI development, I’ve a requirement to display the selected checkboxes on the ModalDialog form but they are showing as null. Can you please help me

 return (

// Function to generate acceptance criteria

   const generateTextTest = (selectedCheckboxes) => {
  console.log("selectedCheckboxes =  "+JSON.stringify(selectedCheckboxes));
    let textMsg="";
    for (const checkbox of selectedCheckboxes) {
if (checkbox === 'CB1') {
          textMsg= 'Selected CB1';
        } else if (checkbox =='CB2') {
          textMsg= 'Selected CB2';

     <ModalDialog header="Generate Text" onClose={() => setOpen(false)} >
        <Text>** Issue Description ** : {description} </Text>
        <Form onSubmit={generateTextTest(selectedCheckboxes)}>
            <CheckboxGroup name="selectedEntities" label="Select items to generate Text : " 
                <Checkbox defaultChecked value="CB1 " label="CB1" />
                <Checkbox value="CB2" label="CB2"/>
                <Checkbox value="CB3" label="CB3"/>
        { generatedTxt && (
            <SectionMessage title="Generated Text " appearance="info">
             <Text format="text">{generatedTxt}</Text>