From 8eacc8fd328d5f34e41deee139db77b0d2f37762 Mon Sep 17 00:00:00 2001 From: Marshall Ku Date: Thu, 5 Dec 2024 08:12:19 +0900 Subject: [PATCH] Add logics for picking random name --- .../blog/src/components/CommentForm/index.tsx | 19 +++++-- packages/utils/src/index.ts | 1 + packages/utils/src/lib/random.ts | 52 +++++++++++++++++++ 3 files changed, 67 insertions(+), 5 deletions(-) create mode 100644 packages/utils/src/lib/random.ts diff --git a/apps/blog/src/components/CommentForm/index.tsx b/apps/blog/src/components/CommentForm/index.tsx index b0e3627e..6dc00bba 100644 --- a/apps/blog/src/components/CommentForm/index.tsx +++ b/apps/blog/src/components/CommentForm/index.tsx @@ -2,15 +2,15 @@ import { FormEventHandler, useCallback, useRef, useState } from "react"; import { MutateOptions } from "@tanstack/react-query"; -import Typography from "@marshallku/ui/Typography"; import Input from "@marshallku/ui/Input"; import Textarea from "@marshallku/ui/Textarea"; import { Icon } from "@marshallku/icon"; -import { classNames } from "@marshallku/utils"; +import { classNames, generateRandomName } from "@marshallku/utils"; import { type CommentRequest } from "#api"; import CommentAvatar from "#components/CommentAvatar"; import styles from "./index.module.scss"; import { toast } from "@marshallku/toast"; +import Button from "@marshallku/ui/Button"; interface CommentFormProps { slug: string; @@ -21,7 +21,7 @@ interface CommentFormProps { const cx = classNames(styles, "comment-form"); function CommentForm({ slug, submit, isClientSide = false }: CommentFormProps) { - const [name, setName] = useState(""); + const [name, setName] = useState("익명"); const [body, setBody] = useState(""); const formRef = useRef(null); @@ -83,12 +83,21 @@ function CommentForm({ slug, submit, isClientSide = false }: CommentFormProps) { { setName(value); }} - /> + > + +