import React, { useState } from 'react'; import { Button, Form, Header, Segment } from 'semantic-ui-react'; import { API, showError, showSuccess } from '../../helpers'; import { CHANNEL_OPTIONS } from '../../constants'; const AddChannel = () => { const originInputs = { name: '', type: 1, key: '', base_url: '', }; const [inputs, setInputs] = useState(originInputs); const { name, type, key } = inputs; const handleInputChange = (e, { name, value }) => { setInputs((inputs) => ({ ...inputs, [name]: value })); }; const submit = async () => { if (inputs.name === '' || inputs.key === '') return; if (inputs.base_url.endsWith('/')) { inputs.base_url = inputs.base_url.slice(0, inputs.base_url.length - 1); } const res = await API.post(`/api/channel/`, inputs); const { success, message } = res.data; if (success) { showSuccess('渠道创建成功!'); setInputs(originInputs); } else { showError(message); } }; return ( <>
创建新的渠道
{ type === 8 && ( ) }
); }; export default AddChannel;