diff --git a/src/components/items/registration/productDescriptionInput.tsx b/src/components/items/registration/productDescriptionInput.tsx
new file mode 100644
index 00000000..3f8e5a64
--- /dev/null
+++ b/src/components/items/registration/productDescriptionInput.tsx
@@ -0,0 +1,31 @@
+import cn from '@/lib/cn';
+import { ProductInputProps } from './types';
+
+export default function ProductDescriptionInput({
+ register,
+ errors,
+}: ProductInputProps) {
+ return (
+
+
+
+ {errors.description && (
+ {errors.description.message}
+ )}
+
+ );
+}
diff --git a/src/components/items/registration/productNameInput.tsx b/src/components/items/registration/productNameInput.tsx
new file mode 100644
index 00000000..c7abbd1d
--- /dev/null
+++ b/src/components/items/registration/productNameInput.tsx
@@ -0,0 +1,27 @@
+import cn from '@/lib/cn';
+import { ProductInputProps } from './types';
+
+export default function ProductNameInput({
+ register,
+ errors,
+}: ProductInputProps) {
+ return (
+
+
+
+ {errors.name && (
+ {errors.name.message}
+ )}
+
+ );
+}
diff --git a/src/components/items/registration/productPriceInput.tsx b/src/components/items/registration/productPriceInput.tsx
new file mode 100644
index 00000000..47fe1a40
--- /dev/null
+++ b/src/components/items/registration/productPriceInput.tsx
@@ -0,0 +1,31 @@
+import cn from '@/lib/cn';
+import { ProductInputProps } from './types';
+
+export default function ProductPriceInput({
+ register,
+ errors,
+}: ProductInputProps) {
+ return (
+
+
+ !Number.isNaN(value) || '숫자로 입력해주세요',
+ isInteger: (value) =>
+ (Number.isInteger(value) && value >= 0) ||
+ '양의 정수를 입력해주세요',
+ },
+ required: '판매 가격을 입력해주세요',
+ })}
+ />
+ {errors.price && (
+ {errors.price.message}
+ )}
+
+ );
+}
diff --git a/src/components/items/registration/productTagInput.tsx b/src/components/items/registration/productTagInput.tsx
new file mode 100644
index 00000000..2f61b96e
--- /dev/null
+++ b/src/components/items/registration/productTagInput.tsx
@@ -0,0 +1,23 @@
+import cn from '@/lib/cn';
+import { ProductTagInputProps } from './types';
+
+export default function ProductTagInput({
+ tagInput,
+ handleAddTag,
+ setTagInput,
+ tagError,
+}: ProductTagInputProps) {
+ return (
+
+
+ setTagInput(e.target.value)}
+ onKeyDown={handleAddTag}
+ placeholder='태그를 입력해주세요.'
+ className={cn('input-base', tagError.length && 'error-input')}
+ />
+ {tagError && {tagError}}
+
+ );
+}
diff --git a/src/components/items/registration/registrationForm.tsx b/src/components/items/registration/registrationForm.tsx
index e9aa1d33..67b41ab7 100644
--- a/src/components/items/registration/registrationForm.tsx
+++ b/src/components/items/registration/registrationForm.tsx
@@ -1,21 +1,23 @@
'use client';
import CommonBtn from '@/components/common/commonBtn/commonBtn';
-import cn from '@/lib/cn';
import { useForm } from 'react-hook-form';
import { ProductRegistrationFormData } from './types';
-import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
-import { faX } from '@fortawesome/free-solid-svg-icons/faX';
import { createProduct } from '@/services/api/product';
import { useMutation } from '@tanstack/react-query';
import { useRouter } from 'next/navigation';
import useTagInput from '@/hooks/useTagInput';
+import ProductNameInput from './productNameInput';
+import ProductDescriptionInput from './productDescriptionInput';
+import ProductPriceInput from './productPriceInput';
+import ProductTagInput from './productTagInput';
+import TagsContainer from './tagsContainer';
-const InputSectionStyle = 'flex flex-col gap-4 mb-8';
-const InputStyle = 'bg-bg-input px-6 py-4 rounded-[12px]';
-const LabelStyle = 'text-[18px] font-bold';
-const errorMessageStyle = 'text-text-red font-semibold text-[14px]';
-const errorInputStyle = 'border border-border-input-error';
+export const InputSectionStyle = 'flex flex-col gap-4 mb-8';
+export const InputStyle = 'bg-bg-input px-6 py-4 rounded-[12px]';
+export const LabelStyle = 'text-[18px] font-bold';
+export const errorMessageStyle = 'text-text-red font-semibold text-[14px]';
+export const errorInputStyle = 'border border-border-input-error';
export default function ProductRegistrationForm({
defaultValue,
@@ -81,99 +83,28 @@ export default function ProductRegistrationForm({
등록
-
-
-
- {errors.name && (
- {errors.name.message}
- )}
-
-
-
-
- {errors.description && (
-
- {errors.description.message}
-
- )}
-
-
-
-
- !Number.isNaN(value) || '숫자로 입력해주세요',
- isInteger: (value) =>
- (Number.isInteger(value) && value >= 0) ||
- '양의 정수를 입력해주세요',
- },
- required: '판매 가격을 입력해주세요',
- })}
- />
- {errors.price && (
- {errors.price.message}
- )}
-
-
-
- setTagInput(e.target.value)}
- onKeyDown={handleAddTag}
- placeholder='태그를 입력해주세요.'
- className={InputStyle}
- />
- {tagError && {tagError}}
-
-
- {tags.map((tag, index) => (
-
- #{tag}
-
-
- ))}
-
+
+
+
+
+
);
diff --git a/src/components/items/registration/tagsContainer.tsx b/src/components/items/registration/tagsContainer.tsx
new file mode 100644
index 00000000..cc518d0e
--- /dev/null
+++ b/src/components/items/registration/tagsContainer.tsx
@@ -0,0 +1,31 @@
+import { faX } from '@fortawesome/free-solid-svg-icons';
+import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
+import { TagsContainerProps } from './types';
+
+export default function TagsContainer({
+ tags,
+ handleRemoveTag,
+}: TagsContainerProps) {
+ return (
+
+ {tags.map((tag, index) => (
+
+ #{tag}
+
+
+ ))}
+
+ );
+}
diff --git a/src/components/items/registration/types.ts b/src/components/items/registration/types.ts
index aed3d7ef..dec4feb5 100644
--- a/src/components/items/registration/types.ts
+++ b/src/components/items/registration/types.ts
@@ -1,6 +1,25 @@
+import { FieldErrors, UseFormRegister } from 'react-hook-form';
+
export interface ProductRegistrationFormData {
name: string;
description: string;
price: number;
tags: string[];
}
+
+export interface ProductInputProps {
+ register: UseFormRegister;
+ errors: FieldErrors;
+}
+
+export interface ProductTagInputProps {
+ tagInput: string;
+ handleAddTag: (e: React.KeyboardEvent) => void;
+ setTagInput: (value: string) => void;
+ tagError: string;
+}
+
+export interface TagsContainerProps {
+ tags: string[];
+ handleRemoveTag: (index: number) => void;
+}