diff --git a/src/components/survey-sale/common/NavTab.tsx b/src/components/survey-sale/common/NavTab.tsx index 042da5d..8029afd 100644 --- a/src/components/survey-sale/common/NavTab.tsx +++ b/src/components/survey-sale/common/NavTab.tsx @@ -7,7 +7,6 @@ import { useEffect } from 'react' export default function NavTab() { const router = useRouter() const pathname = usePathname() - const router = useRouter() if (pathname === '/survey-sale') { return null diff --git a/src/components/survey-sale/detail/RoofInfoForm.tsx b/src/components/survey-sale/detail/RoofInfoForm.tsx index 6d425cc..3c8395f 100644 --- a/src/components/survey-sale/detail/RoofInfoForm.tsx +++ b/src/components/survey-sale/detail/RoofInfoForm.tsx @@ -1,6 +1,5 @@ 'use client' -import { useEffect } from 'react' import { useSurveySaleTabState } from '@/store/surveySaleTabState' import { useServey } from '@/hooks/useSurvey' diff --git a/src/components/survey-sales/SurveyDetail.tsx b/src/components/survey-sales/SurveyDetail.tsx index a50b9ab..bff8618 100644 --- a/src/components/survey-sales/SurveyDetail.tsx +++ b/src/components/survey-sales/SurveyDetail.tsx @@ -1,61 +1,61 @@ -'use client' +// 'use client' -import { useServey } from '@/hooks/useSurvey' -import { useParams, useRouter } from 'next/navigation' +// import { useServey } from '@/hooks/useSurvey' +// import { useParams, useRouter } from 'next/navigation' -export default function SurveyDetail() { - const params = useParams() - const id = params.id - const router = useRouter() +// export default function SurveyDetail() { +// const params = useParams() +// const id = params.id +// const router = useRouter() - const { surveyDetail, deleteSurvey, isDeletingSurvey, confirmSurvey } = useServey(Number(id)) +// const { surveyDetail, deleteSurvey, isDeletingSurvey, confirmSurvey } = useServey(Number(id)) - console.log('surveyDetail:: ', surveyDetail) +// console.log('surveyDetail:: ', surveyDetail) - const handleDelete = async () => { - if (confirm('delete?')) { - if (surveyDetail?.representative) { - if (surveyDetail.detail_info?.id) { - await deleteSurvey({ id: Number(surveyDetail.detail_info.id), isDetail: true }) - } - await deleteSurvey({ id: Number(id), isDetail: false }) - } - alert('delete success') - router.push('/survey-sales') - } - } - const handleSubmit = () => { - if (confirm('submit?')) { - confirmSurvey(Number(id)) - } - alert('submit success') - router.push('/survey-sales') - } +// const handleDelete = async () => { +// if (confirm('delete?')) { +// if (surveyDetail?.representative) { +// if (surveyDetail.detail_info?.id) { +// await deleteSurvey({ id: Number(surveyDetail.detail_info.id), isDetail: true }) +// } +// await deleteSurvey({ id: Number(id), isDetail: false }) +// } +// alert('delete success') +// router.push('/survey-sales') +// } +// } +// const handleSubmit = () => { +// if (confirm('submit?')) { +// confirmSurvey(Number(id)) +// } +// alert('submit success') +// router.push('/survey-sales') +// } - if (isDeletingSurvey) { - return
Deleting...
- } +// if (isDeletingSurvey) { +// return
Deleting...
+// } - return ( -
-

SurveyDetail

-

{id}

-

{surveyDetail?.representative}

-
- - - - -
- -
- ) -} +// return ( +//
+//

SurveyDetail

+//

{id}

+//

{surveyDetail?.representative}

+//
+// +// +// +// +//
+// +//
+// ) +// } diff --git a/src/components/survey-sales/write-survey-sales/MainSurveyForm.tsx b/src/components/survey-sales/write-survey-sales/MainSurveyForm.tsx index b49b96e..17ea551 100644 --- a/src/components/survey-sales/write-survey-sales/MainSurveyForm.tsx +++ b/src/components/survey-sales/write-survey-sales/MainSurveyForm.tsx @@ -1,168 +1,168 @@ -'use client' +// 'use client' -import { useState, useEffect } from 'react' -import BasicWriteForm from './BasicWriteForm' -import DetailWriteForm from './DetailWriteForm' -import { SurveySalesBasicInfo, SurveySalesDetailInfo } from '@/api/surveySales' -import { useRouter, useSearchParams } from 'next/navigation' -import { useServey } from '@/hooks/useSurvey' -import { SurveyBasicRequest, SurveyDetailRequest } from '@/types/Survey' +// import { useState, useEffect } from 'react' +// import BasicWriteForm from './BasicWriteForm' +// import DetailWriteForm from './DetailWriteForm' +// import { SurveySalesBasicInfo, SurveySalesDetailInfo } from '@/api/surveySales' +// import { useRouter, useSearchParams } from 'next/navigation' +// import { useServey } from '@/hooks/useSurvey' +// import { SurveyBasicRequest, SurveyDetailRequest } from '@/types/Survey' -type TabType = 'basic' | 'detail' +// type TabType = 'basic' | 'detail' -const defaultDetailInfoForm: SurveyDetailRequest = { - basic_info_id: 0, - 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: false, - waterproof_material: null, - waterproof_material_etc: null, - structure_order: null, - structure_order_etc: null, - insulation_presence: null, - insulation_presence_etc: null, - installation_availability: null, - installation_availability_etc: null, - memo: null, -} +// const defaultDetailInfoForm: SurveyDetailRequest = { +// basic_info_id: 0, +// 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: false, +// waterproof_material: null, +// waterproof_material_etc: null, +// structure_order: null, +// structure_order_etc: null, +// insulation_presence: null, +// insulation_presence_etc: null, +// installation_availability: null, +// installation_availability_etc: null, +// memo: null, +// } -const defaultBasicInfoForm: SurveyBasicRequest = { - representative: '', - store: null, - construction_point: null, - investigation_date: null, - building_name: null, - customer_name: null, - post_code: null, - address: null, - address_detail: null, - submission_status: false, - submission_date: null, -} +// const defaultBasicInfoForm: SurveyBasicRequest = { +// representative: '', +// store: null, +// construction_point: null, +// investigation_date: null, +// building_name: null, +// customer_name: null, +// post_code: null, +// address: null, +// address_detail: null, +// submission_status: false, +// submission_date: null, +// } -export default function MainSurveyForm() { - const searchParams = useSearchParams() +// export default function MainSurveyForm() { +// const searchParams = useSearchParams() - const id = searchParams.get('id') +// const id = searchParams.get('id') - const [activeTab, setActiveTab] = useState('basic') +// const [activeTab, setActiveTab] = useState('basic') - const handleTabClick = (tab: TabType) => { - setActiveTab(tab) - } +// const handleTabClick = (tab: TabType) => { +// setActiveTab(tab) +// } - const router = useRouter() - const { createSurvey, isCreatingSurvey, createSurveyDetail, surveyDetail, updateSurvey } = useServey(Number(id)) +// const router = useRouter() +// const { createSurvey, isCreatingSurvey, createSurveyDetail, surveyDetail, updateSurvey } = useServey(Number(id)) - const [detailInfoForm, setDetailInfoForm] = useState(defaultDetailInfoForm) - const [basicInfoData, setBasicInfoData] = useState(defaultBasicInfoForm) +// const [detailInfoForm, setDetailInfoForm] = useState(defaultDetailInfoForm) +// const [basicInfoData, setBasicInfoData] = useState(defaultBasicInfoForm) - useEffect(() => { - if (surveyDetail) { - setBasicInfoData({ - ...defaultBasicInfoForm, - ...(({ id, ...rest }) => rest)(surveyDetail), - }) - setDetailInfoForm({ - ...defaultDetailInfoForm, - ...(surveyDetail.detail_info ? (({ id, basic_info_id, updated_at, ...rest }) => rest)(surveyDetail.detail_info as any) : {}), - }) - } - }, [surveyDetail]) +// useEffect(() => { +// if (surveyDetail) { +// setBasicInfoData({ +// ...defaultBasicInfoForm, +// ...(({ id, ...rest }) => rest)(surveyDetail), +// }) +// setDetailInfoForm({ +// ...defaultDetailInfoForm, +// ...(surveyDetail.detail_info ? (({ id, basic_info_id, updated_at, ...rest }) => rest)(surveyDetail.detail_info as any) : {}), +// }) +// } +// }, [surveyDetail]) - const handleSave = async (isSubmit: boolean = false) => { - if (id) { - updateSurvey({ - ...basicInfoData, - submission_status: isSubmit, - submission_date: isSubmit ? new Date().toISOString() : null, - }) - router.push('/survey-sales') - return - } +// const handleSave = async (isSubmit: boolean = false) => { +// if (id) { +// updateSurvey({ +// ...basicInfoData, +// submission_status: isSubmit, +// submission_date: isSubmit ? new Date().toISOString() : null, +// }) +// router.push('/survey-sales') +// return +// } - const surveyId = await createSurvey(basicInfoData) - if (surveyId && surveyId !== 0) { - createSurveyDetail({ - surveyId, - surveyDetail: detailInfoForm, - }) - router.push('/survey-sales') - return - } - throw new Error('‼️Survey creation failed') - } - if (isCreatingSurvey) { - return
Loading...
- } +// const surveyId = await createSurvey(basicInfoData) +// if (surveyId && surveyId !== 0) { +// createSurveyDetail({ +// surveyId, +// surveyDetail: detailInfoForm, +// }) +// router.push('/survey-sales') +// return +// } +// throw new Error('‼️Survey creation failed') +// } +// if (isCreatingSurvey) { +// return
Loading...
+// } - return ( -
- {/* TAB BUTTONS */} -
- - -
+// return ( +//
+// {/* TAB BUTTONS */} +//
+// +// +//
- {/* Tab Content */} -
- {activeTab === 'basic' && ( -
-

Basic Information

- -
- )} - {activeTab === 'detail' && ( -
-

Detail Information

- -
- )} -
-
- - - -
-
- ) -} +// {/* Tab Content */} +//
+// {activeTab === 'basic' && ( +//
+//

Basic Information

+// +//
+// )} +// {activeTab === 'detail' && ( +//
+//

Detail Information

+// +//
+// )} +//
+//
+// +// +// +//
+//
+// ) +// }