From 3411a23cf7fc3e40e1f095f524ad1281e8cb3704 Mon Sep 17 00:00:00 2001 From: ilya-bkv Date: Fri, 23 Dec 2022 08:24:31 +0300 Subject: [PATCH] [WiP] createReaction debug --- src/components/Article/Comment.tsx | 40 ++++++++++++++++++++----- src/components/Article/CommentsTree.tsx | 8 +++-- src/graphql/mutation/reaction-create.ts | 12 ++------ src/graphql/types.gen.ts | 2 +- src/stores/zine/reactions.ts | 6 ++-- src/utils/apiClient.ts | 15 +++++----- 6 files changed, 53 insertions(+), 30 deletions(-) diff --git a/src/components/Article/Comment.tsx b/src/components/Article/Comment.tsx index 8568b627..f7f0b1a0 100644 --- a/src/components/Article/Comment.tsx +++ b/src/components/Article/Comment.tsx @@ -2,26 +2,30 @@ import styles from './Comment.module.scss' import type { JSX } from 'solid-js/jsx-runtime' import { Icon } from '../_shared/Icon' import { AuthorCard } from '../Author/Card' -import { Show, createMemo, createSignal } from 'solid-js' +import { Show, createMemo, createSignal, createEffect } from 'solid-js' import { clsx } from 'clsx' import type { Author, Reaction as Point } from '../../graphql/types.gen' import { t } from '../../utils/intl' -// import { createReaction, updateReaction, deleteReaction } from '../../stores/zine/reactions' +import { createReaction, updateReaction, deleteReaction } from '../../stores/zine/reactions' import MD from './MD' -import { deleteReaction } from '../../stores/zine/reactions' import { formatDate } from '../../utils' import { SharePopup } from './SharePopup' import stylesHeader from '../Nav/Header.module.scss' import Userpic from '../Author/Userpic' +import { apiClient } from '../../utils/apiClient' -export default (props: { +type Props = { level?: number comment: Partial canEdit?: boolean compact?: boolean children?: JSX.Element[] -}) => { + parent?: number +} + +export default (props: Props) => { const [isReplyVisible, setIsReplyVisible] = createSignal(false) + const [postMessageText, setPostMessageText] = createSignal('') const comment = createMemo(() => props.comment) const body = createMemo(() => (comment().body || '').trim()) @@ -31,6 +35,18 @@ export default (props: { deleteReaction(comment().id) } } + + const compose = (event) => setPostMessageText(event.target.value) + const handleCreate = async (event) => { + event.preventDefault() + // await createReaction({ + await apiClient.createReaction({ + kind: 7, + replyTo: props.parent, + body: postMessageText(), + shout: comment().shout.slug + }) + } const formattedDate = createMemo(() => formatDate(new Date(comment()?.createdAt), { hour: 'numeric', minute: 'numeric' }) ) @@ -131,13 +147,21 @@ export default (props: { -
-