-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a23518e
commit 14c79e3
Showing
4 changed files
with
107 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
src/web/containers/main/group/modal/GroupChannelCreate.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import React from 'react'; | ||
import { TMemo } from '@shared/components/TMemo'; | ||
import ModalPanel from '@web/components/ModalPanel'; | ||
import { useFormik } from 'formik'; | ||
import { Form, Button, Input } from 'antd'; | ||
import { useTRPGDispatch } from '@shared/hooks/useTRPGSelector'; | ||
import { createGroupChannel } from '@redux/actions/group'; | ||
|
||
interface ChannelFormValues { | ||
name: string; | ||
desc: string; | ||
} | ||
|
||
const initialValues: ChannelFormValues = { | ||
name: '', | ||
desc: '', | ||
}; | ||
|
||
interface Props { | ||
groupUUID: string; | ||
} | ||
export const GroupChannelCreate: React.FC<Props> = TMemo((props) => { | ||
const dispatch = useTRPGDispatch(); | ||
const { values, handleSubmit, handleChange } = useFormik<ChannelFormValues>({ | ||
initialValues, | ||
onSubmit: async (values) => { | ||
const { name, desc } = values; | ||
dispatch(createGroupChannel(props.groupUUID, name, desc)); | ||
}, | ||
}); | ||
|
||
return ( | ||
<ModalPanel | ||
title="创建频道" | ||
actions={<Button onClick={() => handleSubmit()}>提交</Button>} | ||
style={{ width: 425 }} | ||
> | ||
<Form layout="horizontal" labelCol={{ sm: 6 }} wrapperCol={{ sm: 18 }}> | ||
<Form.Item label="频道名称:"> | ||
<Input | ||
name="name" | ||
size="large" | ||
value={values.name} | ||
onChange={handleChange} | ||
/> | ||
</Form.Item> | ||
<Form.Item label="频道描述:"> | ||
<Input.TextArea | ||
name="desc" | ||
autoSize={{ | ||
maxRows: 4, | ||
minRows: 2, | ||
}} | ||
value={values.desc} | ||
onChange={handleChange} | ||
/> | ||
</Form.Item> | ||
</Form> | ||
</ModalPanel> | ||
); | ||
}); | ||
GroupChannelCreate.displayName = 'GroupChannelCreate'; |