'use client' import { useServey } from '@/hooks/useSurvey' import { SurveyDetailRequest } from '@/types/Survey' import { useRouter, useSearchParams } from 'next/navigation' import { useEffect, useState } from 'react' import MultiCheckbox from './form/MultiCheckbox' const defaultDetailInfoForm: SurveyDetailRequest = { contract_capacity: null, retail_company: null, supplementary_facilities: null, supplementary_facilities_etc: null, installation_system: null, installation_system_etc: null, construction_year: null, construction_year_etc: null, roof_material: null, roof_material_etc: null, roof_shape: null, roof_shape_etc: null, roof_slope: null, house_structure: null, house_structure_etc: null, rafter_material: null, rafter_material_etc: null, rafter_size: null, rafter_size_etc: null, rafter_pitch: null, rafter_pitch_etc: null, rafter_direction: null, open_field_plate_kind: null, open_field_plate_kind_etc: null, open_field_plate_thickness: null, leak_trace: null, waterproof_material: null, waterproof_material_etc: null, insulation_presence: null, insulation_presence_etc: null, structure_order: null, structure_order_etc: null, installation_availability: null, installation_availability_etc: null, memo: null, } export default function RoofInfoForm() { const router = useRouter() const searchParams = useSearchParams() const id = searchParams.get('id') const { updateSurvey, isUpdatingSurvey, surveyDetail, createSurveyDetail } = useServey(Number(id)) const [detailInfoData, setDetailInfoData] = useState(defaultDetailInfoForm) useEffect(() => { if (surveyDetail?.detail_info) { const { id, updated_at, created_at, ...rest } = surveyDetail.detail_info setDetailInfoData(rest) } }, [surveyDetail]) const handleNumberInput = (key: keyof SurveyDetailRequest, value: number | string) => { if (typeof value === 'string') { const numberValue = value === '' ? null : Number(value) setDetailInfoData({ ...detailInfoData, [key]: numberValue }) } else { setDetailInfoData({ ...detailInfoData, [key]: value }) } } const handleTextInput = (key: keyof SurveyDetailRequest, value: string) => { setDetailInfoData({ ...detailInfoData, [key]: value || null }) } const handleBooleanInput = (key: keyof SurveyDetailRequest, checked: boolean) => { setDetailInfoData({ ...detailInfoData, [key]: checked }) } const handleUnitInput = (value: string) => { const capacity = detailInfoData.contract_capacity setDetailInfoData({ ...detailInfoData, contract_capacity: `${capacity} ${value}` }) } const handleSave = () => { if (id) { console.log('detailInfoData:: ', detailInfoData) } } return ( <>
電気関係
電気契約容量
handleTextInput('contract_capacity', e.target.value)} />
電気小売会社
handleTextInput('retail_company', e.target.value)} />
設置希望システム
屋根関係
建築研修
建築研修
屋根の斜面
住宅構造
垂木材質
垂木サイズ
垂木サイズ
垂木の方向
路地板の種類
路地板厚※小幅板を選択した場合, 厚さ. 小幅板間の間隔寸法を記載
mm
垂木の方向
住宅構造
断熱材の有無
路地板の種類
屋根製品名 設置可否確認
メモ
) }