Skip to content

Commit

Permalink
delete title
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyuanxun committed Dec 13, 2023
1 parent 70b1723 commit 84dbcf3
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 11 deletions.
8 changes: 1 addition & 7 deletions frontend/src/components/Modal/EditModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ export function EditModal(props: { isComment: boolean, onFinish: (values: any) =
style={{maxWidth: 600}}
scrollToFirstError
>
{!isComment ? <Form.Item
name="title"
label="Title"
>
<Input/>
</Form.Item> : <></>}

<Form.Item
name="content"
Expand All @@ -65,7 +59,7 @@ export function EditModal(props: { isComment: boolean, onFinish: (values: any) =
},
]}
>
<Input/>
<Input.TextArea showCount/>
</Form.Item>
<Form.Item {...tailFormItemLayout}>
<Button type="primary" htmlType="submit">
Expand Down
22 changes: 20 additions & 2 deletions frontend/src/components/Modal/commentForm.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,43 @@
import React from 'react';
import {
Form,
Form, notification
} from 'antd';
import {useAuth} from "../../utils/useAuth";
import Feed from "../../actors/feed";
import {EditModal} from "./EditModal";
import { LoadingOutlined, CheckOutlined } from '@ant-design/icons';

export function CommentForm(props: {postId:string, 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 Comment ing ...',
key: 'createComment',
duration: null,
description: '',
icon: <LoadingOutlined />
});
const feedApi = new Feed(userFeedCai)
await feedApi.createComment(props.postId, values.content)
await feedApi.getAllPost()
api.success({
message: 'Create Comment Successful !',
key: 'createComment',
description: '',
icon: <CheckOutlined />
})
form.resetFields()
props.setOpen(false)
};

return (
<EditModal isComment={true} form={form} onFinish={onFinish}/>
<>
{contextHolder}
<EditModal isComment={true} form={form} onFinish={onFinish}/>
</>
);
};
35 changes: 33 additions & 2 deletions frontend/src/routes/explore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import React, {useEffect, useState} from "react";
import {rootPostApi} from "../actors/rootPost";
import Bucket from "../actors/bucket";
import {PostImmutable} from "../declarations/feed/feed";
import { Layout, Result } from 'antd';
import { SmileOutlined } from '@ant-design/icons';

export default function Explore() {
const [contents, setContents] = useState<PostImmutable[]>([])

const fetch = async () => {
const bucket = await rootPostApi.getAvailableBucket()
if (!bucket[0]) return
Expand All @@ -19,5 +20,35 @@ export default function Explore() {
fetch()
}, [])

return <Content contents={contents}/>
if(contents.length > 0) {
return <Content contents={contents}/>
} else {
return (
<>
<Layout.Content className={"posts"} style={{
backgroundColor: "white",
overflowY: 'auto',
scrollbarWidth: 'thin',
width: '200px',
borderRight: '1px solid rgba(0,0,0,0.2)',
padding: "40px 20px",
}}>
<Result
icon={<SmileOutlined />}
title="There Is No Feed !"
subTitle="Please Refresh The Website"
style={{
backgroundColor: 'white'
}}
/>
</Layout.Content>
<Layout.Content className={"posts"} style={{
backgroundColor: 'white',
overflowY: 'auto',
scrollbarWidth: 'thin',
padding: "40px 20px"
}}>
</Layout.Content>
</>)
}
}
2 changes: 2 additions & 0 deletions src/post/rootPost.mo
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ actor class RootPost(
};
};

public query func getBucketIndex(): async Nat { bucketIndex };

// let ic: IC.Service = actor("aaaaa-aa");
// public shared({caller}) func updateSettings(bucketArray: [Principal]): async () {
// for(_bucket in bucketArray.vals()) {
Expand Down

0 comments on commit 84dbcf3

Please sign in to comment.