summaryrefslogtreecommitdiffstats
path: root/src/components/CommentForm
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2021-12-20 00:15:20 +0100
committerArmand Philippot <git@armandphilippot.com>2021-12-20 00:15:20 +0100
commitfa6adedc42e9c6ec39cc30df16b54900c220b094 (patch)
tree6bb498beadaa382245cecb86ce56931580313c6f /src/components/CommentForm
parent2ff898626c5c0abc6b8195224067b992403e313b (diff)
refactor: rewrite types and services
I was repeating myself a lot in services. So I rewrited the different functions to improve readability and I extracted some formatting functions to put them in utils. I also rewrited/reorganized some types to keep consistent names.
Diffstat (limited to 'src/components/CommentForm')
-rw-r--r--src/components/CommentForm/CommentForm.tsx21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/components/CommentForm/CommentForm.tsx b/src/components/CommentForm/CommentForm.tsx
index 988468c..b2d538f 100644
--- a/src/components/CommentForm/CommentForm.tsx
+++ b/src/components/CommentForm/CommentForm.tsx
@@ -2,7 +2,7 @@ import { ButtonSubmit } from '@components/Buttons';
import { Form, FormItem, Input, TextArea } from '@components/Form';
import Notice from '@components/Notice/Notice';
import { t } from '@lingui/macro';
-import { createComment } from '@services/graphql/comments';
+import { createComment } from '@services/graphql/mutations';
import { useState } from 'react';
const CommentForm = ({
@@ -30,15 +30,16 @@ const CommentForm = ({
e.preventDefault();
if (name && email && message && articleId) {
- const createdComment = await createComment(
- name,
- email,
- website,
- message,
- parentId,
- articleId,
- 'createComment'
- );
+ const data = {
+ author: name,
+ authorEmail: email,
+ authorUrl: website,
+ content: message,
+ parent: parentId,
+ commentOn: articleId,
+ mutationId: 'createComment',
+ };
+ const createdComment = await createComment(data);
if (createdComment.success) setIsSuccess(true);
if (isSuccess) {