290 lines
12 KiB
TypeScript
290 lines
12 KiB
TypeScript
'use client';
|
|
|
|
import { useEffect, useMemo } from 'react';
|
|
// import SubPageHeader from "@/components/SubPageHeader";
|
|
import Image from 'next/image';
|
|
import { useDmStore } from '@/app/store';
|
|
import { formatUsage } from '@/app/common/transValueFormat';
|
|
import type { DmStatusBildTpYearsType, DmStatusUsgBildTpType, DmStatusUsgYearsType, TableHeaderType } from '@/app/store/dm-status/type';
|
|
|
|
// 공통 섹션 타이틀 컴포넌트
|
|
function SectionTitle({ children }: { children: React.ReactNode }) {
|
|
return (
|
|
<div className='flex items-center gap-3'>
|
|
<span className='h-5 w-[3px] bg-sky-500' />
|
|
<h3 className='text-[24px] font-bold text-neutral-900'>{children}</h3>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
// 구분선
|
|
function Hr({ className = '' }: { className?: string }) {
|
|
return <div className={`h-[2px] w-full bg-black/10 ${className}`} />;
|
|
}
|
|
|
|
/* 인트로 영역 */
|
|
function RainIntroSummary() {
|
|
const items = [
|
|
{
|
|
icon: '/images/landing/icon_chart.png',
|
|
title: '지속적인 이용량 증가',
|
|
desc: '2018년 약 797만m³이었던 빗물 이용량은 5년 사이 약 75% 증가하여 수자원 절약에 기여하고 있습니다.',
|
|
},
|
|
{
|
|
icon: '/images/landing/icon_hand.png',
|
|
title: '조경용수의 핵심 자원',
|
|
desc: '재이용되는 빗물의 약 97%가 조경용수로 활용되고 있으며 이는 공원, 아파트 단지 등의 녹지 관리에 중요한 역할을 합니다.',
|
|
},
|
|
{
|
|
icon: '/images/landing/icon_building.png',
|
|
title: '민간·공공의 협력',
|
|
desc: '골프장과 같은 대규모 스포츠 시설은 물론, 최근에는 공동주택·아파트 등 내 이용량이 급증하며 일상생활 속 빗물 활용이 확산되는 추세입니다.',
|
|
},
|
|
];
|
|
|
|
return (
|
|
<div className='mb-[70px] px-[160px]'>
|
|
<div className='grid grid-cols-[1fr_400px] items-center gap-[60px]'>
|
|
{/* 좌측 */}
|
|
<div>
|
|
<h3 className='text-[40px] font-extrabold leading-[1.35] tracking-[-0.04em] text-neutral-900'>
|
|
기후위기 시대의 수자원 확보,
|
|
<br />
|
|
<span className='inline-block bg-gradient-to-b from-[#6DBB4F] to-[#01ACE5] bg-clip-text text-transparent'>빗물 재이용</span>이 앞장섭니다.
|
|
</h3>
|
|
|
|
<p className='mt-5 text-[16px] leading-[1.8] tracking-[-0.04em] text-neutral-600'>
|
|
2023년 기준 전국 3,500여 개 시설에서
|
|
<br />
|
|
연간 약 1,394만m³의 빗물을 소중한 자원으로 다시 활용하고 있습니다.
|
|
</p>
|
|
|
|
<div className='mt-10 space-y-8'>
|
|
{items.map((item) => (
|
|
<div key={item.title} className='flex gap-3 items-center'>
|
|
<div className='flex h-12 w-12 shrink-0 items-center justify-center'>
|
|
<Image src={item.icon} alt='' width={48} height={48} className='object-contain' />
|
|
</div>
|
|
|
|
<div>
|
|
<strong className='block text-[18px] font-extrabold text-neutral-900'>{item.title}</strong>
|
|
<p className='mt-2 text-[16px] leading-[1.7] text-neutral-600 tracking-tighter'>{item.desc}</p>
|
|
</div>
|
|
</div>
|
|
))}
|
|
</div>
|
|
</div>
|
|
|
|
{/* 우측 이미지 */}
|
|
<div className='flex items-center justify-center'>
|
|
<Image src='/images/landing/rain_status_img.png' alt='빗물 재이용 개념도' width={400} height={343} className='h-auto w-full max-w-[400px] object-contain' priority />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
const tableStyles = {
|
|
container: 'w-[1000px] mx-auto overflow-hidden',
|
|
table: 'w-full table-fixed border-collapse text-center text-[16px]',
|
|
th: 'border border-[#858F98] py-3 font-bold text-neutral-800',
|
|
td: 'border border-[#858F98] py-3 text-neutral-700 font-medium break-keep',
|
|
headerBg: 'bg-[#E3E7EA]',
|
|
};
|
|
|
|
const headerColors6 = ['bg-[#01ACE5]', 'bg-[#17AFC7]', 'bg-[#2CB2A9]', 'bg-[#42B58B]', 'bg-[#57B86D]', 'bg-[#81C784]'];
|
|
const headerColors8 = ['bg-[#01ACE5]', 'bg-[#10AED0]', 'bg-[#20B0BA]', 'bg-[#2FB2A5]', 'bg-[#3FB58F]', 'bg-[#4EB77A]', 'bg-[#5EB964]', 'bg-[#6DBB4F]'];
|
|
export default function RainStatusSection() {
|
|
const getRainyByBildTpYears = useDmStore((state) => state.getRainyByBildTpYears);
|
|
const getRainyByUsgBildTp = useDmStore((state) => state.getRainyByUsgBildTp);
|
|
const getRainyByUsgYears = useDmStore((state) => state.getRainyByUsgYears);
|
|
const rainyYears = useDmStore((state) => state.rainy.rainyYears);
|
|
const selectYear = rainyYears.slice(-1)[0];
|
|
const rainyByBildTpYearsHeader = useDmStore((state) => state.rainy.rainyByBildTpYearsHeader);
|
|
const rainyByBildTpYears = useDmStore((state) => state.rainy.rainyByBildTpYears);
|
|
const rainyByUsgBildTpHeader = useDmStore((state) => state.rainy.rainyByUsgBildTpHeader);
|
|
const rainyByUsgBildTp = useDmStore((state) => state.rainy.rainyByUsgBildTp);
|
|
const rainyByUsgYearsHeader = useDmStore((state) => state.rainy.rainyByUsgYearsHeader);
|
|
const rainyByUsgYears = useDmStore((state) => state.rainy.rainyByUsgYears);
|
|
const partBildTpHeader = useMemo(() => rainyByUsgBildTpHeader.slice(3).map((header) => header.title), [rainyByUsgBildTpHeader]);
|
|
|
|
// 출처 텍스트
|
|
function SourceText() {
|
|
return <p className='mt-7 text-center text-[13px] text-neutral-500'>자료: 하수도정보시스템 {selectYear} 하수도 통계</p>;
|
|
}
|
|
|
|
useEffect(() => {
|
|
void getRainyByBildTpYears();
|
|
void getRainyByUsgBildTp();
|
|
void getRainyByUsgYears();
|
|
}, [getRainyByBildTpYears, getRainyByUsgBildTp, getRainyByUsgYears]);
|
|
|
|
const renderPartHeaders = (headers: string[], headerColors: string[]) => {
|
|
return headers.map((header, index) => (
|
|
<th key={header} className={`${tableStyles.th} ${headerColors[index] ?? 'bg-[#81C784]'} text-white`} style={{ width: '140px' }}>
|
|
{header}
|
|
</th>
|
|
));
|
|
};
|
|
|
|
const renderBuildingUsageCells = (row: DmStatusBildTpYearsType | DmStatusUsgYearsType | DmStatusUsgYearsType, headers: TableHeaderType[]) => {
|
|
const rowData = row as Record<string, string | number>;
|
|
const firstHeaderId = headers[0]?.id;
|
|
const rowKey = firstHeaderId ? String(rowData[firstHeaderId] ?? '') : '';
|
|
|
|
return headers.map((header, index) => {
|
|
const value = rowData[header.id];
|
|
|
|
return (
|
|
<td key={`${rowKey}-${header.id}`} className={`${tableStyles.td} ${index === 0 ? '!font-bold !text-neutral-900' : ''} ${[1, 3, 5].includes(index) ? 'bg-[#EAF5F5]' : ''}`}>
|
|
{index === 0 ? value : formatUsage(value as string | number, 1000, 1)}
|
|
</td>
|
|
);
|
|
});
|
|
};
|
|
|
|
const renderRainyByUsgBildTpCells = (row: DmStatusUsgBildTpType) => {
|
|
return rainyByUsgBildTpHeader.map((header, index) => {
|
|
const value = row[header.id as keyof DmStatusUsgBildTpType];
|
|
const displayValue = index === 0 ? value : header.id === 'CNT' ? Number(value).toLocaleString('ko-KR') : formatUsage(value as string | number, 1000, 1);
|
|
|
|
return (
|
|
<td key={`${row.USG_NM}-${header.id}`} className={`${tableStyles.td} ${index === 0 ? '!font-bold !text-neutral-900' : ''} ${[1, 2].includes(index) ? 'bg-[#EAF5F5]' : ''}`}>
|
|
{displayValue == 0.0 ? '-' : displayValue}
|
|
</td>
|
|
);
|
|
});
|
|
};
|
|
|
|
const title = '빗물이용시설(현황)';
|
|
|
|
return (
|
|
<div className='bg-white'>
|
|
{/* 상단 타이틀 */}
|
|
<div className='inline-block'>
|
|
<h2 className='relative inline-block px-2 text-[28px] font-extrabold tracking-tight leading-none text-slate-900'>
|
|
<span className='relative z-10'>{title}</span>
|
|
<span className='absolute left-0 bottom-[-4px] z-0 h-3 w-full bg-gradient-to-r from-sky-300 to-green-300' />
|
|
</h2>
|
|
</div>
|
|
|
|
<div className='mt-[70px] pb-[120px]'>
|
|
{/* 1) 빗물이용시설의 건축물별 빗물이용량 현황 */}
|
|
<section>
|
|
{/* 인트로 영역 */}
|
|
<RainIntroSummary />
|
|
|
|
<div id='status-rain-building' className='scroll-mt-[120px]'>
|
|
<SectionTitle>빗물이용시설의 건축물별 빗물이용량 현황</SectionTitle>
|
|
|
|
<div className='mt-10'>
|
|
<div className={tableStyles.container}>
|
|
<table className={tableStyles.table}>
|
|
<thead>
|
|
<tr>
|
|
<th rowSpan={2} className={`${tableStyles.th} ${tableStyles.headerBg}`} style={{ width: '160px' }}>
|
|
구분
|
|
</th>
|
|
<th colSpan={rainyYears.length || 6} className={`${tableStyles.th} ${tableStyles.headerBg} py-2`}>
|
|
빗물이용량 (천m³/년)
|
|
</th>
|
|
</tr>
|
|
<tr>{renderPartHeaders(rainyYears, headerColors6)}</tr>
|
|
</thead>
|
|
<tbody>
|
|
{rainyByBildTpYears.map((row, idx) => (
|
|
<tr key={idx} className='bg-white'>
|
|
{renderBuildingUsageCells(row, rainyByBildTpYearsHeader)}
|
|
</tr>
|
|
))}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<SourceText />
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
<Hr className='my-11' />
|
|
|
|
{/* 2) 빗물이용시설의 용도별 분포 (xxxx년 기준) */}
|
|
<section id='status-rain-purpose-distribution' className='scroll-mt-[120px]'>
|
|
<SectionTitle>빗물이용시설의 용도별 분포 ({selectYear}년 기준)</SectionTitle>
|
|
|
|
<div className='mt-8'>
|
|
<div className={tableStyles.container}>
|
|
<table className={tableStyles.table}>
|
|
<thead>
|
|
<tr>
|
|
<th rowSpan={2} className={`${tableStyles.th} ${tableStyles.headerBg}`} style={{ width: '160px' }}>
|
|
용도
|
|
</th>
|
|
<th rowSpan={2} className={`${tableStyles.th} ${tableStyles.headerBg}`} style={{ width: '84px' }}>
|
|
개소수
|
|
<br />
|
|
(개소)
|
|
</th>
|
|
<th rowSpan={2} className={`${tableStyles.th} ${tableStyles.headerBg}`} style={{ width: '84px' }}>
|
|
저류조용량
|
|
<br />
|
|
(천m³)
|
|
</th>
|
|
<th colSpan={8} className={`${tableStyles.th} ${tableStyles.headerBg} py-2`}>
|
|
빗물이용량 (천m³/년)
|
|
</th>
|
|
</tr>
|
|
<tr>{renderPartHeaders(partBildTpHeader, headerColors8)}</tr>
|
|
</thead>
|
|
<tbody>
|
|
{rainyByUsgBildTp.map((row, idx) => (
|
|
<tr key={`${row.USG_NM}-${idx}`} className='bg-white'>
|
|
{renderRainyByUsgBildTpCells(row)}
|
|
</tr>
|
|
))}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<SourceText />
|
|
</div>
|
|
</section>
|
|
|
|
<Hr className='my-11' />
|
|
|
|
{/* 3) 빗물이용시설의 용도별 빗물이용량 현황 */}
|
|
<section id='status-rain-purpose-usage' className='scroll-mt-[120px]'>
|
|
<SectionTitle>빗물이용시설의 용도별 빗물이용량 현황</SectionTitle>
|
|
|
|
<div className='mt-8'>
|
|
<div className={tableStyles.container}>
|
|
<table className={tableStyles.table}>
|
|
<thead>
|
|
<tr>
|
|
<th rowSpan={2} className={`${tableStyles.th} ${tableStyles.headerBg}`} style={{ width: '160px' }}>
|
|
용도
|
|
</th>
|
|
<th colSpan={6} className={`${tableStyles.th} ${tableStyles.headerBg} py-2`}>
|
|
빗물이용량 (천m³/년)
|
|
</th>
|
|
</tr>
|
|
<tr>{renderPartHeaders(rainyYears, headerColors6)}</tr>
|
|
</thead>
|
|
<tbody>
|
|
{rainyByUsgYears.map((row, idx) => (
|
|
<tr key={idx} className='bg-white'>
|
|
{renderBuildingUsageCells(row, rainyByUsgYearsHeader)}
|
|
</tr>
|
|
))}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<SourceText />
|
|
</div>
|
|
</section>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|