-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
360 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
77 changes: 77 additions & 0 deletions
77
frontend/src/app/add-shows/_components/custom-tag-input.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
"use client"; | ||
|
||
import { memo } from "react"; | ||
import { UseFormSetValue } from "react-hook-form"; | ||
|
||
import { ShowType } from "../types/index"; | ||
|
||
interface CustomTagInputProps { | ||
tagInput: string; | ||
setTagInput: (value: string) => void; | ||
selectedTags: string[]; | ||
setSelectedTags: (tags: string[]) => void; | ||
setValue: UseFormSetValue<ShowType>; | ||
} | ||
|
||
export default function CustomTagInputComponent({ | ||
tagInput, | ||
setTagInput, | ||
selectedTags, | ||
setSelectedTags, | ||
setValue, | ||
}: CustomTagInputProps): JSX.Element { | ||
const handleAddTag = (e: React.KeyboardEvent<HTMLInputElement>) => { | ||
if (e.key === "Enter" && tagInput.trim() !== "") { | ||
e.preventDefault(); | ||
if (!selectedTags.includes(tagInput.trim())) { | ||
const newTags = [...selectedTags, tagInput.trim()]; | ||
setSelectedTags(newTags); | ||
setValue("tags", newTags); | ||
} | ||
setTagInput(""); | ||
} | ||
}; | ||
|
||
const handleRemoveTag = (tagToRemove: string) => { | ||
const newTags = selectedTags.filter((tag) => tag !== tagToRemove); | ||
setSelectedTags(newTags); | ||
setValue("tags", newTags); | ||
}; | ||
|
||
return ( | ||
<div className="w-full md:w-full lg:w-full"> | ||
<label htmlFor="tag" className="mb-5 block text-16-600"> | ||
태그 | ||
</label> | ||
<input | ||
id="tag" | ||
type="text" | ||
value={tagInput} | ||
onChange={(e) => setTagInput(e.target.value)} | ||
onKeyDown={handleAddTag} | ||
placeholder="태그를 입력하고 Enter를 누르세요" | ||
className="flex h-58 w-full items-start gap-10 rounded-6 border bg-white p-16" | ||
/> | ||
<div className="mt-5 flex flex-wrap gap-5"> | ||
{selectedTags.map((tag) => ( | ||
<span | ||
key={tag} | ||
className="flex items-center gap-1 rounded-full bg-blue-100 px-8 py-4 text-16-400 text-blue-800" | ||
> | ||
{tag} | ||
<button | ||
type="button" | ||
onClick={() => handleRemoveTag(tag)} | ||
className="text-blue-800 hover:text-blue-900" | ||
> | ||
× | ||
</button> | ||
</span> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
const CustomTagInput = memo(CustomTagInputComponent); | ||
CustomTagInput.displayName = "CustomTagInput"; |
111 changes: 0 additions & 111 deletions
111
frontend/src/app/add-shows/_components/date-time-select.tsx
This file was deleted.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
frontend/src/app/add-shows/_components/description-input.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import clsx from "clsx"; | ||
import { memo } from "react"; | ||
import { FieldErrors, UseFormRegister } from "react-hook-form"; | ||
|
||
import { ShowType } from "../types"; | ||
|
||
interface DescriptionInputProps { | ||
register: UseFormRegister<ShowType>; | ||
errors: FieldErrors<ShowType>; | ||
} | ||
|
||
export default function DescriptionInputComponent({ | ||
register, | ||
errors, | ||
}: DescriptionInputProps): JSX.Element { | ||
return ( | ||
<div className="w-full md:w-full lg:w-full"> | ||
<label htmlFor="description" className="mb-5 block text-16-600"> | ||
설명 * | ||
</label> | ||
<textarea | ||
id="description" | ||
className={clsx( | ||
"h-138 w-full resize-none rounded-6 border p-16", | ||
errors.description && "border-red-500", | ||
)} | ||
placeholder="팝업/전시회 설명을 입력해주세요" | ||
{...register("description")} | ||
/> | ||
{errors.description?.message && ( | ||
<p className="text-14-400 text-red-500">{errors.description.message}</p> | ||
)} | ||
</div> | ||
); | ||
} | ||
|
||
const DescriptionInput = memo(DescriptionInputComponent); | ||
DescriptionInput.displayName = "DescriptionInput"; |
Oops, something went wrong.