Skip to content

Commit 6c837b4

Browse files
authored
Merge pull request #666 from YoungHypo/issue-approveform
Fix the bug that ApproveForm component in dashboard does not display the selection box of channel.
2 parents 0cfe556 + 12046f2 commit 6c837b4

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/dashboard/src/pages/ChainCode/forms/ApproveForm.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const FormItem = Form.Item;
99
const ApproveForm = props => {
1010
const [form] = Form.useForm();
1111
const intl = useIntl();
12-
const [channels, setChannels] = useState();
12+
const [channels, setChannels] = useState([]);
1313
const {
1414
approveModalVisible,
1515
handleApprove,
@@ -20,11 +20,15 @@ const ApproveForm = props => {
2020
} = props;
2121

2222
useEffect(() => {
23-
async function fecthData() {
23+
async function fetchData() {
2424
const response = await listChannel();
25-
setChannels(response.data.data);
25+
const newChannels = Object.keys(response.data.data).map(item => ({
26+
label: response.data.data[item].name,
27+
value: response.data.data[item].name,
28+
}));
29+
setChannels(newChannels);
2630
}
27-
fecthData();
31+
fetchData();
2832
}, []);
2933

3034
const approveCallback = response => {
@@ -107,7 +111,7 @@ const ApproveForm = props => {
107111
id: 'app.chainCode.form.approve.channel',
108112
defaultMessage: 'Please select channel',
109113
})}
110-
name="channel"
114+
name="channels"
111115
rules={[
112116
{
113117
required: true,
@@ -120,9 +124,8 @@ const ApproveForm = props => {
120124
>
121125
<Select
122126
mode="multiple"
123-
options={channels} // dummyChannels changed
127+
options={channels}
124128
tagRender={tagRender}
125-
defaultValue={[]}
126129
dropdownClassName={styles.dropdownClassName}
127130
/>
128131
</FormItem>

0 commit comments

Comments
 (0)