summaryrefslogtreecommitdiffstats
path: root/src/components/CommentsList/CommentsList.tsx
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2022-04-29 12:13:34 +0200
committerArmand Philippot <git@armandphilippot.com>2022-04-29 18:30:05 +0200
commit7e16f500cb7bc0cfd8bafbf6bb1555704f771231 (patch)
treebfc2b4a475cb06a787e2c4bdf284165644e82952 /src/components/CommentsList/CommentsList.tsx
parent5324664e87bedfaa01ba62c0c847ef5b861e69b3 (diff)
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.
Diffstat (limited to 'src/components/CommentsList/CommentsList.tsx')
-rw-r--r--src/components/CommentsList/CommentsList.tsx69
1 files changed, 0 insertions, 69 deletions
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<CommentData[]>(
- '/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 <Spinner />;
-
- return data.map((comment) => {
- return (
- <Comment
- key={comment.databaseId}
- articleId={articleId}
- comment={comment}
- />
- );
- });
- };
-
- return (
- <>
- <h2 className={styles.title}>
- {intl.formatMessage({
- defaultMessage: 'Comments',
- description: 'CommentsList: Comments section title',
- id: 'Ns8CFb',
- })}
- </h2>
- {data && data.length > 0 ? (
- <ol className={styles.list}>{getCommentsList()}</ol>
- ) : (
- <p className={styles['no-comments']}>
- {intl.formatMessage({
- defaultMessage: 'No comments yet.',
- description: 'CommentsList: No comment message',
- id: 'e9L59q',
- })}
- </p>
- )}
- </>
- );
-};
-
-export default CommentsList;