From 7e16f500cb7bc0cfd8bafbf6bb1555704f771231 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Fri, 29 Apr 2022 12:13:34 +0200 Subject: chore: remove old pages, components, helpers and types Since I'm using new components, I will also rewrite the GraphQL queries so it is easier to start from scratch. --- src/components/CommentsList/CommentsList.tsx | 69 ---------------------------- 1 file changed, 69 deletions(-) delete mode 100644 src/components/CommentsList/CommentsList.tsx (limited to 'src/components/CommentsList/CommentsList.tsx') diff --git a/src/components/CommentsList/CommentsList.tsx b/src/components/CommentsList/CommentsList.tsx deleted file mode 100644 index 0eaac17..0000000 --- a/src/components/CommentsList/CommentsList.tsx +++ /dev/null @@ -1,69 +0,0 @@ -import Comment from '@components/Comment/Comment'; -import Spinner from '@components/Spinner/Spinner'; -import { getCommentsByPostId } from '@services/graphql/queries'; -import { Comment as CommentData } from '@ts/types/comments'; -import { useIntl } from 'react-intl'; -import useSWR from 'swr'; -import styles from './CommentsList.module.scss'; - -const CommentsList = ({ - articleId, - comments, -}: { - articleId: number; - comments: CommentData[]; -}) => { - const intl = useIntl(); - const { data, error } = useSWR( - '/api/comments', - () => getCommentsByPostId(articleId), - { fallbackData: comments } - ); - - const getCommentsList = () => { - if (error) { - return intl.formatMessage({ - defaultMessage: 'Failed to load.', - description: 'CommentsList: failed to load', - id: 'Zlkww3', - }); - } - - if (!data) return ; - - return data.map((comment) => { - return ( - - ); - }); - }; - - return ( - <> -

- {intl.formatMessage({ - defaultMessage: 'Comments', - description: 'CommentsList: Comments section title', - id: 'Ns8CFb', - })} -

- {data && data.length > 0 ? ( -
    {getCommentsList()}
- ) : ( -

- {intl.formatMessage({ - defaultMessage: 'No comments yet.', - description: 'CommentsList: No comment message', - id: 'e9L59q', - })} -

- )} - - ); -}; - -export default CommentsList; -- cgit v1.2.3