|
@@ -2,7 +2,7 @@ import { Button, Divider, message } from "antd"
|
|
import Title from "antd/lib/typography/Title"
|
|
import Title from "antd/lib/typography/Title"
|
|
import { useEffect, useState } from "react"
|
|
import { useEffect, useState } from "react"
|
|
import { connect } from "react-redux"
|
|
import { connect } from "react-redux"
|
|
-import { actionFullSentPost, } from "../actions"
|
|
|
|
|
|
+import { actionAddPostsFeedAC, actionFullSentPost, actionRemovePostsFeedAC, } from "../actions"
|
|
import { EditPhotos } from "../components/uploadPhoto/EditPhotos"
|
|
import { EditPhotos } from "../components/uploadPhoto/EditPhotos"
|
|
import { EditDescriptionPost } from "../components/uploadPhoto/EditDescriptionPost"
|
|
import { EditDescriptionPost } from "../components/uploadPhoto/EditDescriptionPost"
|
|
import { EditTitlePost } from "../components/uploadPhoto/EditTitlePost"
|
|
import { EditTitlePost } from "../components/uploadPhoto/EditTitlePost"
|
|
@@ -13,19 +13,23 @@ import { history } from '../App'
|
|
const ContainEditorPost = ({ children }) =>
|
|
const ContainEditorPost = ({ children }) =>
|
|
<div className='ContainEditPost ContainerInner'>{children}</div>
|
|
<div className='ContainEditPost ContainerInner'>{children}</div>
|
|
|
|
|
|
-const EntityEditorPost = ({ match: { params: { _id } }, myID, entity, status, onSave, findPostOne, clearState }) => {
|
|
|
|
|
|
+const EntityEditorPost = ({ match: { params: { _id } }, myID, entity, status, onSave, updatePost, clearState }) => {
|
|
|
|
|
|
const [photos, setPhotos] = useState(entity?.images || []);
|
|
const [photos, setPhotos] = useState(entity?.images || []);
|
|
const [titleSend, setTitleSend] = useState(entity?.title || '')
|
|
const [titleSend, setTitleSend] = useState(entity?.title || '')
|
|
const [description, setDescription] = useState(entity?.text || '');
|
|
const [description, setDescription] = useState(entity?.text || '');
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
- console.log();
|
|
|
|
|
|
+ let newEntity
|
|
if (Array.isArray(entity)) {
|
|
if (Array.isArray(entity)) {
|
|
- let newEntity = entity.find(e => e._id === _id)
|
|
|
|
|
|
+ newEntity = entity.find(e => e._id === _id)
|
|
setPhotos(newEntity?.images || [])
|
|
setPhotos(newEntity?.images || [])
|
|
setTitleSend(newEntity?.title || '')
|
|
setTitleSend(newEntity?.title || '')
|
|
setDescription(newEntity?.text || '')
|
|
setDescription(newEntity?.text || '')
|
|
} else if (!Object.keys(entity = {}).length) history.push('/edit/post/new')
|
|
} else if (!Object.keys(entity = {}).length) history.push('/edit/post/new')
|
|
|
|
+ updatePost(newEntity)
|
|
|
|
+ return () => {
|
|
|
|
+ clearState()
|
|
|
|
+ }
|
|
}, []);
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
@@ -33,6 +37,8 @@ const EntityEditorPost = ({ match: { params: { _id } }, myID, entity, status, on
|
|
if (status === "RESOLVED") {
|
|
if (status === "RESOLVED") {
|
|
message.success(`post published, can create a new one`)
|
|
message.success(`post published, can create a new one`)
|
|
history.push(`/profile/${myID}`)
|
|
history.push(`/profile/${myID}`)
|
|
|
|
+ }else if(status === "REJECTED"){
|
|
|
|
+ message.error('Error')
|
|
}
|
|
}
|
|
}, [status])
|
|
}, [status])
|
|
|
|
|
|
@@ -59,5 +65,7 @@ export const CEntityEditorPost = connect(state => ({
|
|
status: state?.promise?.sentPost?.status
|
|
status: state?.promise?.sentPost?.status
|
|
}),
|
|
}),
|
|
{
|
|
{
|
|
|
|
+ updatePost: actionAddPostsFeedAC,
|
|
onSave: actionFullSentPost,
|
|
onSave: actionFullSentPost,
|
|
|
|
+ clearState: actionRemovePostsFeedAC,
|
|
})(EntityEditorPost)
|
|
})(EntityEditorPost)
|