From b5c24b5a7ffca3df8a06ba23fb21219dabf205f4 Mon Sep 17 00:00:00 2001 From: YoungHypo Date: Fri, 17 Jan 2025 18:47:28 -0800 Subject: [PATCH] fix bug of approveform not showing channel Signed-off-by: YoungHypo --- .../src/pages/ChainCode/forms/ApproveForm.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/dashboard/src/pages/ChainCode/forms/ApproveForm.js b/src/dashboard/src/pages/ChainCode/forms/ApproveForm.js index 113520193..91604a653 100644 --- a/src/dashboard/src/pages/ChainCode/forms/ApproveForm.js +++ b/src/dashboard/src/pages/ChainCode/forms/ApproveForm.js @@ -9,7 +9,7 @@ const FormItem = Form.Item; const ApproveForm = props => { const [form] = Form.useForm(); const intl = useIntl(); - const [channels, setChannels] = useState(); + const [channels, setChannels] = useState([]); const { approveModalVisible, handleApprove, @@ -20,11 +20,15 @@ const ApproveForm = props => { } = props; useEffect(() => { - async function fecthData() { + async function fetchData() { const response = await listChannel(); - setChannels(response.data.data); + const newChannels = Object.keys(response.data.data).map(item => ({ + label: response.data.data[item].name, + value: response.data.data[item].name + })); + setChannels(newChannels); } - fecthData(); + fetchData(); }, []); const approveCallback = response => { @@ -107,7 +111,7 @@ const ApproveForm = props => { id: 'app.chainCode.form.approve.channel', defaultMessage: 'Please select channel', })} - name="channel" + name="channels" rules={[ { required: true, @@ -120,9 +124,8 @@ const ApproveForm = props => { >