fix: solve conflict
- 충돌 해결 및 이전 sample page 주석 처리
This commit is contained in:
parent
ec9f0fa747
commit
8153dd9d18
@ -7,7 +7,6 @@ import { useEffect } from 'react'
|
|||||||
export default function NavTab() {
|
export default function NavTab() {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const pathname = usePathname()
|
const pathname = usePathname()
|
||||||
const router = useRouter()
|
|
||||||
|
|
||||||
if (pathname === '/survey-sale') {
|
if (pathname === '/survey-sale') {
|
||||||
return null
|
return null
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import { useEffect } from 'react'
|
|
||||||
import { useSurveySaleTabState } from '@/store/surveySaleTabState'
|
import { useSurveySaleTabState } from '@/store/surveySaleTabState'
|
||||||
|
|
||||||
import { useServey } from '@/hooks/useSurvey'
|
import { useServey } from '@/hooks/useSurvey'
|
||||||
|
|||||||
@ -1,61 +1,61 @@
|
|||||||
'use client'
|
// 'use client'
|
||||||
|
|
||||||
import { useServey } from '@/hooks/useSurvey'
|
// import { useServey } from '@/hooks/useSurvey'
|
||||||
import { useParams, useRouter } from 'next/navigation'
|
// import { useParams, useRouter } from 'next/navigation'
|
||||||
|
|
||||||
export default function SurveyDetail() {
|
// export default function SurveyDetail() {
|
||||||
const params = useParams()
|
// const params = useParams()
|
||||||
const id = params.id
|
// const id = params.id
|
||||||
const router = useRouter()
|
// 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 () => {
|
// const handleDelete = async () => {
|
||||||
if (confirm('delete?')) {
|
// if (confirm('delete?')) {
|
||||||
if (surveyDetail?.representative) {
|
// if (surveyDetail?.representative) {
|
||||||
if (surveyDetail.detail_info?.id) {
|
// if (surveyDetail.detail_info?.id) {
|
||||||
await deleteSurvey({ id: Number(surveyDetail.detail_info.id), isDetail: true })
|
// await deleteSurvey({ id: Number(surveyDetail.detail_info.id), isDetail: true })
|
||||||
}
|
// }
|
||||||
await deleteSurvey({ id: Number(id), isDetail: false })
|
// await deleteSurvey({ id: Number(id), isDetail: false })
|
||||||
}
|
// }
|
||||||
alert('delete success')
|
// alert('delete success')
|
||||||
router.push('/survey-sales')
|
// router.push('/survey-sales')
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
const handleSubmit = () => {
|
// const handleSubmit = () => {
|
||||||
if (confirm('submit?')) {
|
// if (confirm('submit?')) {
|
||||||
confirmSurvey(Number(id))
|
// confirmSurvey(Number(id))
|
||||||
}
|
// }
|
||||||
alert('submit success')
|
// alert('submit success')
|
||||||
router.push('/survey-sales')
|
// router.push('/survey-sales')
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (isDeletingSurvey) {
|
// if (isDeletingSurvey) {
|
||||||
return <div>Deleting...</div>
|
// return <div>Deleting...</div>
|
||||||
}
|
// }
|
||||||
|
|
||||||
return (
|
// return (
|
||||||
<div>
|
// <div>
|
||||||
<h1>SurveyDetail</h1>
|
// <h1>SurveyDetail</h1>
|
||||||
<p>{id}</p>
|
// <p>{id}</p>
|
||||||
<p>{surveyDetail?.representative}</p>
|
// <p>{surveyDetail?.representative}</p>
|
||||||
<div className="flex gap-3">
|
// <div className="flex gap-3">
|
||||||
<button className="bg-blue-500 text-white px-2 py-1 rounded-md cursor-pointer" onClick={() => router.push('/survey-sales/write?id=' + id)}>
|
// <button className="bg-blue-500 text-white px-2 py-1 rounded-md cursor-pointer" onClick={() => router.push('/survey-sales/write?id=' + id)}>
|
||||||
edit
|
// edit
|
||||||
</button>
|
// </button>
|
||||||
<button className="bg-blue-500 text-white px-2 py-1 rounded-md cursor-pointer" onClick={handleSubmit}>
|
// <button className="bg-blue-500 text-white px-2 py-1 rounded-md cursor-pointer" onClick={handleSubmit}>
|
||||||
submit
|
// submit
|
||||||
</button>
|
// </button>
|
||||||
<button className="bg-red-500 text-white px-2 py-1 rounded-md cursor-pointer" onClick={handleDelete}>
|
// <button className="bg-red-500 text-white px-2 py-1 rounded-md cursor-pointer" onClick={handleDelete}>
|
||||||
delete
|
// delete
|
||||||
</button>
|
// </button>
|
||||||
<button className="bg-gray-500 text-white px-2 py-1 rounded-md cursor-pointer" onClick={() => router.back()}>
|
// <button className="bg-gray-500 text-white px-2 py-1 rounded-md cursor-pointer" onClick={() => router.back()}>
|
||||||
back
|
// back
|
||||||
</button>
|
// </button>
|
||||||
</div>
|
// </div>
|
||||||
<input type="text" className="input-frame" disabled defaultValue={surveyDetail?.store ?? ''} />
|
// <input type="text" className="input-frame" disabled defaultValue={surveyDetail?.store ?? ''} />
|
||||||
</div>
|
// </div>
|
||||||
)
|
// )
|
||||||
}
|
// }
|
||||||
|
|||||||
@ -1,168 +1,168 @@
|
|||||||
'use client'
|
// 'use client'
|
||||||
|
|
||||||
import { useState, useEffect } from 'react'
|
// import { useState, useEffect } from 'react'
|
||||||
import BasicWriteForm from './BasicWriteForm'
|
// import BasicWriteForm from './BasicWriteForm'
|
||||||
import DetailWriteForm from './DetailWriteForm'
|
// import DetailWriteForm from './DetailWriteForm'
|
||||||
import { SurveySalesBasicInfo, SurveySalesDetailInfo } from '@/api/surveySales'
|
// import { SurveySalesBasicInfo, SurveySalesDetailInfo } from '@/api/surveySales'
|
||||||
import { useRouter, useSearchParams } from 'next/navigation'
|
// import { useRouter, useSearchParams } from 'next/navigation'
|
||||||
import { useServey } from '@/hooks/useSurvey'
|
// import { useServey } from '@/hooks/useSurvey'
|
||||||
import { SurveyBasicRequest, SurveyDetailRequest } from '@/types/Survey'
|
// import { SurveyBasicRequest, SurveyDetailRequest } from '@/types/Survey'
|
||||||
|
|
||||||
type TabType = 'basic' | 'detail'
|
// type TabType = 'basic' | 'detail'
|
||||||
|
|
||||||
const defaultDetailInfoForm: SurveyDetailRequest = {
|
// const defaultDetailInfoForm: SurveyDetailRequest = {
|
||||||
basic_info_id: 0,
|
// basic_info_id: 0,
|
||||||
contract_capacity: null,
|
// contract_capacity: null,
|
||||||
retail_company: null,
|
// retail_company: null,
|
||||||
supplementary_facilities: null,
|
// supplementary_facilities: null,
|
||||||
supplementary_facilities_etc: null,
|
// supplementary_facilities_etc: null,
|
||||||
installation_system: null,
|
// installation_system: null,
|
||||||
installation_system_etc: null,
|
// installation_system_etc: null,
|
||||||
construction_year: null,
|
// construction_year: null,
|
||||||
construction_year_etc: null,
|
// construction_year_etc: null,
|
||||||
roof_material: null,
|
// roof_material: null,
|
||||||
roof_material_etc: null,
|
// roof_material_etc: null,
|
||||||
roof_shape: null,
|
// roof_shape: null,
|
||||||
roof_shape_etc: null,
|
// roof_shape_etc: null,
|
||||||
roof_slope: null,
|
// roof_slope: null,
|
||||||
house_structure: null,
|
// house_structure: null,
|
||||||
house_structure_etc: null,
|
// house_structure_etc: null,
|
||||||
rafter_material: null,
|
// rafter_material: null,
|
||||||
rafter_material_etc: null,
|
// rafter_material_etc: null,
|
||||||
rafter_size: null,
|
// rafter_size: null,
|
||||||
rafter_size_etc: null,
|
// rafter_size_etc: null,
|
||||||
rafter_pitch: null,
|
// rafter_pitch: null,
|
||||||
rafter_pitch_etc: null,
|
// rafter_pitch_etc: null,
|
||||||
rafter_direction: null,
|
// rafter_direction: null,
|
||||||
open_field_plate_kind: null,
|
// open_field_plate_kind: null,
|
||||||
open_field_plate_kind_etc: null,
|
// open_field_plate_kind_etc: null,
|
||||||
open_field_plate_thickness: null,
|
// open_field_plate_thickness: null,
|
||||||
leak_trace: false,
|
// leak_trace: false,
|
||||||
waterproof_material: null,
|
// waterproof_material: null,
|
||||||
waterproof_material_etc: null,
|
// waterproof_material_etc: null,
|
||||||
structure_order: null,
|
// structure_order: null,
|
||||||
structure_order_etc: null,
|
// structure_order_etc: null,
|
||||||
insulation_presence: null,
|
// insulation_presence: null,
|
||||||
insulation_presence_etc: null,
|
// insulation_presence_etc: null,
|
||||||
installation_availability: null,
|
// installation_availability: null,
|
||||||
installation_availability_etc: null,
|
// installation_availability_etc: null,
|
||||||
memo: null,
|
// memo: null,
|
||||||
}
|
// }
|
||||||
|
|
||||||
const defaultBasicInfoForm: SurveyBasicRequest = {
|
// const defaultBasicInfoForm: SurveyBasicRequest = {
|
||||||
representative: '',
|
// representative: '',
|
||||||
store: null,
|
// store: null,
|
||||||
construction_point: null,
|
// construction_point: null,
|
||||||
investigation_date: null,
|
// investigation_date: null,
|
||||||
building_name: null,
|
// building_name: null,
|
||||||
customer_name: null,
|
// customer_name: null,
|
||||||
post_code: null,
|
// post_code: null,
|
||||||
address: null,
|
// address: null,
|
||||||
address_detail: null,
|
// address_detail: null,
|
||||||
submission_status: false,
|
// submission_status: false,
|
||||||
submission_date: null,
|
// submission_date: null,
|
||||||
}
|
// }
|
||||||
|
|
||||||
export default function MainSurveyForm() {
|
// export default function MainSurveyForm() {
|
||||||
const searchParams = useSearchParams()
|
// const searchParams = useSearchParams()
|
||||||
|
|
||||||
const id = searchParams.get('id')
|
// const id = searchParams.get('id')
|
||||||
|
|
||||||
const [activeTab, setActiveTab] = useState<TabType>('basic')
|
// const [activeTab, setActiveTab] = useState<TabType>('basic')
|
||||||
|
|
||||||
const handleTabClick = (tab: TabType) => {
|
// const handleTabClick = (tab: TabType) => {
|
||||||
setActiveTab(tab)
|
// setActiveTab(tab)
|
||||||
}
|
// }
|
||||||
|
|
||||||
const router = useRouter()
|
// const router = useRouter()
|
||||||
const { createSurvey, isCreatingSurvey, createSurveyDetail, surveyDetail, updateSurvey } = useServey(Number(id))
|
// const { createSurvey, isCreatingSurvey, createSurveyDetail, surveyDetail, updateSurvey } = useServey(Number(id))
|
||||||
|
|
||||||
const [detailInfoForm, setDetailInfoForm] = useState<SurveyDetailRequest>(defaultDetailInfoForm)
|
// const [detailInfoForm, setDetailInfoForm] = useState<SurveyDetailRequest>(defaultDetailInfoForm)
|
||||||
const [basicInfoData, setBasicInfoData] = useState<SurveyBasicRequest>(defaultBasicInfoForm)
|
// const [basicInfoData, setBasicInfoData] = useState<SurveyBasicRequest>(defaultBasicInfoForm)
|
||||||
|
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
if (surveyDetail) {
|
// if (surveyDetail) {
|
||||||
setBasicInfoData({
|
// setBasicInfoData({
|
||||||
...defaultBasicInfoForm,
|
// ...defaultBasicInfoForm,
|
||||||
...(({ id, ...rest }) => rest)(surveyDetail),
|
// ...(({ id, ...rest }) => rest)(surveyDetail),
|
||||||
})
|
// })
|
||||||
setDetailInfoForm({
|
// setDetailInfoForm({
|
||||||
...defaultDetailInfoForm,
|
// ...defaultDetailInfoForm,
|
||||||
...(surveyDetail.detail_info ? (({ id, basic_info_id, updated_at, ...rest }) => rest)(surveyDetail.detail_info as any) : {}),
|
// ...(surveyDetail.detail_info ? (({ id, basic_info_id, updated_at, ...rest }) => rest)(surveyDetail.detail_info as any) : {}),
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
}, [surveyDetail])
|
// }, [surveyDetail])
|
||||||
|
|
||||||
const handleSave = async (isSubmit: boolean = false) => {
|
// const handleSave = async (isSubmit: boolean = false) => {
|
||||||
if (id) {
|
// if (id) {
|
||||||
updateSurvey({
|
// updateSurvey({
|
||||||
...basicInfoData,
|
// ...basicInfoData,
|
||||||
submission_status: isSubmit,
|
// submission_status: isSubmit,
|
||||||
submission_date: isSubmit ? new Date().toISOString() : null,
|
// submission_date: isSubmit ? new Date().toISOString() : null,
|
||||||
})
|
// })
|
||||||
router.push('/survey-sales')
|
// router.push('/survey-sales')
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
const surveyId = await createSurvey(basicInfoData)
|
// const surveyId = await createSurvey(basicInfoData)
|
||||||
if (surveyId && surveyId !== 0) {
|
// if (surveyId && surveyId !== 0) {
|
||||||
createSurveyDetail({
|
// createSurveyDetail({
|
||||||
surveyId,
|
// surveyId,
|
||||||
surveyDetail: detailInfoForm,
|
// surveyDetail: detailInfoForm,
|
||||||
})
|
// })
|
||||||
router.push('/survey-sales')
|
// router.push('/survey-sales')
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
throw new Error('‼️Survey creation failed')
|
// throw new Error('‼️Survey creation failed')
|
||||||
}
|
// }
|
||||||
if (isCreatingSurvey) {
|
// if (isCreatingSurvey) {
|
||||||
return <div>Loading...</div>
|
// return <div>Loading...</div>
|
||||||
}
|
// }
|
||||||
|
|
||||||
return (
|
// return (
|
||||||
<div>
|
// <div>
|
||||||
{/* TAB BUTTONS */}
|
// {/* TAB BUTTONS */}
|
||||||
<div>
|
// <div>
|
||||||
<button
|
// <button
|
||||||
onClick={() => handleTabClick('basic')}
|
// onClick={() => handleTabClick('basic')}
|
||||||
className={`flex-1 px-4 py-2 text-center focus:outline-none focus:ring-2 focus:ring-blue-500
|
// className={`flex-1 px-4 py-2 text-center focus:outline-none focus:ring-2 focus:ring-blue-500
|
||||||
${activeTab === 'basic' ? 'border-b-2 border-blue-500 font-semibold text-blue-600' : 'text-gray-500 hover:text-gray-700'}`}
|
// ${activeTab === 'basic' ? 'border-b-2 border-blue-500 font-semibold text-blue-600' : 'text-gray-500 hover:text-gray-700'}`}
|
||||||
aria-selected={activeTab === 'basic'}
|
// aria-selected={activeTab === 'basic'}
|
||||||
role="tab"
|
// role="tab"
|
||||||
>
|
// >
|
||||||
Basic Info
|
// Basic Info
|
||||||
</button>
|
// </button>
|
||||||
<button
|
// <button
|
||||||
onClick={() => handleTabClick('detail')}
|
// onClick={() => handleTabClick('detail')}
|
||||||
className={`flex-1 px-4 py-2 text-center focus:outline-none focus:ring-2 focus:ring-blue-500
|
// className={`flex-1 px-4 py-2 text-center focus:outline-none focus:ring-2 focus:ring-blue-500
|
||||||
${activeTab === 'detail' ? 'border-b-2 border-blue-500 font-semibold text-blue-600' : 'text-gray-500 hover:text-gray-700'}`}
|
// ${activeTab === 'detail' ? 'border-b-2 border-blue-500 font-semibold text-blue-600' : 'text-gray-500 hover:text-gray-700'}`}
|
||||||
aria-selected={activeTab === 'detail'}
|
// aria-selected={activeTab === 'detail'}
|
||||||
role="tab"
|
// role="tab"
|
||||||
>
|
// >
|
||||||
Detail Info
|
// Detail Info
|
||||||
</button>
|
// </button>
|
||||||
</div>
|
// </div>
|
||||||
|
|
||||||
{/* Tab Content */}
|
// {/* Tab Content */}
|
||||||
<div className="mt-6">
|
// <div className="mt-6">
|
||||||
{activeTab === 'basic' && (
|
// {activeTab === 'basic' && (
|
||||||
<div className="rounded-lg border p-4">
|
// <div className="rounded-lg border p-4">
|
||||||
<h2 className="text-lg font-semibold">Basic Information</h2>
|
// <h2 className="text-lg font-semibold">Basic Information</h2>
|
||||||
<BasicWriteForm basicInfoData={basicInfoData} setBasicInfoData={setBasicInfoData} />
|
// <BasicWriteForm basicInfoData={basicInfoData} setBasicInfoData={setBasicInfoData} />
|
||||||
</div>
|
// </div>
|
||||||
)}
|
// )}
|
||||||
{activeTab === 'detail' && (
|
// {activeTab === 'detail' && (
|
||||||
<div className="rounded-lg border p-4">
|
// <div className="rounded-lg border p-4">
|
||||||
<h2 className="text-lg font-semibold">Detail Information</h2>
|
// <h2 className="text-lg font-semibold">Detail Information</h2>
|
||||||
<DetailWriteForm detailInfoForm={detailInfoForm} setDetailInfoForm={setDetailInfoForm} />
|
// <DetailWriteForm detailInfoForm={detailInfoForm} setDetailInfoForm={setDetailInfoForm} />
|
||||||
</div>
|
// </div>
|
||||||
)}
|
// )}
|
||||||
</div>
|
// </div>
|
||||||
<div className="flex justify-start gap-4">
|
// <div className="flex justify-start gap-4">
|
||||||
<button onClick={() => handleSave(false)}>save</button>
|
// <button onClick={() => handleSave(false)}>save</button>
|
||||||
<button onClick={() => handleSave(true)}>submit</button>
|
// <button onClick={() => handleSave(true)}>submit</button>
|
||||||
<button onClick={() => router.push('/survey-sales')}>cancel</button>
|
// <button onClick={() => router.push('/survey-sales')}>cancel</button>
|
||||||
</div>
|
// </div>
|
||||||
</div>
|
// </div>
|
||||||
)
|
// )
|
||||||
}
|
// }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user