From fa6adedc42e9c6ec39cc30df16b54900c220b094 Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Mon, 20 Dec 2021 00:15:20 +0100
Subject: 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.
---
 src/components/CommentForm/CommentForm.tsx | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

(limited to 'src/components/CommentForm/CommentForm.tsx')

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) {
-- 
cgit v1.2.3

