-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(admin): current-applicant-count form 페이지 적용 (#166)
- Loading branch information
1 parent
bc295ba
commit 967259b
Showing
6 changed files
with
153 additions
and
5 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 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,7 @@ | ||
.counter { | ||
@include text('H6/Bold', 'primary'); | ||
|
||
@include xs { | ||
@include text('body1/Bold'); | ||
} | ||
} |
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,34 @@ | ||
import { api, type CurrentApplicantCount } from '@dnd-academy/core'; | ||
import { Counter, PageTitle } from '@dnd-academy/ui'; | ||
|
||
import CurrentApplicantCountForm from '@/components/CurrentApplicantCountForm'; | ||
|
||
import styles from './page.module.scss'; | ||
|
||
async function page() { | ||
const currentApplicantCountData = await api<CurrentApplicantCount>({ | ||
url: '/current_applicant_count.json', | ||
method: 'GET', | ||
}); | ||
|
||
const currentApplicantCount = currentApplicantCountData.designer | ||
+ currentApplicantCountData.developer; | ||
|
||
return ( | ||
<> | ||
<PageTitle | ||
title="현재 지원자 수" | ||
subTitle="캐시 적용으로 실제 적용까지는 최대 5분정도 소요됩니다." | ||
/> | ||
<div className={styles.counter}> | ||
오늘까지 | ||
<Counter count={currentApplicantCount} /> | ||
명이 지원했어요! | ||
</div> | ||
<CurrentApplicantCountForm initialApplicantCount={currentApplicantCountData} /> | ||
</> | ||
|
||
); | ||
} | ||
|
||
export default page; |
23 changes: 23 additions & 0 deletions
23
apps/admin/src/components/CurrentApplicantCountForm/index.module.scss
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,23 @@ | ||
.applicantCountFormWrapper { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 20px; | ||
margin-top: 20px; | ||
|
||
.applicantCountForm { | ||
display: flex; | ||
flex-direction: row; | ||
} | ||
|
||
.message { | ||
@include text('body1'); | ||
|
||
&.error { | ||
color: color('tertiary'); | ||
} | ||
|
||
&.success { | ||
color: color('success'); | ||
} | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
apps/admin/src/components/CurrentApplicantCountForm/index.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,50 @@ | ||
'use client'; | ||
|
||
import { useFormState } from 'react-dom'; | ||
|
||
import { type CurrentApplicantCount } from '@dnd-academy/core'; | ||
import clsx from 'clsx'; | ||
|
||
import { currentApplicantCountAction } from '@/actions/count'; | ||
import SubmitButton from '@/components/common/SubmitButton'; | ||
|
||
import styles from './index.module.scss'; | ||
|
||
type Props = { | ||
initialApplicantCount: CurrentApplicantCount; | ||
}; | ||
|
||
function CurrentApplicantCountForm({ initialApplicantCount }: Props) { | ||
const [state, formAction] = useFormState(currentApplicantCountAction, null); | ||
|
||
return ( | ||
<div className={styles.applicantCountFormWrapper}> | ||
<form action={formAction} className={styles.applicantCountForm}> | ||
<div> | ||
<label htmlFor="designer"> | ||
디자이너 지원자 수 | ||
<input type="number" id="designer" name="designerApplicantCount" defaultValue={initialApplicantCount.designer} /> | ||
</label> | ||
</div> | ||
<div> | ||
<label htmlFor="developer"> | ||
개발자 지원자 수 | ||
<input type="number" id="developer" name="developerApplicantCount" defaultValue={initialApplicantCount.developer} /> | ||
</label> | ||
</div> | ||
<SubmitButton>업데이트하기</SubmitButton> | ||
</form> | ||
{state?.message && ( | ||
<div className={clsx( | ||
styles.message, | ||
state.messageType && styles[state.messageType], | ||
)} | ||
> | ||
{state.message} | ||
</div> | ||
)} | ||
</div> | ||
); | ||
} | ||
|
||
export default CurrentApplicantCountForm; |
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