-
Notifications
You must be signed in to change notification settings - Fork 3
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
961b55c
commit a140b96
Showing
21 changed files
with
297 additions
and
66 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,44 @@ | ||
import React from 'react'; | ||
import { | ||
Form, | ||
notification | ||
} from 'antd'; | ||
import { LoadingOutlined, CheckOutlined } from '@ant-design/icons'; | ||
import {useAuth} from "../../utils/useAuth"; | ||
import Feed from "../../actors/feed"; | ||
import {EditModal} from "./EditModal"; | ||
|
||
export function PostForm(props: { setOpen: Function }) { | ||
const {userFeedCai} = useAuth() | ||
const [form] = Form.useForm(); | ||
const [api, contextHolder] = notification.useNotification(); | ||
|
||
const onFinish = async (values: { title: string, content: string }) => { | ||
if (!userFeedCai) return | ||
api.info({ | ||
message: 'Create Post ing ...', | ||
key: 'createPost', | ||
duration: null, | ||
description: '', | ||
icon: <LoadingOutlined /> | ||
}); | ||
const feedApi = new Feed(userFeedCai) | ||
await feedApi.createPost(values.title, values.content) | ||
api.success({ | ||
message: 'Create Post Successful !', | ||
key: 'createPost', | ||
description: '', | ||
icon: <CheckOutlined /> | ||
}) | ||
await feedApi.getAllPost() | ||
form.resetFields() | ||
props.setOpen(false) | ||
}; | ||
|
||
return ( | ||
<EditModal isComment={false} form={form} onFinish={onFinish}/> | ||
<> | ||
{contextHolder} | ||
<EditModal isComment={false} form={form} onFinish={onFinish}/> | ||
</> | ||
); | ||
}; |
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
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
Oops, something went wrong.