83 lines
2.4 KiB
TypeScript

'use client'
import { useSurvey } from '@/hooks/useSurvey'
import { useParams, useRouter } from 'next/navigation'
import { useEffect } from 'react'
import DetailForm from './DetailForm'
export default function DataTable() {
const params = useParams()
const id = params.id
const router = useRouter()
useEffect(() => {
if (Number.isNaN(Number(id))) {
alert('間違ったアプローチです。')
window.location.href = '/survey-sale'
}
}, [id])
const { surveyDetail, isLoadingSurveyDetail } = useSurvey(Number(id))
if (isLoadingSurveyDetail) {
return <></>
}
return (
<>
<div className="sale-data-table-wrap">
<table className="sale-data-table">
<colgroup>
<col style={{ width: '80px' }} />
<col />
</colgroup>
<tbody>
<tr>
<th></th>
{surveyDetail?.srlNo?.startsWith('一時保存') ? (
<td>
<span className="text-red-500"></span>
</td>
) : (
<td>{surveyDetail?.srlNo}</td>
)}
</tr>
<tr>
<th></th>
<td>{surveyDetail?.regDt ? new Date(surveyDetail.regDt).toLocaleString() : ''}</td>
</tr>
<tr>
<th></th>
<td>{surveyDetail?.uptDt ? new Date(surveyDetail.uptDt).toLocaleString() : ''}</td>
</tr>
<tr>
<th></th>
<td>
{surveyDetail?.submissionStatus && surveyDetail?.submissionDate ? (
<>
<div>{new Date(surveyDetail.submissionDate).toLocaleString()}</div>
<div>
({} - {surveyDetail.submissionTargetId})
</div>
</>
) : (
'-'
)}
</td>
</tr>
<tr>
<th></th>
<td>
<button className="data-down" onClick={() => router.push(`/pdf/survey-sale/${id}`)}>
HWJ現地調査票確認<i className="down-icon"></i>
</button>
</td>
</tr>
</tbody>
</table>
</div>
<DetailForm />
</>
)
}