126 lines
6.4 KiB
TypeScript
126 lines
6.4 KiB
TypeScript
'use client'
|
|
import ContentLayout from '@/components/ui/contentLayout'
|
|
import { GovSidoSigunguSearchForm } from '@/components/ui/govSidoSigunguSearchForm'
|
|
import { Form, SearchFormRight, SelectBox } from '@common/business_components/ui'
|
|
import { SidoSigunguSelectBox } from '../components/ui/SidoSigunguSelectBox'
|
|
import { SelectBox2 } from '@common/business_components/ui/select/index-2'
|
|
import ListDiv from '@common/business_components/ui/list_div'
|
|
import { Button, Label } from '@common/components/ui'
|
|
import { type ReactNode } from 'react'
|
|
|
|
type TitleName = {
|
|
mainTitle: string
|
|
firstCardTitle: string
|
|
secondCardTitle?: string
|
|
}
|
|
type SelectBox = {
|
|
labelNm?: Label
|
|
searchChk?: boolean
|
|
title?: string // SearchDiv의 제목 (선택 사항)
|
|
}
|
|
type Label = {
|
|
first: string
|
|
second: string
|
|
third: string
|
|
fourth: string
|
|
}
|
|
type BaseLayout = {
|
|
children?: ReactNode[]
|
|
titleName: TitleName
|
|
form: any
|
|
onSubmitEvent: Function
|
|
graphBtn?: boolean
|
|
firstDivBtn?: boolean
|
|
searchBox?: SelectBox
|
|
sido?: number
|
|
setSido?: (sido: number) => void
|
|
sigungu?: number
|
|
setSigungu?: (sigungu: number) => void
|
|
}
|
|
// TODO: 나중에 이벤트 추가되면 파라미터 추가 필요 ?
|
|
/**
|
|
*
|
|
* @param children
|
|
* @param titleName : 메인 타이틀, 첫번째 요소 타이틀, 두번째 요소 타이틀
|
|
* @param form : zod 스키마
|
|
* @param onSubmitEvent : 폼 이벤트 처리
|
|
* @param graphBtn : 하단에 그래프 버튼 유무 처리
|
|
* @returns
|
|
*/
|
|
const BaseLayout = ({ children, titleName, form, onSubmitEvent, graphBtn = false, searchBox, sido, setSido, sigungu, setSigungu }: BaseLayout) => {
|
|
return (
|
|
<ContentLayout title={titleName.mainTitle}>
|
|
<ListDiv>
|
|
{/* searchBox.title이 있으면 h3 태그로 제목을 표시합니다. */}
|
|
{searchBox?.title && (
|
|
<div className="card-header">
|
|
<h3 className="text-2xl font-medium">{searchBox.title}</h3>
|
|
<div>
|
|
{graphBtn ? <Button className="!mr-[1.2rem]">다운로드</Button> : null}
|
|
{/* 그래프 있을 시 */}
|
|
{graphBtn ? <Button className="!mr-[1.2rem]">삭제</Button> : null}
|
|
</div>
|
|
</div>
|
|
)}
|
|
<div className="flex items-center w-full">
|
|
{/* <div className="flex-1">
|
|
<div className="grid grid-cols-8 gap-5 m-4"> */}
|
|
{/* <SelectBox2 label={"환경청"} selectArray={[{ text: '한강 유역청', val: '1' }]} className="col-span-2" selectClass="rounded-lg bg-white truncate" onSelectValue={(val) => { }} />
|
|
<SidoSigunguSelectBox
|
|
className='col-span-2'
|
|
sido={sido ?? 0}
|
|
sigungu={sigungu ?? 0}
|
|
onSidoChange={(sido) => {
|
|
setSido?.(sido);
|
|
setSigungu?.(sigungu ?? 0);
|
|
}}
|
|
onSigunguChange={setSigungu ?? (() => { })}
|
|
/>
|
|
<SelectBox2 label={"하수처리장"} selectArray={[{ text: '양평하수처리장', val: '1' }]} className="col-span-2" selectClass="rounded-lg bg-white truncate" onSelectValue={() => { }} />
|
|
<SelectBox2 label={"하수처리구역"} selectArray={[{ text: '하수처리구역', val: '1' }]} className="col-span-2" selectClass="rounded-lg bg-white truncate" onSelectValue={() => { }} /> */}
|
|
<GovSidoSigunguSearchForm isShowPart={true} >
|
|
<SelectBox2 label={"하수처리장"} selectArray={[{ text: '양평하수처리장', val: '1' }]} className="col-span-2" selectClass="rounded-lg bg-white truncate" onSelectValue={() => { }} />
|
|
<SelectBox2 label={"하수처리구역"} selectArray={[{ text: '하수처리구역', val: '1' }]} className="col-span-2" selectClass="rounded-lg bg-white truncate" onSelectValue={() => { }} />
|
|
</GovSidoSigunguSearchForm>
|
|
{/* </div>
|
|
</div> */}
|
|
{searchBox?.searchChk ? <SearchFormRight><Button>조회</Button></SearchFormRight> : null}
|
|
|
|
</div>
|
|
</ListDiv>
|
|
<ListDiv>
|
|
<div className="card-header">
|
|
<h3 className="text-2xl font-medium">{titleName.firstCardTitle}</h3>
|
|
<div>
|
|
{graphBtn ? <Button className="px-4 py-2 !mr-[1.2rem] bg-blue-600 text-white rounded-sm text-sm font-medium hover:bg-blue-700" size='sm'>다운로드</Button> : null}
|
|
{/* 그래프 있을 시 */}
|
|
{graphBtn ? <Button className="px-4 py-2 bg-blue-600 text-white rounded-sm text-sm font-medium hover:bg-blue-700 !mr-[1.2rem]" size='sm'>삭제</Button> : null}
|
|
</div>
|
|
</div>
|
|
<Form {...form}>
|
|
<form onSubmit={form.handleSubmit(onSubmitEvent)}>
|
|
<div className="card !m-[1.2rem]">
|
|
{/* 폼 정보 입력 칸 */}
|
|
{children?.[0]}
|
|
</div>
|
|
</form>
|
|
</Form>
|
|
</ListDiv>
|
|
{
|
|
children?.[1] != null ? <ListDiv>
|
|
<div className="card-header flex items-center justify-between">
|
|
<h3 className="text-2xl font-medium">{titleName?.secondCardTitle}</h3>
|
|
<div>
|
|
{graphBtn ? <Button className="px-4 py-2 bg-blue-600 text-white rounded-sm text-sm font-medium hover:bg-blue-700 !mr-[1.2rem]" size='sm'>다운로드</Button> : null}
|
|
{/* 그래프 있을 시 */}
|
|
{graphBtn ? <Button className="px-4 py-2 bg-blue-600 text-white rounded-sm text-sm font-medium hover:bg-blue-700 !mr-[1.2rem]" size='sm'>삭제</Button> : null}
|
|
</div>
|
|
</div>
|
|
<div className="card !m-[1.2rem]">{children?.[1]}</div>
|
|
</ListDiv> : null
|
|
}
|
|
</ContentLayout >
|
|
)
|
|
}
|
|
|
|
export default BaseLayout |