From 0dbcd18d5da02ea8f2dbcc61bd95093680546bf3 Mon Sep 17 00:00:00 2001 From: edwin6666 Date: Tue, 17 Oct 2023 14:02:15 -0400 Subject: [PATCH] feat(posts): Add author, category and source to admin and user views --- src/components/PostCard.jsx | 4 +- src/components/PostCardUser.jsx | 6 ++- src/pages/PostForm.js | 68 +++++++++++++++++++++++++++++---- 3 files changed, 67 insertions(+), 11 deletions(-) diff --git a/src/components/PostCard.jsx b/src/components/PostCard.jsx index 3121254..cf97731 100644 --- a/src/components/PostCard.jsx +++ b/src/components/PostCard.jsx @@ -89,11 +89,12 @@ export function PostCard({ post }) { img Logo

- TechTalk + {post.author}

{normalDate}

+

{post.categories}

@@ -125,6 +126,7 @@ export function PostCard({ post }) {

{post.description}

+

Source:{post.source}

); diff --git a/src/components/PostCardUser.jsx b/src/components/PostCardUser.jsx index ba2a790..9b6f68f 100644 --- a/src/components/PostCardUser.jsx +++ b/src/components/PostCardUser.jsx @@ -11,12 +11,13 @@ export function PostCardUser({ post }) {
logo
-

- TechTalk +

+ {post.author}

{normalDate}

+

{post.categories}

@@ -44,6 +45,7 @@ export function PostCardUser({ post }) {

{post.description}

+

Source:{post.source}

); diff --git a/src/pages/PostForm.js b/src/pages/PostForm.js index cf4862f..6217a03 100644 --- a/src/pages/PostForm.js +++ b/src/pages/PostForm.js @@ -1,6 +1,6 @@ import { Formik, Form, Field, ErrorMessage } from "formik"; import { usePosts } from "../context/postContext"; -import { useNavigate, useParams, Link } from "react-router-dom"; +import { useNavigate, useParams } from "react-router-dom"; import * as Yup from "yup"; import { useEffect, useState } from "react"; import { Toaster, toast } from "react-hot-toast"; @@ -13,6 +13,9 @@ export function PostForm() { title: "", description: "", image: null, + categories: "", + source: "", + author: "", }); const params = useParams(); @@ -23,6 +26,9 @@ export function PostForm() { setPost({ title: post.title, description: post.description, + categories: post.categories, + source: post.source, + author: post.author, }); } })(); @@ -31,14 +37,9 @@ export function PostForm() { return (
-
+

New Post

- - Go Back - +
{ if (params.id) { @@ -102,6 +106,54 @@ export function PostForm() { name="description" className="text-red-400 text-sm" /> + + + + + + + + +