Skip to content

Commit

Permalink
Work on post moderation
Browse files Browse the repository at this point in the history
  • Loading branch information
maxtyson123 committed Aug 7, 2024
1 parent 761ae43 commit 3caa823
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
11 changes: 10 additions & 1 deletion website/src/pages/admin/posts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {useRouter} from "next/router";
import {Layout} from "@/components/layout";
import {RongoaUser, UserDatabaseDetails} from "@/lib/users";
import {PostCard, PostCardApi} from "@/pages/media/components/cards";
import {getFilePath} from "@/lib/data";
import {ModalImage} from "@/components/modal";

export default function Admin(){
const pageName = "Admin";
Expand All @@ -19,6 +21,7 @@ export default function Admin(){
const { data: session, update } = useSession()

const [moderationIds, setModerationIds] = useState<number[]>([])
const [images, setImages] = useState<string[]>([])
const [currentIndex, setCurrentIndex] = useState<number>(0)
const [loadingMessage, setLoadingMessage] = useState("")
const [error, setError] = useState("")
Expand All @@ -38,7 +41,9 @@ export default function Admin(){
if(response.data.data){

const ids = response.data.data.map((post: any) => post.id)
const images = response.data.data.map((post: any) => getFilePath(post.post_user_id, post.id, post.post_image))
setModerationIds(ids)
setImages(images)
}
setLoadingMessage("")

Expand Down Expand Up @@ -85,13 +90,16 @@ export default function Admin(){
<div className={globalStyles.container}>
<div className={styles.adminHeaderContainer}>
<h1>Post Moderation</h1>
<p> There are {moderationIds.length} posts that need to be moderated. </p>
</div>
</div>

<div id={"widthReference"} style={{width: "400px", height: "50px"}}/>
<div className={styles.postsToModerate}>
{moderationIds && moderationIds.slice(currentIndex, currentIndex + 2).map((id) => (
<PostCardApi id={id} key={id}/>
<ModalImage url={images[currentIndex]} description={"Post: " + id} key={id}>
<PostCardApi id={id} />
</ModalImage>
))}
{currentIndex >= moderationIds.length && (
<div style={{
Expand All @@ -111,6 +119,7 @@ export default function Admin(){
<div className={styles.adminHeaderContainer}>
<div className={styles.approveAndDeny}>
<button style={{background: "red"}} onClick={() => handleModeration("deny")}> Deny</button>
<button style={{background: "orange"}} onClick={() => handleModeration("edit")}> Edit</button>
<button onClick={() => handleModeration("approve")}> Approve</button>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions website/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import axios from "axios";
// - Plant App
// = = Moderation
// - - Live Chat
// - - Better Plan Search
// - - Link To Rongoa (Images Popup and Home Feed)
// - - Publish on stores
// - Databse
Expand Down
16 changes: 15 additions & 1 deletion website/src/pages/media/messages/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,20 @@ export default function Page(){
scrollMessages();
}, [messages]);


const setupRealtime = useRef(false);
useEffect(() => {

if(setupRealtime.current) return;
setupRealtime.current = true;

// Create a timeout to refresh every 3
const interval = setInterval(() => {
fetchMessages();
}, 3000);

}, []);

const scrollMessages = () => {

// Scroll to the bottom of the messages
Expand Down Expand Up @@ -215,7 +229,7 @@ export default function Page(){
type={message.message_user_id === (session?.user as RongoaUser).database.id ? "sent" : "received"}
/>
</>

sudo nano /etc/network/interfaces
)
})}
</>
Expand Down

0 comments on commit 3caa823

Please sign in to comment.