-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat(admin): 지원자 수 카드 섹션 수정 페이지 및 업데이트 플로우 구현 #161
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,8 +13,5 @@ | |
], | ||
"*.{js,jsx,ts,tsx}": [ | ||
"yarn test:coverage --findRelatedTests" | ||
], | ||
"*.scss": [ | ||
"yarn stylelint" | ||
] | ||
} |
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 |
---|---|---|
@@ -1,25 +1,47 @@ | ||
'use server'; | ||
|
||
import { revalidatePath } from 'next/cache'; | ||
|
||
import { put } from '@vercel/blob'; | ||
|
||
type TotalCountStatusStateType = { | ||
message: string; | ||
messageType?: 'error' | 'success'; | ||
}; | ||
|
||
// eslint-disable-next-line import/prefer-default-export | ||
export const totalCountStatusAction = async (formData: FormData) => { | ||
const requestForm = { | ||
cumulativeApplicants: formData.get('cumulativeApplicants'), | ||
dropouts: formData.get('dropouts'), | ||
totalParticipants: formData.get('totalParticipants'), | ||
totalProjects: formData.get('totalProjects'), | ||
}; | ||
export async function totalCountStatusAction( | ||
_: TotalCountStatusStateType | null, | ||
formData: FormData, | ||
): Promise<TotalCountStatusStateType> { | ||
try { | ||
const requestForm = { | ||
cumulativeApplicants: formData.get('cumulativeApplicants'), | ||
dropouts: formData.get('dropouts'), | ||
totalParticipants: formData.get('totalParticipants'), | ||
totalProjects: formData.get('totalProjects'), | ||
}; | ||
|
||
const jsonString = JSON.stringify(requestForm); | ||
const jsonString = JSON.stringify(requestForm); | ||
|
||
const requestBlob = new Blob([jsonString], { type: 'application/json' }); | ||
const requestBlob = new Blob([jsonString], { type: 'application/json' }); | ||
|
||
const blob = await put('total_count_status.json', requestBlob, { | ||
access: 'public', | ||
token: process.env.DND_ACADEMY_V2_BLOB_READ_WRITE_TOKEN, | ||
addRandomSuffix: false, | ||
}); | ||
await put('total_count_status.json', requestBlob, { | ||
access: 'public', | ||
token: process.env.DND_ACADEMY_V2_BLOB_READ_WRITE_TOKEN, | ||
addRandomSuffix: false, | ||
}); | ||
|
||
console.log(blob); | ||
}; | ||
revalidatePath('/total-count-status'); | ||
|
||
return { | ||
message: '수정사항이 반영되었습니다. 캐시 적용으로 실제 적용까지는 최대 5분정도 소요됩니다.', | ||
messageType: 'success', | ||
}; | ||
} catch (error) { | ||
return { | ||
message: '수정사항이 반영되지 않았습니다. 잠시 후 다시 시도해주세요.', | ||
messageType: 'error', | ||
}; | ||
} | ||
} |
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,5 @@ | ||
.counterCardWrapper { | ||
display: flex; | ||
flex-direction: row; | ||
gap: 10px; | ||
} |
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,35 @@ | ||
import { api, type TotalCountStatus } from '@dnd-academy/core'; | ||
import { CounterCard, PageTitle } from '@dnd-academy/ui'; | ||
|
||
import TotalCountStatusForm from '@/components/TotalCountStatusForm'; | ||
|
||
import styles from './page.module.scss'; | ||
|
||
async function page() { | ||
const totalCountStatus = await api<TotalCountStatus>({ | ||
url: '/total_count_status.json', | ||
method: 'GET', | ||
}); | ||
|
||
const { | ||
cumulativeApplicants, dropouts, totalParticipants, totalProjects, | ||
} = totalCountStatus; | ||
|
||
return ( | ||
<> | ||
<PageTitle | ||
title="지원자 수 카드 섹션" | ||
subTitle="캐시 적용으로 실제 적용까지는 최대 5분정도 소요됩니다." | ||
/> | ||
<div className={styles.counterCardWrapper}> | ||
<CounterCard count={cumulativeApplicants} title="누적 지원자 수" /> | ||
<CounterCard count={totalParticipants} title="총 참가자 수" /> | ||
<CounterCard count={totalProjects} title="총 프로젝트 수" suffix="개" /> | ||
<CounterCard count={dropouts} title="이탈자 수" color="primary" /> | ||
</div> | ||
<TotalCountStatusForm initialTotalCountStatus={totalCountStatus} /> | ||
</> | ||
); | ||
} | ||
|
||
export default page; |
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,13 @@ | ||
function Navigator() { | ||
return ( | ||
<nav> | ||
<ul> | ||
<li> | ||
<a href="/total-count-status">지원자 수 카드 섹션 정보 업데이트하기</a> | ||
</li> | ||
</ul> | ||
</nav> | ||
); | ||
} | ||
|
||
export default Navigator; |
23 changes: 23 additions & 0 deletions
23
apps/admin/src/components/TotalCountStatusForm/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 @@ | ||
.totalCountStatusFormWrapper { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 20px; | ||
margin-top: 20px; | ||
|
||
.totalCountStatusForm { | ||
display: flex; | ||
flex-direction: row; | ||
} | ||
|
||
.message { | ||
@include text('body1'); | ||
|
||
&.error { | ||
color: color('tertiary'); | ||
} | ||
|
||
&.success { | ||
color: color('success'); | ||
} | ||
} | ||
} |
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,47 @@ | ||
'use client'; | ||
|
||
import { useFormState, useFormStatus } from 'react-dom'; | ||
|
||
import { type TotalCountStatus } from '@dnd-academy/core'; | ||
import { Button } from '@dnd-academy/ui'; | ||
import clsx from 'clsx'; | ||
|
||
import { totalCountStatusAction } from '@/actions/count'; | ||
|
||
import styles from './index.module.scss'; | ||
|
||
type Props = { | ||
initialTotalCountStatus: TotalCountStatus; | ||
}; | ||
|
||
function TotalCountStatusForm({ initialTotalCountStatus }: Props) { | ||
const { pending } = useFormStatus(); | ||
const [state, formAction] = useFormState(totalCountStatusAction, null); | ||
|
||
const { | ||
cumulativeApplicants, dropouts, totalParticipants, totalProjects, | ||
} = initialTotalCountStatus; | ||
|
||
return ( | ||
<div className={styles.totalCountStatusFormWrapper}> | ||
<form action={formAction} className={styles.totalCountStatusForm}> | ||
<input type="number" name="cumulativeApplicants" min={0} placeholder="누적 지원자 수" defaultValue={cumulativeApplicants} required /> | ||
<input type="number" name="totalParticipants" min={0} placeholder="총 참가자 수" defaultValue={totalParticipants} required /> | ||
<input type="number" name="totalProjects" min={0} placeholder="총 프로젝트 수" defaultValue={totalProjects} required /> | ||
<input type="number" name="dropouts" min={0} placeholder="이탈자 수" defaultValue={dropouts} required /> | ||
<Button type="submit" disabled={pending}>업데이트하기</Button> | ||
</form> | ||
{state?.message && ( | ||
<div className={clsx( | ||
styles.message, | ||
state.messageType && styles[state.messageType], | ||
)} | ||
> | ||
{state.message} | ||
</div> | ||
)} | ||
</div> | ||
); | ||
} | ||
|
||
export default TotalCountStatusForm; |
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
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
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
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
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
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,3 @@ | ||
/// <reference types="jest" /> | ||
|
||
declare let context: jest.Describe; |
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
27 changes: 27 additions & 0 deletions
27
packages/ui/src/components/atoms/PageTitle/PageTitle.stories.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,27 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import PageTitle from '.'; | ||
|
||
const meta = { | ||
title: 'atoms/PageTitle', | ||
component: PageTitle, | ||
parameters: { | ||
layout: 'centered', | ||
}, | ||
args: { | ||
title: 'title', | ||
}, | ||
tags: ['autodocs'], | ||
} satisfies Meta<typeof PageTitle>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = {}; | ||
|
||
export const HasSubtitle: Story = { | ||
args: { | ||
subTitle: 'subTitle', | ||
}, | ||
}; |
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
react에서는 useFormState가 useActionState로 변경되었지만, next.js에서는 아직 미반영이라 에러가 남.
vercel/next.js#65673