From a26faeeb0286d3c7b140b47dfe6799075cb2d398 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9CSalar?= <“salar.sali97@gmail.com”>
Date: Wed, 12 Oct 2022 16:23:48 +0300
Subject: [PATCH] Fetch an articl by its id, Fetch the body of the
articl(content)
---
src/components/fetchAnArticle/AnArticle.tsx | 80 +++++++++++++++++++
.../fetchAnArticle/AnArticleBody.tsx | 58 ++++++++++++++
.../fetchAnArticle/AskeletonArticle.tsx | 59 ++++++++++++++
src/components/fetchAnArticle/NotFound.tsx | 33 ++++++++
4 files changed, 230 insertions(+)
create mode 100644 src/components/fetchAnArticle/AnArticle.tsx
create mode 100644 src/components/fetchAnArticle/AnArticleBody.tsx
create mode 100644 src/components/fetchAnArticle/AskeletonArticle.tsx
create mode 100644 src/components/fetchAnArticle/NotFound.tsx
diff --git a/src/components/fetchAnArticle/AnArticle.tsx b/src/components/fetchAnArticle/AnArticle.tsx
new file mode 100644
index 0000000..54d35d8
--- /dev/null
+++ b/src/components/fetchAnArticle/AnArticle.tsx
@@ -0,0 +1,80 @@
+import { useArticleViewModel } from "article/controller/articleViewModel";
+import { useArticleStore } from "article/data/articleStoreImplementation";
+import { useEffect } from "react";
+import * as ArticlePart from "../../components/Article/Article";
+import { useParams } from "react-router";
+import AskeletonArticle from "./AskeletonArticle";
+import Container from "components/Container";
+import NotFound from "./NotFound";
+import { SVGSearch } from "components/icons";
+import BaseLayout from "components/BaseLayout";
+
+const AnArticle = () => {
+ const store = useArticleStore();
+ const { article, hasError, shouldShowLoading } = useArticleViewModel(store);
+
+ const { id } = useParams();
+ const newId = `${id}`;
+
+ useEffect(() => {
+ store.getArticle(newId);
+ }, [id]);
+
+ if (hasError) {
+ return ;
+ }
+ return (
+
+
+ {shouldShowLoading ? (
+
+ ) : (
+ <>
+
+ {article?.topic}
+
+
+
+ {article?.title}
+
+
+ {article?.authors !== undefined ? article?.authors : "Unknown"}
+
+
+
+
+
+ {article?.tags && (
+
+
+ Keywords
+
+
+
+ {article?.tags}
+
+
+ )}
+
+
+ Abstract
+
+
+ {article?.summary !== undefined ? (
+ article?.summary
+ ) : (
+
+
+
+ )}
+
+
+ >
+ )}
+
+
+ );
+};
+
+// \n
+export default AnArticle;
diff --git a/src/components/fetchAnArticle/AnArticleBody.tsx b/src/components/fetchAnArticle/AnArticleBody.tsx
new file mode 100644
index 0000000..55d7f95
--- /dev/null
+++ b/src/components/fetchAnArticle/AnArticleBody.tsx
@@ -0,0 +1,58 @@
+import { useArticleViewModel } from "article/controller/articleViewModel";
+import { useArticleStore } from "article/data/articleStoreImplementation";
+import "react-loading-skeleton/dist/skeleton.css";
+import Skeleton from "react-loading-skeleton";
+import { useParams } from "react-router";
+import { useEffect } from "react";
+
+/* -------------------------------------------------------------------------- */
+/* Components */
+/* -------------------------------------------------------------------------- */
+import * as ArticlePart from "../../components/Article/Article";
+import BaseLayout from "components/BaseLayout";
+import Container from "components/Container";
+import NotFound from "./NotFound";
+
+const AnArticleBody = () => {
+ const store = useArticleStore();
+ const { article, hasError, shouldShowLoading } = useArticleViewModel(store);
+ const { id } = useParams();
+ const newId = `${id}`;
+ useEffect(() => {
+ store.getArticle(newId);
+ }, [id]);
+ if (hasError) ;
+ return (
+
+
+ {shouldShowLoading ? (
+ <>
+
+
+
+
+
+ >
+ ) : (
+ <>
+
+ {article?.topic}
+
+
+
+ {article?.title}
+
+
{article?.content}
+
+ >
+ )}
+
+
+ );
+};
+
+export default AnArticleBody;
diff --git a/src/components/fetchAnArticle/AskeletonArticle.tsx b/src/components/fetchAnArticle/AskeletonArticle.tsx
new file mode 100644
index 0000000..f0b9702
--- /dev/null
+++ b/src/components/fetchAnArticle/AskeletonArticle.tsx
@@ -0,0 +1,59 @@
+import Skeleton from "react-loading-skeleton";
+import "react-loading-skeleton/dist/skeleton.css";
+const AskeletonArticle = () => {
+ return (
+ <>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ >
+ );
+};
+
+export default AskeletonArticle;
diff --git a/src/components/fetchAnArticle/NotFound.tsx b/src/components/fetchAnArticle/NotFound.tsx
new file mode 100644
index 0000000..5db7e0d
--- /dev/null
+++ b/src/components/fetchAnArticle/NotFound.tsx
@@ -0,0 +1,33 @@
+import React from "react";
+import Container from "components/Container";
+import { Button } from "components/Button/Button";
+import Link from "components/Link";
+
+const NotFound = () => {
+ return (
+
+
+ 404
+
+ Page does not exist
+
+ Maybe you got a broken link, or maybe you made a misprint in the address
+ bar
+
+
+
+ );
+};
+
+export default NotFound;