Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: admin 용어 등록 폼 resource(출처) 필드 추가 #107

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/app/admin/words/add/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default function AddWordPage() {
pronunciationInfo: { english: '' },
category: '비즈니스',
example: '',
resource: '',
})
const handleChange = (
e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>,
Expand All @@ -36,15 +37,15 @@ export default function AddWordPage() {
} else {
setWord((prev) => ({ ...prev, [name]: value }))
}
console.log(word)
}
function hasEmptyField() {
const { name, meaning, pronunciationInfo, example } = word
const { name, meaning, pronunciationInfo, example, resource } = word
return (
name === '' ||
meaning === '' ||
pronunciationInfo.english === '' ||
example === ''
example === '' ||
resource === ''
)
}

Expand All @@ -69,7 +70,6 @@ export default function AddWordPage() {
onChange={handleChange}
/>
</label>

<label>
용어 뜻{' '}
<Textarea
Expand All @@ -88,7 +88,6 @@ export default function AddWordPage() {
className="bg-white"
/>
</label>

<label>
발음
<Input
Expand All @@ -97,6 +96,14 @@ export default function AddWordPage() {
onChange={handleChange}
/>
</label>
<label>
출처
<Input
name="resource"
value={word.resource ?? ''}
onChange={handleChange}
/>
</label>
<fieldset>
<label>카테고리</label>
{CATEGORY.map((item) => (
Expand Down
8 changes: 7 additions & 1 deletion src/types/word.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ export type DetailWordType = {
// 관리자 용어 조회
export type AdminWordType = Pick<
DetailWordType,
'id' | 'name' | 'pronunciationInfo' | 'meaning' | 'category' | 'example'
| 'id'
| 'name'
| 'pronunciationInfo'
| 'meaning'
| 'category'
| 'example'
| 'resource'
>

// 관리자 용어 등록 폼 타입
Expand Down