Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/components/PostCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,12 @@ export function PostCard({ post }) {
<img className="w-12 rounded-full" src={logoImg} alt="img Logo" />
<div className="ml-3">
<h1 className="text-xl font-bold text-gray-800 cursor-pointer">
TechTalk
{post.author}
</h1>
<p className="text-sm text-gray-800 hover:underline cursor-pointer">
{normalDate}
</p>
<p className="text-blue-400 capitalize "> {post.categories}</p>
</div>
</div>
<div>
Expand Down Expand Up @@ -125,6 +126,7 @@ export function PostCard({ post }) {
<p className="text-lg font font-thin text-black text-justify">
{post.description}
</p>
<h4 className="text-gray-400 capitalize right-0"> Source:{post.source}</h4>
</div>
</article>
);
Expand Down
6 changes: 4 additions & 2 deletions src/components/PostCardUser.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ export function PostCardUser({ post }) {
<div className="flex justify-between items-center py-4">
<img className="w-12 rounded-full" src={logoImg} alt="logo" />
<div className="ml-3">
<h1 className="text-xl font-bold text-gray-800 cursor-pointer">
TechTalk
<h1 className="text-xl font-bold text-gray-800 cursor-pointer">
{post.author}
</h1>
<p className="text-sm text-gray-800 hover:underline cursor-pointer">
{normalDate}
</p>
<p className="text-blue-400 capitalize "> {post.categories}</p>
</div>
</div>
<div>
Expand Down Expand Up @@ -44,6 +45,7 @@ export function PostCardUser({ post }) {
<p className="text-lg font font-thin text-black text-justify">
{post.description}
</p>
<h4 className="text-gray-400 capitalize right-0"> Source:{post.source}</h4>
</div>
</article>
);
Expand Down
68 changes: 60 additions & 8 deletions src/pages/PostForm.js
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -13,6 +13,9 @@ export function PostForm() {
title: "",
description: "",
image: null,
categories: "",
source: "",
author: "",
});
const params = useParams();

Expand All @@ -23,6 +26,9 @@ export function PostForm() {
setPost({
title: post.title,
description: post.description,
categories: post.categories,
source: post.source,
author: post.author,
});
}
})();
Expand All @@ -31,21 +37,19 @@ export function PostForm() {
return (
<div className="flex items-center justify-center">
<div className="bg-blue-950 p-10 shadow-md shadow-black mt-7 animate-fade-down animate-once animate-duration-500 animate-ease-linear">
<header className="flex justify-between items-center py-4 text-white">
<header className="flex justify between items-center py-4 text-white">
<h3 className="text-xl">New Post</h3>
<Link
to="/admin"
className="text-gray-400 text-sm hover:text-white underline"
>
Go Back
</Link>

</header>

<Formik
initialValues={post}
validationSchema={Yup.object({
title: Yup.string().required("Title is Required"),
description: Yup.string().required("Description is Required"),
categories: Yup.string(),
source: Yup.string(),
author: Yup.string(),
})}
onSubmit={async (values, actions) => {
if (params.id) {
Expand Down Expand Up @@ -102,6 +106,54 @@ export function PostForm() {
name="description"
className="text-red-400 text-sm"
/>
<label
htmlFor="categories"
className="text-sm block font-bold text-gray-400"
>
Categories
</label>
<Field
name="categories"
placeholder="Categories"
className="px-3 py-2 focus:outline-none rounded bg-gray-600 text-white w-full"
/>
<ErrorMessage
component="p"
name="categories"
className="text-red-400 text-sm"
/>
<label
htmlFor="source"
className="text-sm block font-bold text-gray-400"
>
Source
</label>
<Field
name="source"
placeholder="Source"
className="px-3 py-2 focus:outline-none rounded bg-gray-600 text-white w-full"
/>
<ErrorMessage
component="p"
name="source"
className="text-red-400 text-sm"
/>
<label
htmlFor="author"
className="text-sm block font-bold text-gray-400"
>
Author
</label>
<Field
name="author"
placeholder="Author"
className="px-3 py-2 focus:outline-none rounded bg-gray-600 text-white w-full"
/>
<ErrorMessage
component="p"
name="author"
className="text-red-400 text-sm"
/>
<label
htmlFor="image"
className="text-sm block font-bold text-gray-400"
Expand Down