-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ Form 구조를 useState에서 react-hook-form 기반으로 수정 (#282)
- Loading branch information
Showing
272 changed files
with
4,326 additions
and
5,790 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
This file was deleted.
Oops, something went wrong.
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,28 @@ | ||
'use server'; | ||
|
||
import { getRequest, postRequest, putRequest } from '@/apis'; | ||
import { Attachment } from '@/components/common/Attachments'; | ||
import { StudentType } from '@/types/academics'; | ||
|
||
export interface AcademicsByPostType { | ||
year: number; | ||
description: string; | ||
attachments: Attachment[]; | ||
} | ||
|
||
export type PostType = 'course-changes' | 'curriculum' | 'general-studies-requirements'; | ||
|
||
export const getAcademicsByPostType = (studentType: StudentType, postType: PostType) => | ||
getRequest<AcademicsByPostType>(`/v1/academics/${studentType}/${postType}`); | ||
|
||
export const postAcademicsByPostType = ( | ||
studentType: StudentType, | ||
postType: PostType, | ||
body: FormData, | ||
) => postRequest(`/v1/academics/${studentType}/${postType}`, { body, jsessionID: true }); | ||
|
||
export const putAcademicsByPostType = ( | ||
studentType: StudentType, | ||
postType: PostType, | ||
body: FormData, | ||
) => putRequest(`/v1/academics/${studentType}/${postType}`, { body, jsessionID: true }); |
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,10 @@ | ||
import { deleteRequest, putRequest } from '@/apis'; | ||
import { StudentType } from '@/types/academics'; | ||
|
||
export const putCourseChanges = (type: StudentType, year: number, body: FormData) => | ||
putRequest(`/v1/academics/${type}/course-changes/${year}`, { body, jsessionID: true }); | ||
|
||
export const deleteCourseChanges = async (type: StudentType, year: number) => | ||
deleteRequest(`/v1/academics/${type}/course-changes/${year}`, { | ||
jsessionID: true, | ||
}); |
7 changes: 4 additions & 3 deletions
7
.../academics/[type]/course-changes/index.ts → ...ics/[studentType]/course-changes/index.ts
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
File renamed without changes.
This file was deleted.
Oops, something went wrong.
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 @@ | ||
import { Attachment } from '@/components/common/Attachments'; | ||
|
||
export interface AcademicsCommon { | ||
year: number; | ||
description: string; | ||
attachments: Attachment[]; | ||
} |
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,15 @@ | ||
export const companyList = ['SAMSUNG', 'LG', 'LARGE', 'SMALL', 'GRADUATE', 'OTHER'] as const; | ||
export type Company = (typeof companyList)[number]; | ||
export const degreeList = ['bachelor', 'master', 'doctor'] as const; | ||
export type Degree = (typeof degreeList)[number]; | ||
|
||
export type Stat = { career: Company } & { [key in Degree]: number }; | ||
|
||
export const COMPANY_MAP = { | ||
SAMSUNG: '삼성', | ||
LG: 'LG', | ||
LARGE: '기타 대기업', | ||
SMALL: '중소기업', | ||
GRADUATE: '진학', | ||
OTHER: '기타', | ||
} as const; |
This file was deleted.
Oops, something went wrong.
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,9 @@ | ||
'use client'; | ||
|
||
import { GrayButton } from '@/components/common/Buttons'; | ||
import { useRouter } from '@/i18n/routing'; | ||
|
||
export default function EditButton() { | ||
const router = useRouter(); | ||
return <GrayButton title="편집" onClick={() => router.push('/.internal/edit')} />; | ||
} |
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,49 @@ | ||
'use client'; | ||
|
||
import { FormProvider, useForm } from 'react-hook-form'; | ||
|
||
import Fieldset from '@/components/form/Fieldset'; | ||
import Form from '@/components/form/Form'; | ||
import { useRouter } from '@/i18n/routing'; | ||
import { errorToStr } from '@/utils/error'; | ||
import { handleServerAction } from '@/utils/serverActionError'; | ||
import { errorToast } from '@/utils/toast'; | ||
|
||
interface FormData { | ||
description: string; | ||
} | ||
|
||
export default function InternalEditor({ | ||
description, | ||
onSubmit: _onSubmit, | ||
}: { | ||
description: string; | ||
onSubmit: (description: string) => Promise<void>; | ||
}) { | ||
const formMethods = useForm<FormData>({ defaultValues: { description } }); | ||
const { handleSubmit } = formMethods; | ||
|
||
const router = useRouter(); | ||
const onCancel = () => router.push('.internal'); | ||
|
||
const onSubmit = async ({ description }: FormData) => { | ||
try { | ||
handleServerAction(await _onSubmit(description)); | ||
} catch (e) { | ||
errorToast(errorToStr(e)); | ||
} | ||
}; | ||
|
||
return ( | ||
<FormProvider {...formMethods}> | ||
<div className="m-10 min-w-[720px]"> | ||
<Form> | ||
<Fieldset.HTML> | ||
<Form.HTML name="description" /> | ||
</Fieldset.HTML> | ||
<Form.Action onCancel={onCancel} onSubmit={handleSubmit(onSubmit)} /> | ||
</Form> | ||
</div> | ||
</FormProvider> | ||
); | ||
} |
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,19 @@ | ||
import { revalidateTag } from 'next/cache'; | ||
|
||
import { getInternal, putInternal } from '@/apis/v1/internal'; | ||
import InternalEditor from '@/app/.internal/components/InternalEditor'; | ||
import { FETCH_TAG_INTERNAL } from '@/constants/network'; | ||
import { redirectKo } from '@/i18n/routing'; | ||
|
||
export default async function InternalPage() { | ||
const { description } = await getInternal(); | ||
|
||
const onSubmit = async (description: string) => { | ||
'use server'; | ||
await putInternal(description); | ||
revalidateTag(FETCH_TAG_INTERNAL); | ||
redirectKo('/.internal'); | ||
}; | ||
|
||
return <InternalEditor description={description} onSubmit={onSubmit} />; | ||
} |
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,13 +1,17 @@ | ||
import { getInternal } from '@/apis/v1/internal'; | ||
|
||
import InternalContent from './InternalContent'; | ||
import EditButton from '@/app/.internal/components/EditButton'; | ||
import LoginVisible from '@/components/common/LoginVisible'; | ||
import HTMLViewer from '@/components/form/html/HTMLViewer'; | ||
|
||
export default async function InternalPage() { | ||
const { description } = await getInternal(); | ||
|
||
return ( | ||
<div className="m-10 min-w-[720px]"> | ||
<InternalContent description={description} /> | ||
<LoginVisible staff> | ||
<EditButton /> | ||
</LoginVisible> | ||
<HTMLViewer htmlContent={description} /> | ||
</div> | ||
); | ||
} |
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
Oops, something went wrong.