diff --git a/src/app/pdf/survey-sale/page.tsx b/src/app/pdf/survey-sale/[id]/page.tsx similarity index 100% rename from src/app/pdf/survey-sale/page.tsx rename to src/app/pdf/survey-sale/[id]/page.tsx diff --git a/src/components/pdf/SurveySaleDownloadPdf.tsx b/src/components/pdf/SurveySaleDownloadPdf.tsx index 313f18d..0802308 100644 --- a/src/components/pdf/SurveySaleDownloadPdf.tsx +++ b/src/components/pdf/SurveySaleDownloadPdf.tsx @@ -1,9 +1,22 @@ 'use client' -import { useRef } from 'react' +import { useEffect, useRef } from 'react' import generatePDF, { Margin, Resolution } from 'react-to-pdf' +import { useParams } from 'next/navigation' +import { useSurvey } from '@/hooks/useSurvey' +import { radioEtcData, roofMaterial, selectBoxOptions, supplementaryFacilities } from '../survey-sale/detail/RoofForm' export default function SurveySaleDownloadPdf() { + const params = useParams() + const id = params.id + + const { surveyDetail, isLoadingSurveyDetail } = useSurvey(Number(id)) + + useEffect(() => { + if (isLoadingSurveyDetail) return + handleDownPdf() + }, [surveyDetail, isLoadingSurveyDetail]) + const targetRef = useRef(null) const handleDownPdf = () => { const options = { @@ -33,7 +46,7 @@ export default function SurveySaleDownloadPdf() { } return ( <> - + {/* */}
@@ -46,12 +59,14 @@ export default function SurveySaleDownloadPdf() { 現地明登施工店名

- Sheet2 No.4Sheet2 + {surveyDetail?.store}

現地阴買日

-

2025.05.09

+

+ {surveyDetail?.investigationDate} +

@@ -86,7 +101,7 @@ export default function SurveySaleDownloadPdf() { boxSizing: 'border-box', }} > - Sheet2No.1 + {surveyDetail?.customerName} @@ -115,7 +130,7 @@ export default function SurveySaleDownloadPdf() { boxSizing: 'border-box', }} > - Sheet2No.2 + {surveyDetail?.postCode ? `(${surveyDetail?.postCode}) ${surveyDetail?.address} ${surveyDetail?.addressDetail}` : '-'} @@ -153,7 +168,7 @@ export default function SurveySaleDownloadPdf() { boxSizing: 'border-box', }} > - Sheet2No.1 + {surveyDetail?.detailInfo?.contractCapacity} - Sheet2No.1 + {surveyDetail?.detailInfo?.retailCompany} @@ -210,7 +225,13 @@ export default function SurveySaleDownloadPdf() { boxSizing: 'border-box', }} > - Sheet2No.7 選式回答表示/自由入力回答表示 + {supplementaryFacilities + .filter((facility) => surveyDetail?.detailInfo?.supplementaryFacilities?.includes(facility.id.toString())) + .map((facility) => facility.name) + .join(', ')} + {surveyDetail?.detailInfo?.supplementaryFacilitiesEtc + ? `, (その他) ${surveyDetail?.detailInfo?.supplementaryFacilitiesEtc}` + : '-'} @@ -240,7 +261,11 @@ export default function SurveySaleDownloadPdf() { boxSizing: 'border-box', }} > - Sheet2No.8 選択式回表示/自由入力回表 + { + selectBoxOptions.installationSystem.find((system) => system.id.toString() === surveyDetail?.detailInfo?.installationSystem) + ?.name + } + {surveyDetail?.detailInfo?.installationSystemEtc ? `, (その他) ${surveyDetail?.detailInfo?.installationSystemEtc}` : '-'} @@ -278,7 +303,7 @@ export default function SurveySaleDownloadPdf() { boxSizing: 'border-box', }} > - No.9 + {surveyDetail?.detailInfo?.constructionYear === '1' ? '新築' : `既築 (${surveyDetail?.detailInfo?.constructionYear}年)`} - No.10 + {roofMaterial + .filter((material) => surveyDetail?.detailInfo?.roofMaterial?.includes(material.id.toString())) + .map((material) => material.name) + .join(', ')} + {surveyDetail?.detailInfo?.roofMaterialEtc ? `, (その他) ${surveyDetail?.detailInfo?.roofMaterialEtc}` : '-'} - No.11 + {selectBoxOptions.roofShape.find((shape) => shape.id.toString() === surveyDetail?.detailInfo?.roofShape)?.name} @@ -361,7 +390,7 @@ export default function SurveySaleDownloadPdf() { boxSizing: 'border-box', }} > - No.12 + {`${surveyDetail?.detailInfo?.roofSlope} 寸`} - No.13 + {`${surveyDetail?.detailInfo?.houseStructure ? '木製' : '(その他)'} ${surveyDetail?.detailInfo?.houseStructureEtc}`} @@ -418,7 +447,8 @@ export default function SurveySaleDownloadPdf() { boxSizing: 'border-box', }} > - No.14 + {radioEtcData.rafterMaterial.find((material) => material.id.toString() === surveyDetail?.detailInfo?.rafterMaterial)?.label ?? + (surveyDetail?.detailInfo?.rafterMaterialEtc ? `(その他) ${surveyDetail?.detailInfo?.rafterMaterialEtc}` : '-')} - No.15 + {selectBoxOptions.rafterSize.find((size) => size.id.toString() === surveyDetail?.detailInfo?.rafterSize)?.name ?? + (surveyDetail?.detailInfo?.rafterSizeEtc ? `(その他) ${surveyDetail?.detailInfo?.rafterSizeEtc}` : '-')} @@ -463,7 +494,7 @@ export default function SurveySaleDownloadPdf() { boxSizing: 'border-box', }} > - 垂木ビッチ + 垂木ピッチ - No.16 + {selectBoxOptions.rafterPitch.find((pitch) => pitch.id.toString() === surveyDetail?.detailInfo?.rafterPitch)?.name ?? + (surveyDetail?.detailInfo?.rafterPitchEtc ? `(その他) ${surveyDetail?.detailInfo?.rafterPitchEtc}` : '-')} - No.17 + {radioEtcData.rafterDirection.find((direction) => direction.id.toString() === surveyDetail?.detailInfo?.rafterDirection)?.label ?? + '-'} @@ -532,7 +565,8 @@ export default function SurveySaleDownloadPdf() { boxSizing: 'border-box', }} > - No.18 + {selectBoxOptions.openFieldPlateKind.find((kind) => kind.id.toString() === surveyDetail?.detailInfo?.openFieldPlateKind)?.name ?? + (surveyDetail?.detailInfo?.openFieldPlateKindEtc ? `(その他) ${surveyDetail?.detailInfo?.openFieldPlateKindEtc}` : '-')} - No.19 + {surveyDetail?.detailInfo?.openFieldPlateThickness ? `${surveyDetail?.detailInfo?.openFieldPlateThickness}mm` : '-'} @@ -590,7 +624,7 @@ export default function SurveySaleDownloadPdf() { boxSizing: 'border-box', }} > - No.20 + {surveyDetail?.detailInfo?.leakTrace ? 'あり' : 'なし'} @@ -620,7 +654,9 @@ export default function SurveySaleDownloadPdf() { boxSizing: 'border-box', }} > - No.21 + {radioEtcData.waterproofMaterial.find((material) => material.id.toString() === surveyDetail?.detailInfo?.waterproofMaterial) + ?.label ?? + (surveyDetail?.detailInfo?.waterproofMaterialEtc ? `(その他) ${surveyDetail?.detailInfo?.waterproofMaterialEtc}` : '-')} @@ -650,7 +686,11 @@ export default function SurveySaleDownloadPdf() { boxSizing: 'border-box', }} > - No.22 + { + radioEtcData.insulationPresence.find((presence) => presence.id.toString() === surveyDetail?.detailInfo?.insulationPresence) + ?.label + } + {surveyDetail?.detailInfo?.insulationPresenceEtc ? `(その他) ${surveyDetail?.detailInfo?.insulationPresenceEtc}` : '-'} @@ -680,7 +720,8 @@ export default function SurveySaleDownloadPdf() { boxSizing: 'border-box', }} > - No.23 + {selectBoxOptions.structureOrder.find((order) => order.id.toString() === surveyDetail?.detailInfo?.structureOrder)?.name ?? + (surveyDetail?.detailInfo?.structureOrderEtc ? `(その他) ${surveyDetail?.detailInfo?.structureOrderEtc}` : '-')} @@ -718,7 +759,14 @@ export default function SurveySaleDownloadPdf() { boxSizing: 'border-box', }} > - No.23 + { + selectBoxOptions.installationAvailability.find( + (availability) => availability.id.toString() === surveyDetail?.detailInfo?.installationAvailability, + )?.name + } + {surveyDetail?.detailInfo?.installationAvailabilityEtc + ? `(その他) ${surveyDetail?.detailInfo?.installationAvailabilityEtc}` + : '-'} @@ -738,7 +786,7 @@ export default function SurveySaleDownloadPdf() { height: '150px', }} > - No.25 + {surveyDetail?.detailInfo?.memo ?? '-'} diff --git a/src/components/popup/SurveySaleSubmitPopup.tsx b/src/components/popup/SurveySaleSubmitPopup.tsx index 8ccddab..426d49c 100644 --- a/src/components/popup/SurveySaleSubmitPopup.tsx +++ b/src/components/popup/SurveySaleSubmitPopup.tsx @@ -1,7 +1,7 @@ import Image from 'next/image' import { usePopupController } from '@/store/popupController' import { useParams } from 'next/navigation' -import { useServey } from '@/hooks/useSurvey' +import { useSurvey } from '@/hooks/useSurvey' import { useEffect, useState } from 'react' import { useSessionStore } from '@/store/session' import { useCommCode } from '@/hooks/useCommCode' @@ -61,7 +61,7 @@ export default function SurveySaleSubmitPopup() { contents: '', }) - const { submitSurvey, isSubmittingSurvey } = useServey(Number(routeId)) + const { submitSurvey, isSubmittingSurvey } = useSurvey(Number(routeId)) const handleInputChange = (field: keyof SubmitFormData, value: string) => { setSubmitData((prev) => ({ ...prev, [field]: value })) diff --git a/src/components/popup/ZipCodePopup.tsx b/src/components/popup/ZipCodePopup.tsx index 843c2b2..e468af3 100644 --- a/src/components/popup/ZipCodePopup.tsx +++ b/src/components/popup/ZipCodePopup.tsx @@ -1,6 +1,6 @@ 'use client' -import { useServey } from '@/hooks/useSurvey' +import { useSurvey } from '@/hooks/useSurvey' import { useAddressStore } from '@/store/addressStore' import { usePopupController } from '@/store/popupController' import { useState } from 'react' @@ -19,7 +19,7 @@ type Address = { export default function ZipCodePopup() { const [searchValue, setSearchValue] = useState('') //search 데이터 유무 const { setAddressData } = useAddressStore() - const { getZipCode } = useServey() + const { getZipCode } = useSurvey() const [addressInfo, setAddressInfo] = useState([]) const popupController = usePopupController() diff --git a/src/components/survey-sale/detail/ButtonForm.tsx b/src/components/survey-sale/detail/ButtonForm.tsx index 6d2d28e..db66b53 100644 --- a/src/components/survey-sale/detail/ButtonForm.tsx +++ b/src/components/survey-sale/detail/ButtonForm.tsx @@ -4,7 +4,7 @@ import type { Mode, SurveyBasicRequest, SurveyDetailInfo, SurveyDetailRequest } import { useSessionStore } from '@/store/session' import { useEffect, useState } from 'react' import { useParams, useRouter, useSearchParams } from 'next/navigation' -import { requiredFields, useServey } from '@/hooks/useSurvey' +import { requiredFields, useSurvey } from '@/hooks/useSurvey' import { usePopupController } from '@/store/popupController' export default function ButtonForm(props: { @@ -72,8 +72,8 @@ export default function ButtonForm(props: { // 저장/임시저장/수정 const id = Number(routeId) ? Number(routeId) : Number(idParam) - const { deleteSurvey, updateSurvey, isDeletingSurvey, isUpdatingSurvey } = useServey(Number(id)) - const { validateSurveyDetail, createSurvey, isCreatingSurvey } = useServey() + const { deleteSurvey, updateSurvey, isDeletingSurvey, isUpdatingSurvey } = useSurvey(Number(id)) + const { validateSurveyDetail, createSurvey, isCreatingSurvey } = useSurvey() const handleSave = (isTemporary: boolean, isSubmitProcess = false) => { const emptyField = validateSurveyDetail(props.data.roof) diff --git a/src/components/survey-sale/detail/DataTable.tsx b/src/components/survey-sale/detail/DataTable.tsx index da10167..d0ca7bf 100644 --- a/src/components/survey-sale/detail/DataTable.tsx +++ b/src/components/survey-sale/detail/DataTable.tsx @@ -1,6 +1,6 @@ 'use client' -import { useServey } from '@/hooks/useSurvey' +import { useSurvey } from '@/hooks/useSurvey' import { useParams } from 'next/navigation' import { useEffect } from 'react' import DetailForm from './DetailForm' @@ -16,7 +16,7 @@ export default function DataTable() { } }, [id]) - const { surveyDetail, isLoadingSurveyDetail } = useServey(Number(id)) + const { surveyDetail, isLoadingSurveyDetail } = useSurvey(Number(id)) if (isLoadingSurveyDetail) { return
Loading...
@@ -67,7 +67,7 @@ export default function DataTable() { ダウンロード - diff --git a/src/components/survey-sale/detail/DetailForm.tsx b/src/components/survey-sale/detail/DetailForm.tsx index 7204135..110b765 100644 --- a/src/components/survey-sale/detail/DetailForm.tsx +++ b/src/components/survey-sale/detail/DetailForm.tsx @@ -6,7 +6,7 @@ import ButtonForm from './ButtonForm' import BasicForm from './BasicForm' import RoofForm from './RoofForm' import { useParams, useSearchParams } from 'next/navigation' -import { useServey } from '@/hooks/useSurvey' +import { useSurvey } from '@/hooks/useSurvey' const roofInfoForm: SurveyDetailRequest = { contractCapacity: null, @@ -71,7 +71,7 @@ export default function DetailForm() { const modeset = Number(routeId) ? 'READ' : idParam ? 'EDIT' : 'CREATE' const id = Number(routeId) ? Number(routeId) : Number(idParam) - const { surveyDetail, validateSurveyDetail } = useServey(Number(id)) + const { surveyDetail, validateSurveyDetail } = useSurvey(Number(id)) const [mode, setMode] = useState(modeset) const [basicInfoData, setBasicInfoData] = useState(basicInfoForm) diff --git a/src/components/survey-sale/detail/RoofForm.tsx b/src/components/survey-sale/detail/RoofForm.tsx index 1942217..3e8dcc2 100644 --- a/src/components/survey-sale/detail/RoofForm.tsx +++ b/src/components/survey-sale/detail/RoofForm.tsx @@ -312,6 +312,7 @@ export default function RoofForm(props: { + {/* 설치 희망 시스템 */}
設置希望システム
diff --git a/src/components/survey-sale/list/ListTable.tsx b/src/components/survey-sale/list/ListTable.tsx index 6cba7e2..b1bc137 100644 --- a/src/components/survey-sale/list/ListTable.tsx +++ b/src/components/survey-sale/list/ListTable.tsx @@ -1,7 +1,7 @@ 'use client' import LoadMoreButton from '@/components/LoadMoreButton' -import { useServey } from '@/hooks/useSurvey' +import { useSurvey } from '@/hooks/useSurvey' import { useEffect, useState } from 'react' import { useRouter, usePathname } from 'next/navigation' import SearchForm from './SearchForm' @@ -13,7 +13,7 @@ export default function ListTable() { const router = useRouter() const pathname = usePathname() - const { surveyList, isLoadingSurveyList } = useServey() + const { surveyList, isLoadingSurveyList } = useSurvey() const { offset, setOffset } = useSurveyFilterStore() const { session } = useSessionStore() @@ -54,7 +54,7 @@ export default function ListTable() { {heldSurveyList.map((survey) => (
  • handleDetailClick(survey.id)}>
    -
    +
    {survey.srlNo}
    {survey.investigationDate}
    diff --git a/src/hooks/useSurvey.ts b/src/hooks/useSurvey.ts index 4ea7eb4..1054a2a 100644 --- a/src/hooks/useSurvey.ts +++ b/src/hooks/useSurvey.ts @@ -54,7 +54,7 @@ type ZipCode = { kana3: string } -export function useServey(id?: number): { +export function useSurvey(id?: number): { surveyList: { data: SurveyBasicInfo[]; count: number } | {} surveyDetail: SurveyBasicInfo | null isLoadingSurveyList: boolean