structural changes

This commit is contained in:
VividTruthKeeper 2022-09-30 14:25:41 +05:00
parent 992c99bfcf
commit 8e5148b3fb
5 changed files with 64 additions and 74 deletions

View File

@ -33,7 +33,6 @@ const Post = () => {
} }
} }
}, [posts]); }, [posts]);
console.log(postData ? parseDate(postData.publish_date)[0] : "");
return ( return (
<main className="post"> <main className="post">
<div className="container"> <div className="container">
@ -56,29 +55,20 @@ const Post = () => {
</h4> </h4>
</div> </div>
<div className="post__content"> <div className="post__content">
<div className="post__content__block">
<h4>ID</h4>
<input type="text" readOnly value={postData ? postData.id : ""} />
</div>
<div className="post__content__block"> <div className="post__content__block">
<h4>Category</h4> <h4>Category</h4>
<input <input
type="text" type="text"
readOnly readOnly
value={ value={postData ? postData.category : ""}
postData
? capitalizeFirstLetter(postData.category.toLowerCase())
: ""
}
/> />
</div> </div>
<div className="post__content__block"> <div className="post__content__block">
<h4>Title</h4> <h4>Summary</h4>
<input <textarea
type="text"
readOnly readOnly
value={postData ? postData.title : ""} value={postData ? postData.summary : ""}
/> ></textarea>
</div> </div>
<a <a
@ -128,8 +118,8 @@ const Post = () => {
parseDate(History.new_published_at)[1] parseDate(History.new_published_at)[1]
}`} }`}
</td> </td>
<td>{`${parseDate(History.createdAt)[0]}, ${ <td>{`${parseDate(History.created_at)[0]}, ${
parseDate(History.createdAt)[1] parseDate(History.created_at)[1]
}`}</td> }`}</td>
<td>{`${parseDate(History.updatedAt)[0]}, ${ <td>{`${parseDate(History.updatedAt)[0]}, ${
parseDate(History.updatedAt)[1] parseDate(History.updatedAt)[1]

View File

@ -38,8 +38,8 @@ interface filtersType {
fil_link: filterType; fil_link: filterType;
fil_publish_date: filterType; fil_publish_date: filterType;
fil_summary: filterType; fil_summary: filterType;
fil_createdAt: filterType; fil_created_atAt: filterType;
fil_updatedAt: filterType; fil_updated_atAt: filterType;
} }
const Posts = () => { const Posts = () => {
@ -59,9 +59,9 @@ const Posts = () => {
title: "asc", title: "asc",
link: "asc", link: "asc",
date: "asc", date: "asc",
published: "asc", publish_date: "asc",
created: "asc", created_at: "asc",
updated: "asc", updated_at: "asc",
}); });
const [filters, setFilters] = useState<filtersType>({ const [filters, setFilters] = useState<filtersType>({
@ -81,12 +81,12 @@ const Posts = () => {
name: "fil_summary", name: "fil_summary",
value: "", value: "",
}, },
fil_createdAt: { fil_created_atAt: {
name: "fil_createdAt", name: "fil_created_atAt",
value: "", value: "",
}, },
fil_updatedAt: { fil_updated_atAt: {
name: "fil_updatedAt", name: "fil_updated_atAt",
value: "", value: "",
}, },
}); });
@ -199,12 +199,12 @@ const Posts = () => {
name: "fil_summary", name: "fil_summary",
value: "", value: "",
}, },
fil_createdAt: { fil_created_atAt: {
name: "fil_createdAt", name: "fil_created_atAt",
value: "", value: "",
}, },
fil_updatedAt: { fil_updated_atAt: {
name: "fil_updatedAt", name: "fil_updated_atAt",
value: "", value: "",
}, },
}); });
@ -285,20 +285,20 @@ const Posts = () => {
<span>Link</span> <span>Link</span>
</th> </th>
<th <th
className={sort === "published" ? "active" : ""} className={sort === "publish_date" ? "active" : ""}
onClick={() => { onClick={() => {
setSort("published"); setSort("publish_date");
if (params.published !== "asc") if (params.publish_date !== "asc")
setParams({ ...params, published: "asc" }); setParams({ ...params, publish_date: "asc" });
else setParams({ ...params, published: "desc" }); else setParams({ ...params, publish_date: "desc" });
}} }}
> >
{sort === "published" && params.published === "asc" ? ( {sort === "publish_date" && params.publish_date === "asc" ? (
<IconContext.Provider value={{ color: "#7d69ef" }}> <IconContext.Provider value={{ color: "#7d69ef" }}>
<FaArrowUp /> <FaArrowUp />
</IconContext.Provider> </IconContext.Provider>
) : null} ) : null}
{sort === "published" && params.published === "desc" ? ( {sort === "publish_date" && params.publish_date === "desc" ? (
<IconContext.Provider value={{ color: "#7d69ef" }}> <IconContext.Provider value={{ color: "#7d69ef" }}>
<FaArrowDown /> <FaArrowDown />
</IconContext.Provider> </IconContext.Provider>
@ -306,20 +306,20 @@ const Posts = () => {
<span>Published</span> <span>Published</span>
</th> </th>
<th <th
className={sort === "created" ? "active" : ""} className={sort === "created_at" ? "active" : ""}
onClick={() => { onClick={() => {
setSort("created"); setSort("created_at");
if (params.created !== "asc") if (params.created_at !== "asc")
setParams({ ...params, created: "asc" }); setParams({ ...params, created_at: "asc" });
else setParams({ ...params, created: "desc" }); else setParams({ ...params, created_at: "desc" });
}} }}
> >
{sort === "created" && params.created === "asc" ? ( {sort === "created_at" && params.created_at === "asc" ? (
<IconContext.Provider value={{ color: "#7d69ef" }}> <IconContext.Provider value={{ color: "#7d69ef" }}>
<FaArrowUp /> <FaArrowUp />
</IconContext.Provider> </IconContext.Provider>
) : null} ) : null}
{sort === "created" && params.created === "desc" ? ( {sort === "created_at" && params.created_at === "desc" ? (
<IconContext.Provider value={{ color: "#7d69ef" }}> <IconContext.Provider value={{ color: "#7d69ef" }}>
<FaArrowDown /> <FaArrowDown />
</IconContext.Provider> </IconContext.Provider>
@ -327,20 +327,20 @@ const Posts = () => {
<span>Created</span> <span>Created</span>
</th> </th>
<th <th
className={sort === "updated" ? "active" : ""} className={sort === "updated_at" ? "active" : ""}
onClick={() => { onClick={() => {
setSort("updated"); setSort("updated_at");
if (params.updated !== "asc") if (params.updated_at !== "asc")
setParams({ ...params, updated: "asc" }); setParams({ ...params, updated_at: "asc" });
else setParams({ ...params, updated: "desc" }); else setParams({ ...params, updated_at: "desc" });
}} }}
> >
{sort === "updated" && params.updated === "asc" ? ( {sort === "updated_at" && params.updated_at === "asc" ? (
<IconContext.Provider value={{ color: "#7d69ef" }}> <IconContext.Provider value={{ color: "#7d69ef" }}>
<FaArrowUp /> <FaArrowUp />
</IconContext.Provider> </IconContext.Provider>
) : null} ) : null}
{sort === "updated" && params.updated === "desc" ? ( {sort === "updated_at" && params.updated_at === "desc" ? (
<IconContext.Provider value={{ color: "#7d69ef" }}> <IconContext.Provider value={{ color: "#7d69ef" }}>
<FaArrowDown /> <FaArrowDown />
</IconContext.Provider> </IconContext.Provider>
@ -388,8 +388,8 @@ const Posts = () => {
</th> </th>
<th> <th>
<input <input
placeholder="Filter by published" placeholder="Filter by publish_date"
id="filter-published" id="filter-publish_date"
type="date" type="date"
value={filters.fil_publish_date.value} value={filters.fil_publish_date.value}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => { onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
@ -405,15 +405,15 @@ const Posts = () => {
</th> </th>
<th> <th>
<input <input
placeholder="Filter by created" placeholder="Filter by created_at"
id="filter-created" id="filter-created_at"
type="date" type="date"
value={filters.fil_createdAt.value} value={filters.fil_created_atAt.value}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => { onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
setFilters({ setFilters({
...filters, ...filters,
fil_createdAt: { fil_created_atAt: {
...filters.fil_createdAt, ...filters.fil_created_atAt,
value: e.target.value, value: e.target.value,
}, },
}); });
@ -422,15 +422,15 @@ const Posts = () => {
</th> </th>
<th> <th>
<input <input
placeholder="Filter by updated" placeholder="Filter by updated_at"
id="filter-updated" id="filter-updated_at"
type="date" type="date"
value={filters.fil_updatedAt.value} value={filters.fil_updated_atAt.value}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
setFilters({ setFilters({
...filters, ...filters,
fil_updatedAt: { fil_updated_atAt: {
...filters.fil_updatedAt, ...filters.fil_updated_atAt,
value: e.target.value, value: e.target.value,
}, },
}) })
@ -467,11 +467,11 @@ const Posts = () => {
<td>{`${parseDate(post.publish_date)[0]}, ${ <td>{`${parseDate(post.publish_date)[0]}, ${
parseDate(post.publish_date)[1] parseDate(post.publish_date)[1]
}`}</td> }`}</td>
<td>{`${parseDate(post.createdAt)[0]}, ${ <td>{`${parseDate(post.created_at)[0]}, ${
parseDate(post.createdAt)[1] parseDate(post.created_at)[1]
}`}</td> }`}</td>
<td>{`${parseDate(post.updatedAt)[0]}, ${ <td>{`${parseDate(post.created_at)[0]}, ${
parseDate(post.updatedAt)[1] parseDate(post.created_at)[1]
}`}</td> }`}</td>
</tr> </tr>
</Link> </Link>

View File

@ -2,6 +2,6 @@ export interface LinksAll {
id: number; id: number;
name: string; name: string;
source: string; source: string;
createdAt: Date; created_at: Date;
updatedAt: Date; updatedAt: Date;
} }

View File

@ -2,7 +2,7 @@ export interface HistoryList {
old_published_at: Date; old_published_at: Date;
new_published_at: Date; new_published_at: Date;
PostID: number; PostID: number;
createdAt: Date; created_at: Date;
updatedAt: Date; updatedAt: Date;
} }
export interface PostType { export interface PostType {
@ -12,7 +12,7 @@ export interface PostType {
link: string; link: string;
publish_date: Date; publish_date: Date;
summary: string; summary: string;
createdAt: Date; created_at: Date;
updatedAt: Date; updatedAt: Date;
HistoryList: HistoryList[]; HistoryList: HistoryList[];
} }
@ -22,7 +22,7 @@ export interface paramsType {
title: "asc" | "desc"; title: "asc" | "desc";
link: "asc" | "desc"; link: "asc" | "desc";
date: "asc" | "desc"; date: "asc" | "desc";
published: "asc" | "desc"; publish_date: "asc" | "desc";
created: "asc" | "desc"; created_at: "asc" | "desc";
updated: "asc" | "desc"; updated_at: "asc" | "desc";
} }

View File

@ -2,7 +2,7 @@ export interface SourceType {
id: number; id: number;
name: string; name: string;
source: string; source: string;
createdAt: Date; created_at: Date;
updatedAt: Date; updatedAt: Date;
} }