diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-04-29 12:13:34 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-04-29 18:30:05 +0200 |
| commit | 7e16f500cb7bc0cfd8bafbf6bb1555704f771231 (patch) | |
| tree | bfc2b4a475cb06a787e2c4bdf284165644e82952 /src/components/CommentsList | |
| parent | 5324664e87bedfaa01ba62c0c847ef5b861e69b3 (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')
| -rw-r--r-- | src/components/CommentsList/CommentsList.module.scss | 14 | ||||
| -rw-r--r-- | src/components/CommentsList/CommentsList.tsx | 69 |
2 files changed, 0 insertions, 83 deletions
diff --git a/src/components/CommentsList/CommentsList.module.scss b/src/components/CommentsList/CommentsList.module.scss deleted file mode 100644 index 4971b15..0000000 --- a/src/components/CommentsList/CommentsList.module.scss +++ /dev/null @@ -1,14 +0,0 @@ -@use "@styles/abstracts/placeholders"; - -.title, -.no-comments { - width: max-content; - margin-left: auto; - margin-right: auto; -} - -.list { - @extend %reset-ordered-list; - - margin-bottom: var(--spacing-lg); -} 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; |
