-
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.
ποΈ μλͺ»λ searchParam νμ
μμ (#324)
- Loading branch information
Showing
2 changed files
with
42 additions
and
33 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
app/[locale]/community/council/meeting-minute/create/client.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,34 @@ | ||
'use client'; | ||
|
||
import { postMinutesByYearAction } from '@/actions/council'; | ||
import PageLayout from '@/components/layout/pageLayout/PageLayout'; | ||
import { councilMinute } from '@/constants/segmentNode'; | ||
import { useRouter } from '@/i18n/routing'; | ||
import { contentToFormData } from '@/utils/formData'; | ||
import { getPath } from '@/utils/page'; | ||
|
||
import CouncilMeetingMinuteEditor, { MinuteFormData } from '../CouncilMeetingMinuteEditor'; | ||
|
||
const minutePath = getPath(councilMinute); | ||
|
||
export default function CouncilMinuteCreateClientPage({ year }: { year: number }) { | ||
const router = useRouter(); | ||
|
||
const onCancel = () => router.push(minutePath); | ||
|
||
const onSubmit = async (requestObject: MinuteFormData) => { | ||
const formData = contentToFormData('CREATE', { attachments: requestObject.file }); | ||
await postMinutesByYearAction(requestObject.year, formData); | ||
}; | ||
|
||
return ( | ||
// TODO: μλ¬Έ λ²μ | ||
<PageLayout title={`${year ? `${year}λ ` : ''}νμν νμλ‘ μΆκ°`} titleType="big" hideNavbar> | ||
<CouncilMeetingMinuteEditor | ||
defaultValues={year ? { year, file: [] } : undefined} | ||
onSubmit={onSubmit} | ||
onCancel={onCancel} | ||
/> | ||
</PageLayout> | ||
); | ||
} |
41 changes: 8 additions & 33 deletions
41
app/[locale]/community/council/meeting-minute/create/page.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 |
---|---|---|
@@ -1,42 +1,17 @@ | ||
'use client'; | ||
|
||
import { postMinutesByYearAction } from '@/actions/council'; | ||
import PageLayout from '@/components/layout/pageLayout/PageLayout'; | ||
import { councilMinute } from '@/constants/segmentNode'; | ||
import { useRouter } from '@/i18n/routing'; | ||
import { contentToFormData } from '@/utils/formData'; | ||
import { getPath } from '@/utils/page'; | ||
import CouncilMinuteCreateClientPage from '@/app/[locale]/community/council/meeting-minute/create/client'; | ||
|
||
import CouncilMeetingMinuteEditor, { MinuteFormData } from '../CouncilMeetingMinuteEditor'; | ||
|
||
const minutePath = getPath(councilMinute); | ||
|
||
export default function CouncilMinuteCreatePage({ | ||
export default async function CouncilMinuteCreatePage({ | ||
searchParams, | ||
}: { | ||
searchParams: { year?: string }; | ||
searchParams: Promise<{ year?: string }>; | ||
}) { | ||
const year = Number(searchParams.year); | ||
if (searchParams.year !== undefined && Number.isNaN(year)) | ||
throw new Error('/meeting-minute?year=[year]: yearκ° μ«μκ° μλλλ€.'); | ||
const { year } = await searchParams; | ||
const yearInNumber = Number(year); | ||
|
||
const router = useRouter(); | ||
|
||
const onCancel = () => router.push(minutePath); | ||
|
||
const onSubmit = async (requestObject: MinuteFormData) => { | ||
const formData = contentToFormData('CREATE', { attachments: requestObject.file }); | ||
await postMinutesByYearAction(requestObject.year, formData); | ||
}; | ||
if (yearInNumber !== undefined && Number.isNaN(yearInNumber)) | ||
throw new Error('/meeting-minute?year=[year]: yearκ° μ«μκ° μλλλ€.'); | ||
|
||
return ( | ||
// TODO: μλ¬Έ λ²μ | ||
<PageLayout title={`${year ? `${year}λ ` : ''}νμν νμλ‘ μΆκ°`} titleType="big" hideNavbar> | ||
<CouncilMeetingMinuteEditor | ||
defaultValues={year ? { year, file: [] } : undefined} | ||
onSubmit={onSubmit} | ||
onCancel={onCancel} | ||
/> | ||
</PageLayout> | ||
); | ||
return <CouncilMinuteCreateClientPage year={yearInNumber} />; | ||
} |