feature/survey-sales #1
67
src/api/surveySales.ts
Normal file
67
src/api/surveySales.ts
Normal file
@ -0,0 +1,67 @@
|
||||
import { axiosInstance } from '@/libs/axios'
|
||||
|
||||
export interface SurveySalesBasicInfo {
|
||||
id?: number
|
||||
representative: String
|
||||
store: String | null
|
||||
construction_point: String | null
|
||||
investigation_date: String | null
|
||||
building_name: String | null
|
||||
customer_name: String | null
|
||||
post_code: String | null
|
||||
address: String | null
|
||||
address_detail: String | null
|
||||
submission_status: Boolean
|
||||
submission_date?: String | null
|
||||
detail_info?: SurveySalesDetailInfo | null
|
||||
}
|
||||
|
||||
export interface SurveySalesDetailInfo {
|
||||
id?: number
|
||||
contract_capacity: String | null
|
||||
retail_company: String | null
|
||||
supplementary_facilities: Number | null
|
||||
supplementary_facilities_etc: String | null
|
||||
installation_system: Number | null
|
||||
installation_system_etc: String | null
|
||||
construction_year: Number | null
|
||||
construction_year_etc: String | null
|
||||
roof_material: Number | null
|
||||
roof_material_etc: String | null
|
||||
roof_shape: Number | null
|
||||
roof_shape_etc: String | null
|
||||
roof_slope: String | null
|
||||
house_structure: Number | null
|
||||
house_structure_etc: String | null
|
||||
rafter_material: Number | null
|
||||
rafter_material_etc: String | null
|
||||
rafter_size: Number | null
|
||||
rafter_size_etc: String | null
|
||||
rafter_pitch: Number | null
|
||||
rafter_pitch_etc: String | null
|
||||
rafter_direction: Number | null
|
||||
open_field_plate_kind: Number | null
|
||||
open_field_plate_kind_etc: String | null
|
||||
open_field_plate_thickness: String | null
|
||||
leak_trace: Boolean | null
|
||||
waterproof_material: Number | null
|
||||
waterproof_material_etc: String | null
|
||||
insulation_presence: Number | null
|
||||
insulation_presence_etc: String | null
|
||||
structure_order: Number | null
|
||||
structure_order_etc: String | null
|
||||
installation_availability: Number | null
|
||||
installation_availability_etc: String | null
|
||||
memo: String | null
|
||||
}
|
||||
|
||||
export const surveySalesApi = {
|
||||
create: async (data: SurveySalesBasicInfo): Promise<SurveySalesBasicInfo> => {
|
||||
const response = await axiosInstance.post<SurveySalesBasicInfo>('/api/survey-sales', data)
|
||||
return response.data
|
||||
},
|
||||
getList: async (): Promise<SurveySalesBasicInfo[]> => {
|
||||
const response = await axiosInstance.get<SurveySalesBasicInfo[]>('/api/survey-sales')
|
||||
return response.data
|
||||
},
|
||||
}
|
||||
13
src/app/api/survey-sales/route.ts
Normal file
13
src/app/api/survey-sales/route.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { NextResponse } from 'next/server'
|
||||
import { prisma } from '@/libs/prisma'
|
||||
|
||||
export async function POST(request: Request) {
|
||||
const body = await request.json()
|
||||
|
||||
// @ts-ignore
|
||||
const res = await prisma.SD_SERVEY_SALES_BASIC_INFO.create({
|
||||
data: body,
|
||||
})
|
||||
|
||||
return NextResponse.json({ message: 'Survey sales created successfully' })
|
||||
}
|
||||
@ -31,6 +31,12 @@ export default async function Home() {
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<div className="p-4">
|
||||
<Link href="/survey-sales">
|
||||
<button className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">조사 매물</button>
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<User />
|
||||
</div>
|
||||
</>
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
import Suitable from '@/components/Suitable'
|
||||
import SuitableCreateBtn from '@/components/SuitableCreateBtn'
|
||||
import SuitableSearch from '@/components/SuitableSearch'
|
||||
|
||||
export default function suitablePage() {
|
||||
@ -8,7 +7,7 @@ export default function suitablePage() {
|
||||
<SuitableSearch />
|
||||
<Suitable />
|
||||
{/* 최초 한번 밀어넣음 */}
|
||||
<SuitableCreateBtn />
|
||||
{/* <SuitableCreateBtn /> */}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
10
src/app/survey-sales/page.tsx
Normal file
10
src/app/survey-sales/page.tsx
Normal file
@ -0,0 +1,10 @@
|
||||
import SurveySales from '@/components/SurveySales'
|
||||
|
||||
export default function page() {
|
||||
return (
|
||||
<>
|
||||
<h1 className="text-2xl font-bold my-4 flex justify-center">조사 매물 정보</h1>
|
||||
<SurveySales />
|
||||
</>
|
||||
)
|
||||
}
|
||||
53
src/components/SurveySales.tsx
Normal file
53
src/components/SurveySales.tsx
Normal file
@ -0,0 +1,53 @@
|
||||
'use client'
|
||||
|
||||
import { surveySalesApi, SurveySalesBasicInfo } from '@/api/surveySales'
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
||||
|
||||
export default function SurveySales() {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
const {
|
||||
mutate: createSurveySales,
|
||||
isPending,
|
||||
error,
|
||||
} = useMutation({
|
||||
mutationFn: surveySalesApi.create,
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['survey-sales', 'list'] })
|
||||
},
|
||||
})
|
||||
|
||||
const handleSurveySales = () => {
|
||||
const data: SurveySalesBasicInfo = {
|
||||
representative: 'keyy1315',
|
||||
store: 'HWJ(T01)',
|
||||
construction_point: 'HWJ(T01)',
|
||||
investigation_date: '2025-04-28',
|
||||
building_name: '한화재팬빌딩',
|
||||
customer_name: 'Hong Gil Dong',
|
||||
post_code: '1050013',
|
||||
address: '서울특별시 강남구 테헤란로 14길 6 ',
|
||||
address_detail: '남도빌딩 2층',
|
||||
submission_status: false,
|
||||
}
|
||||
|
||||
createSurveySales(data)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="flex items-center justify-center">
|
||||
<div className="flex gap-2">
|
||||
<button className="bg-blue-500 text-white px-4 py-2 rounded-md" onClick={handleSurveySales}>
|
||||
신규 등록
|
||||
</button>
|
||||
<button className="bg-blue-500 text-white px-4 py-2 rounded-md">조회</button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="bg-orange-100 border-l-4 border-orange-500 text-orange-700 p-4 m-4" role="alert">
|
||||
<p className="font-bold">Be Warned</p>
|
||||
<p>기본 데이터 세팅 되어있습니다.</p>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user