diff --git a/public/pages/ShowPost/ShowPost.page.tsx b/public/pages/ShowPost/ShowPost.page.tsx index 3d893701f..ccacf8636 100644 --- a/public/pages/ShowPost/ShowPost.page.tsx +++ b/public/pages/ShowPost/ShowPost.page.tsx @@ -23,21 +23,22 @@ import { Avatar, Dropdown, } from "@fider/components" -import { ResponseForm } from "./components/ResponseForm" -import { TagsPanel } from "./components/TagsPanel" -import { NotificationsPanel } from "./components/NotificationsPanel" -import { ModerationPanel } from "./components/ModerationPanel" +// import { ResponseForm } from "./components/ResponseForm" +// import { TagsPanel } from "./components/TagsPanel" +// import { NotificationsPanel } from "./components/NotificationsPanel" +// import { ModerationPanel } from "./components/ModerationPanel" import { DiscussionPanel } from "./components/DiscussionPanel" -import { VotesPanel } from "./components/VotesPanel" +// import { VotesPanel } from "./components/VotesPanel" import IconX from "@fider/assets/images/heroicons-x.svg" -import IconPencilAlt from "@fider/assets/images/heroicons-pencil-alt.svg" +// import IconPencilAlt from "@fider/assets/images/heroicons-pencil-alt.svg" import IconThumbsUp from "@fider/assets/images/heroicons-thumbsup.svg" import { HStack, VStack } from "@fider/components/layout" import { Trans } from "@lingui/macro" import { TagsPanel2 } from "./components/TagsPanel2" import { NotificationsPanel2 } from "./components/NotificationsPanel2" import { VoteSection } from "./components/VoteSection" +import { ModerationPanel } from "./components/ModerationPanel" interface ShowPostPageProps { post: Post @@ -51,6 +52,7 @@ interface ShowPostPageProps { interface ShowPostPageState { editMode: boolean newTitle: string + showDeleteModal: boolean attachments: ImageUpload[] newDescription: string highlightedComment?: number @@ -72,6 +74,7 @@ export default class ShowPostPage extends React.Component { + this.setState({ showDeleteModal }) + } + private cancelEdit = async () => { this.setState({ error: undefined, editMode: false }) } @@ -158,7 +165,7 @@ export default class ShowPostPage extends React.ComponentLink copied to clipboard) } else if (action === "delete") { - // actions.deletePost(this.props.post.number) + this.setShowDeleteModal(true) } else if (action === "status") { // actions.changeStatus(this.props.post.number, this.props.post.status) } else if (action === "edit") { @@ -174,8 +181,7 @@ export default class ShowPostPage extends React.Component
- - +
{this.state.editMode ? ( @@ -191,6 +197,7 @@ export default class ShowPostPage extends React.Component )}
+ this.setShowDeleteModal(false)} showModal={this.state.showDeleteModal} post={this.props.post} /> {!this.state.editMode && ( }> @@ -278,7 +285,7 @@ export default class ShowPostPage extends React.Component
- + {/* {Fider.session.isAuthenticated && canEditPost(Fider.session.user, this.props.post) && ( @@ -318,7 +325,7 @@ export default class ShowPostPage extends React.Component - + */}
diff --git a/public/pages/ShowPost/components/ModerationPanel.tsx b/public/pages/ShowPost/components/ModerationPanel.tsx index e37b356a6..019234c8d 100644 --- a/public/pages/ShowPost/components/ModerationPanel.tsx +++ b/public/pages/ShowPost/components/ModerationPanel.tsx @@ -3,26 +3,23 @@ import { PostStatus, Post } from "@fider/models" import { actions, navigator, Failure } from "@fider/services" import { Form, Modal, Button, TextArea } from "@fider/components" import { useFider } from "@fider/hooks" -import { VStack } from "@fider/components/layout" import { t, Trans } from "@lingui/macro" interface ModerationPanelProps { post: Post + showModal: boolean + onModalClose: () => void } export const ModerationPanel = (props: ModerationPanelProps) => { const fider = useFider() - const [showConfirmation, setShowConfirmation] = useState(false) const [text, setText] = useState("") const [error, setError] = useState() - const hideModal = async () => setShowConfirmation(false) - const showModal = async () => setShowConfirmation(true) - const handleDelete = async () => { const response = await actions.deletePost(props.post.number, text) if (response.ok) { - hideModal() + props.onModalClose() navigator.goHome() } else if (response.error) { setError(response.error) @@ -35,7 +32,7 @@ export const ModerationPanel = (props: ModerationPanelProps) => { } const modal = ( - +