Compare commits

..

No commits in common. "47be6a4433c9f237c9b8f0255a6f3e48d548da3f" and "34319dadcdf9a216682e18cf3b1b0bc39eb3c2bc" have entirely different histories.

32 changed files with 687 additions and 1019 deletions

View File

@ -4,14 +4,4 @@
NEXT_PUBLIC_API_URL=http://localhost:3000 NEXT_PUBLIC_API_URL=http://localhost:3000
#qsp 로그인 api #qsp 로그인 api
NEXT_PUBLIC_QSP_API_URL=http://1.248.227.176:8120 NEXT_PUBLIC_QSP_API_URL=http://1.248.227.176:8120
#1:1문의 api
NEXT_PUBLIC_INQUIRY_API_URL=http://1.248.227.176:38080
#QPARTNER 로그인 api
DB_HOST=asdf
DB_USER=asdf
DB_PASSWORD=asdf
DB_DATABASE=asdf
DB_PORT=3306

View File

@ -2,14 +2,4 @@
NEXT_PUBLIC_API_URL=http://172.30.1.35:3000 NEXT_PUBLIC_API_URL=http://172.30.1.35:3000
#qsp 로그인 api #qsp 로그인 api
NEXT_PUBLIC_QSP_API_URL=http://1.248.227.176:8120 NEXT_PUBLIC_QSP_API_URL=http://1.248.227.176:8120
#1:1문의 api
NEXT_PUBLIC_INQUIRY_API_URL=http://1.248.227.176:38080
#QPARTNER 로그인 api
DB_HOST=asdf
DB_USER=asdf
DB_PASSWORD=asdf
DB_DATABASE=asdf
DB_PORT=3306

View File

@ -41,20 +41,3 @@ onClick={() => popupController.setZipCodePopup(false)}
# useEffect 정리 # useEffect 정리
- client url pathname 변경시 -> @/components/ui/Header.tsx - client url pathname 변경시 -> @/components/ui/Header.tsx
# User Role 구분
session에 있는 role 키로 구분한다
- T01 / T01 -> Super user\
session.role === 'T01'
- A03 / 1234 -> T01을 제외한 1차점\
session.role === 'Admin'
- 2A03 / 1234 -> 2차점\
session.role === 'Admin_Sub'
- constA03_01 / 1234 -> 시공사\
session.role === 'Builder'
- partners -> Q.Partners 계정\
session.role === 'Partner'
- 이외의 경우 -> 굳이 체크할 필요 없어보임\
session.role === 'User'

View File

@ -9,7 +9,7 @@
"lint": "next lint" "lint": "next lint"
}, },
"dependencies": { "dependencies": {
"@prisma/client": "^6.7.0", "@prisma/client": "^6.5.0",
"@tanstack/react-query": "^5.71.0", "@tanstack/react-query": "^5.71.0",
"@tanstack/react-query-devtools": "^5.71.0", "@tanstack/react-query-devtools": "^5.71.0",
"axios": "^1.8.4", "axios": "^1.8.4",
@ -29,7 +29,7 @@
"@types/node": "^20", "@types/node": "^20",
"@types/react": "^19", "@types/react": "^19",
"@types/react-dom": "^19", "@types/react-dom": "^19",
"prisma": "^6.7.0", "prisma": "^6.5.0",
"tailwindcss": "^4", "tailwindcss": "^4",
"typescript": "^5" "typescript": "^5"
} }

78
pnpm-lock.yaml generated
View File

@ -9,8 +9,8 @@ importers:
.: .:
dependencies: dependencies:
'@prisma/client': '@prisma/client':
specifier: ^6.7.0 specifier: ^6.5.0
version: 6.7.0(prisma@6.7.0(typescript@5.8.2))(typescript@5.8.2) version: 6.5.0(prisma@6.5.0(typescript@5.8.2))(typescript@5.8.2)
'@tanstack/react-query': '@tanstack/react-query':
specifier: ^5.71.0 specifier: ^5.71.0
version: 5.71.0(react@19.1.0) version: 5.71.0(react@19.1.0)
@ -64,8 +64,8 @@ importers:
specifier: ^19 specifier: ^19
version: 19.0.4(@types/react@19.0.12) version: 19.0.4(@types/react@19.0.12)
prisma: prisma:
specifier: ^6.7.0 specifier: ^6.5.0
version: 6.7.0(typescript@5.8.2) version: 6.5.0(typescript@5.8.2)
tailwindcss: tailwindcss:
specifier: ^4 specifier: ^4
version: 4.0.17 version: 4.0.17
@ -541,8 +541,8 @@ packages:
resolution: {integrity: sha512-dfUnCxiN9H4ap84DvD2ubjw+3vUNpstxa0TneY/Paat8a3R4uQZDLSvWjmznAY/DoahqTHl9V46HF/Zs3F29pg==} resolution: {integrity: sha512-dfUnCxiN9H4ap84DvD2ubjw+3vUNpstxa0TneY/Paat8a3R4uQZDLSvWjmznAY/DoahqTHl9V46HF/Zs3F29pg==}
engines: {node: '>= 10.0.0'} engines: {node: '>= 10.0.0'}
'@prisma/client@6.7.0': '@prisma/client@6.5.0':
resolution: {integrity: sha512-+k61zZn1XHjbZul8q6TdQLpuI/cvyfil87zqK2zpreNIXyXtpUv3+H/oM69hcsFcZXaokHJIzPAt5Z8C8eK2QA==} resolution: {integrity: sha512-M6w1Ql/BeiGoZmhMdAZUXHu5sz5HubyVcKukbLs3l0ELcQb8hTUJxtGEChhv4SVJ0QJlwtLnwOLgIRQhpsm9dw==}
engines: {node: '>=18.18'} engines: {node: '>=18.18'}
peerDependencies: peerDependencies:
prisma: '*' prisma: '*'
@ -553,23 +553,23 @@ packages:
typescript: typescript:
optional: true optional: true
'@prisma/config@6.7.0': '@prisma/config@6.5.0':
resolution: {integrity: sha512-di8QDdvSz7DLUi3OOcCHSwxRNeW7jtGRUD2+Z3SdNE3A+pPiNT8WgUJoUyOwJmUr5t+JA2W15P78C/N+8RXrOA==} resolution: {integrity: sha512-sOH/2Go9Zer67DNFLZk6pYOHj+rumSb0VILgltkoxOjYnlLqUpHPAN826vnx8HigqnOCxj9LRhT6U7uLiIIWgw==}
'@prisma/debug@6.7.0': '@prisma/debug@6.5.0':
resolution: {integrity: sha512-RabHn9emKoYFsv99RLxvfG2GHzWk2ZI1BuVzqYtmMSIcuGboHY5uFt3Q3boOREM9de6z5s3bQoyKeWnq8Fz22w==} resolution: {integrity: sha512-fc/nusYBlJMzDmDepdUtH9aBsJrda2JNErP9AzuHbgUEQY0/9zQYZdNlXmKoIWENtio+qarPNe/+DQtrX5kMcQ==}
'@prisma/engines-version@6.7.0-36.3cff47a7f5d65c3ea74883f1d736e41d68ce91ed': '@prisma/engines-version@6.5.0-73.173f8d54f8d52e692c7e27e72a88314ec7aeff60':
resolution: {integrity: sha512-EvpOFEWf1KkJpDsBCrih0kg3HdHuaCnXmMn7XFPObpFTzagK1N0Q0FMnYPsEhvARfANP5Ok11QyoTIRA2hgJTA==} resolution: {integrity: sha512-iK3EmiVGFDCmXjSpdsKGNqy9hOdLnvYBrJB61far/oP03hlIxrb04OWmDjNTwtmZ3UZdA5MCvI+f+3k2jPTflQ==}
'@prisma/engines@6.7.0': '@prisma/engines@6.5.0':
resolution: {integrity: sha512-3wDMesnOxPrOsq++e5oKV9LmIiEazFTRFZrlULDQ8fxdub5w4NgRBoxtWbvXmj2nJVCnzuz6eFix3OhIqsZ1jw==} resolution: {integrity: sha512-FVPQYHgOllJklN9DUyujXvh3hFJCY0NX86sDmBErLvoZjy2OXGiZ5FNf3J/C4/RZZmCypZBYpBKEhx7b7rEsdw==}
'@prisma/fetch-engine@6.7.0': '@prisma/fetch-engine@6.5.0':
resolution: {integrity: sha512-zLlAGnrkmioPKJR4Yf7NfW3hftcvqeNNEHleMZK9yX7RZSkhmxacAYyfGsCcqRt47jiZ7RKdgE0Wh2fWnm7WsQ==} resolution: {integrity: sha512-3LhYA+FXP6pqY8FLHCjewyE8pGXXJ7BxZw2rhPq+CZAhvflVzq4K8Qly3OrmOkn6wGlz79nyLQdknyCG2HBTuA==}
'@prisma/get-platform@6.7.0': '@prisma/get-platform@6.5.0':
resolution: {integrity: sha512-i9IH5lO4fQwnMLvQLYNdgVh9TK3PuWBfQd7QLk/YurnAIg+VeADcZDbmhAi4XBBDD+hDif9hrKyASu0hbjwabw==} resolution: {integrity: sha512-xYcvyJwNMg2eDptBYFqFLUCfgi+wZLcj6HDMsj0Qw0irvauG4IKmkbywnqwok0B+k+W+p+jThM2DKTSmoPCkzw==}
'@swc/counter@0.1.3': '@swc/counter@0.1.3':
resolution: {integrity: sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==} resolution: {integrity: sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==}
@ -1187,8 +1187,8 @@ packages:
resolution: {integrity: sha512-dle9A3yYxlBSrt8Fu+IpjGT8SY8hN0mlaA6GY8t0P5PjIOZemULz/E2Bnm/2dcUOena75OTNkHI76uZBNUUq3A==} resolution: {integrity: sha512-dle9A3yYxlBSrt8Fu+IpjGT8SY8hN0mlaA6GY8t0P5PjIOZemULz/E2Bnm/2dcUOena75OTNkHI76uZBNUUq3A==}
engines: {node: ^10 || ^12 || >=14} engines: {node: ^10 || ^12 || >=14}
prisma@6.7.0: prisma@6.5.0:
resolution: {integrity: sha512-vArg+4UqnQ13CVhc2WUosemwh6hr6cr6FY2uzDvCIFwH8pu8BXVv38PktoMLVjtX7sbYThxbnZF5YiR8sN2clw==} resolution: {integrity: sha512-yUGXmWqv5F4PByMSNbYFxke/WbnyTLjnJ5bKr8fLkcnY7U5rU9rUTh/+Fja+gOrRxEgtCbCtca94IeITj4j/pg==}
engines: {node: '>=18.18'} engines: {node: '>=18.18'}
hasBin: true hasBin: true
peerDependencies: peerDependencies:
@ -1760,38 +1760,38 @@ snapshots:
'@parcel/watcher-win32-x64': 2.5.1 '@parcel/watcher-win32-x64': 2.5.1
optional: true optional: true
'@prisma/client@6.7.0(prisma@6.7.0(typescript@5.8.2))(typescript@5.8.2)': '@prisma/client@6.5.0(prisma@6.5.0(typescript@5.8.2))(typescript@5.8.2)':
optionalDependencies: optionalDependencies:
prisma: 6.7.0(typescript@5.8.2) prisma: 6.5.0(typescript@5.8.2)
typescript: 5.8.2 typescript: 5.8.2
'@prisma/config@6.7.0': '@prisma/config@6.5.0':
dependencies: dependencies:
esbuild: 0.25.2 esbuild: 0.25.2
esbuild-register: 3.6.0(esbuild@0.25.2) esbuild-register: 3.6.0(esbuild@0.25.2)
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
'@prisma/debug@6.7.0': {} '@prisma/debug@6.5.0': {}
'@prisma/engines-version@6.7.0-36.3cff47a7f5d65c3ea74883f1d736e41d68ce91ed': {} '@prisma/engines-version@6.5.0-73.173f8d54f8d52e692c7e27e72a88314ec7aeff60': {}
'@prisma/engines@6.7.0': '@prisma/engines@6.5.0':
dependencies: dependencies:
'@prisma/debug': 6.7.0 '@prisma/debug': 6.5.0
'@prisma/engines-version': 6.7.0-36.3cff47a7f5d65c3ea74883f1d736e41d68ce91ed '@prisma/engines-version': 6.5.0-73.173f8d54f8d52e692c7e27e72a88314ec7aeff60
'@prisma/fetch-engine': 6.7.0 '@prisma/fetch-engine': 6.5.0
'@prisma/get-platform': 6.7.0 '@prisma/get-platform': 6.5.0
'@prisma/fetch-engine@6.7.0': '@prisma/fetch-engine@6.5.0':
dependencies: dependencies:
'@prisma/debug': 6.7.0 '@prisma/debug': 6.5.0
'@prisma/engines-version': 6.7.0-36.3cff47a7f5d65c3ea74883f1d736e41d68ce91ed '@prisma/engines-version': 6.5.0-73.173f8d54f8d52e692c7e27e72a88314ec7aeff60
'@prisma/get-platform': 6.7.0 '@prisma/get-platform': 6.5.0
'@prisma/get-platform@6.7.0': '@prisma/get-platform@6.5.0':
dependencies: dependencies:
'@prisma/debug': 6.7.0 '@prisma/debug': 6.5.0
'@swc/counter@0.1.3': {} '@swc/counter@0.1.3': {}
@ -2421,10 +2421,10 @@ snapshots:
picocolors: 1.1.1 picocolors: 1.1.1
source-map-js: 1.2.1 source-map-js: 1.2.1
prisma@6.7.0(typescript@5.8.2): prisma@6.5.0(typescript@5.8.2):
dependencies: dependencies:
'@prisma/config': 6.7.0 '@prisma/config': 6.5.0
'@prisma/engines': 6.7.0 '@prisma/engines': 6.5.0
optionalDependencies: optionalDependencies:
fsevents: 2.3.3 fsevents: 2.3.3
typescript: 5.8.2 typescript: 5.8.2

View File

@ -57,65 +57,65 @@ model MS_SUITABLE {
updated_at DateTime @updatedAt updated_at DateTime @updatedAt
} }
model SD_SURVEY_SALES_BASIC_INFO { model SD_SERVEY_SALES_BASIC_INFO {
ID Int @id @default(autoincrement()) id Int @id @default(autoincrement())
REPRESENTATIVE String @db.VarChar(200) representative String @db.VarChar(200)
STORE String? @db.VarChar(200) store String? @db.VarChar(200)
CONSTRUCTION_POINT String? @db.VarChar(200) construction_point String? @db.VarChar(200)
INVESTIGATION_DATE String? @db.VarChar(10) investigation_date String? @db.VarChar(10)
BUILDING_NAME String? @db.VarChar(200) building_name String? @db.VarChar(200)
CUSTOMER_NAME String? @db.VarChar(200) customer_name String? @db.VarChar(200)
POST_CODE String? @db.VarChar(10) post_code String? @db.VarChar(10)
ADDRESS String? @db.VarChar(200) address String? @db.VarChar(200)
ADDRESS_DETAIL String? @db.VarChar(300) address_detail String? @db.VarChar(300)
SUBMISSION_STATUS Boolean @default(false) submission_status Boolean @default(false)
SUBMISSION_DATE DateTime? @db.Date submission_date DateTime? @db.Date
REG_DT DateTime @default(now()) created_at DateTime @default(now())
UPT_DT DateTime @updatedAt updated_at DateTime @updatedAt
DETAIL_INFO SD_SURVEY_SALES_DETAIL_INFO? detail_info SD_SERVEY_SALES_DETAIL_INFO?
} }
model SD_SURVEY_SALES_DETAIL_INFO { model SD_SERVEY_SALES_DETAIL_INFO {
ID Int @id @default(autoincrement()) id Int @id @default(autoincrement())
CONTRACT_CAPACITY String? @db.VarChar(20) contract_capacity String? @db.VarChar(20)
RETAIL_COMPANY String? @db.VarChar(100) retail_company String? @db.VarChar(100)
SUPPLEMENTARY_FACILITIES String? @db.VarChar(20) supplementary_facilities String? @db.VarChar(20)
SUPPLEMENTARY_FACILITIES_ETC String? @db.VarChar(200) supplementary_facilities_etc String? @db.VarChar(200)
INSTALLATION_SYSTEM String? @db.VarChar(20) installation_system Int?
INSTALLATION_SYSTEM_ETC String? @db.VarChar(200) installation_system_etc String? @db.VarChar(200)
CONSTRUCTION_YEAR String? @db.VarChar(200) construction_year Int?
CONSTRUCTION_YEAR_ETC String? @db.VarChar(200) construction_year_etc String? @db.VarChar(200)
ROOF_MATERIAL String? @db.VarChar(20) roof_material String? @db.VarChar(20)
ROOF_MATERIAL_ETC String? @db.VarChar(200) roof_material_etc String? @db.VarChar(200)
ROOF_SHAPE String? @db.VarChar(20) roof_shape Int?
ROOF_SHAPE_ETC String? @db.VarChar(200) roof_shape_etc String? @db.VarChar(200)
ROOF_SLOPE String? @db.VarChar(5) roof_slope String? @db.VarChar(5)
HOUSE_STRUCTURE String? @db.VarChar(20) house_structure Int?
HOUSE_STRUCTURE_ETC String? @db.VarChar(200) house_structure_etc String? @db.VarChar(200)
RAFTER_MATERIAL String? @db.VarChar(20) rafter_material Int?
RAFTER_MATERIAL_ETC String? @db.VarChar(200) rafter_material_etc String? @db.VarChar(200)
RAFTER_SIZE String? @db.VarChar(20) rafter_size Int?
RAFTER_SIZE_ETC String? @db.VarChar(200) rafter_size_etc String? @db.VarChar(200)
RAFTER_PITCH String? @db.VarChar(20) rafter_pitch Int?
RAFTER_PITCH_ETC String? @db.VarChar(200) rafter_pitch_etc String? @db.VarChar(200)
RAFTER_DIRECTION String? @db.VarChar(20) rafter_direction Int?
OPEN_FIELD_PLATE_KIND String? @db.VarChar(20) open_field_plate_kind Int?
OPEN_FIELD_PLATE_KIND_ETC String? @db.VarChar(200) open_field_plate_kind_etc String? @db.VarChar(200)
OPEN_FIELD_PLATE_THICKNESS String? @db.VarChar(5) open_field_plate_thickness String? @db.VarChar(5)
LEAK_TRACE Boolean? @default(false) leak_trace Boolean? @default(false)
WATERPROOF_MATERIAL String? @db.VarChar(20) waterproof_material Int?
WATERPROOF_MATERIAL_ETC String? @db.VarChar(200) waterproof_material_etc String? @db.VarChar(200)
INSULATION_PRESENCE String? @db.VarChar(20) insulation_presence Int?
INSULATION_PRESENCE_ETC String? @db.VarChar(200) insulation_presence_etc String? @db.VarChar(200)
STRUCTURE_ORDER String? @db.VarChar(20) structure_order Int?
STRUCTURE_ORDER_ETC String? @db.VarChar(200) structure_order_etc String? @db.VarChar(200)
INSTALLATION_AVAILABILITY String? @db.VarChar(20) installation_availability Int?
INSTALLATION_AVAILABILITY_ETC String? @db.VarChar(200) installation_availability_etc String? @db.VarChar(200)
MEMO String? @db.VarChar(500) memo String? @db.VarChar(500)
REG_DT DateTime @default(now()) created_at DateTime @default(now())
UPT_DT DateTime @updatedAt updated_at DateTime @updatedAt
BASIC_INFO_ID Int @unique basic_info_id Int @unique
BASIC_INFO SD_SURVEY_SALES_BASIC_INFO @relation(fields: [BASIC_INFO_ID], references: [ID]) basic_info SD_SERVEY_SALES_BASIC_INFO @relation(fields: [basic_info_id], references: [id])
} }
model BC_COMM_H { model BC_COMM_H {
@ -177,33 +177,3 @@ model BC_COMM_L {
@@id([HEAD_CD, CODE], map: "PK_BC_COMM_L") @@id([HEAD_CD, CODE], map: "PK_BC_COMM_L")
} }
model MS_SUITABLE_ROOF_MATERIAL_GROUP {
ID Int @id @default(autoincrement())
ROOF_MATERIAL_GROUP String @db.VarChar(200)
ROOF_MT_CD String @db.VarChar(200)
REG_DT DateTime @default(now(), map: "DF__MS_SUITAB__creat__4F7CD00D")
UPT_DT DateTime
}
model MS_SUITABLE_DETAIL {
ID Int @id @default(autoincrement())
MAIN_ID Int
TRESTLE_MFPC_CD String? @db.VarChar(200)
TRESTLE_MANUFACTURER_PRODUCT_NAME String? @db.VarChar(200)
MEMO String? @db.VarChar(500)
REG_DT DateTime @default(now(), map: "DF__MS_SUITAB__creat__571DF1D5")
UPT_DT DateTime?
MS_SUITABLE_MAIN MS_SUITABLE_MAIN @relation(fields: [MAIN_ID], references: [ID], onUpdate: NoAction, map: "MS_SUITABLE_DETAIL_MS_SUITABLE_MAIN_FK")
}
model MS_SUITABLE_MAIN {
ID Int @id @default(autoincrement())
PRODUCT_NAME String @db.VarChar(200)
MANU_FT_CD String? @db.VarChar(200)
ROOF_MT_CD String? @db.VarChar(100)
ROOF_SH_CD String? @db.VarChar(200)
REG_DT DateTime @default(now(), map: "DF__MS_SUITAB__creat__5441852A")
UPT_DT DateTime?
MS_SUITABLE_DETAIL MS_SUITABLE_DETAIL[]
}

View File

@ -49,21 +49,6 @@ export async function POST(request: Request) {
session.custCd = result.data.data.custCd session.custCd = result.data.data.custCd
session.builderNo = result.data.data.builderNo session.builderNo = result.data.data.builderNo
session.isLoggedIn = true session.isLoggedIn = true
if (result.data.data.userId === 'T01') {
session.role = 'T01'
} else if (result.data.data.groupId === '60000') {
session.role = 'Admin'
} else if (result.data.data.groupId === '70000' && result.data.data.builderNo === null) {
session.role = 'Admin_Sub'
} else if (result.data.data.groupId === '70000' && result.data.data.builderNo !== null) {
session.role = 'Builder'
} else if (result.data.data.groupId === '90000' && result.data.data.builderNo !== null) {
session.role = 'Partner'
} else {
session.role = 'User'
}
console.log('end session edit!') console.log('end session edit!')
await session.save() await session.save()

View File

@ -3,10 +3,10 @@ import { NextResponse } from 'next/server'
export async function GET(request: Request, context: { params: { id: string } }) { export async function GET(request: Request, context: { params: { id: string } }) {
const { id } = await context.params const { id } = await context.params
// @ts-ignore // @ts-ignore
const survey = await prisma.SD_SURVEY_SALES_BASIC_INFO.findUnique({ const survey = await prisma.SD_SERVEY_SALES_BASIC_INFO.findUnique({
where: { ID: Number(id) }, where: { id: Number(id) },
include: { include: {
DETAIL_INFO: true, detail_info: true,
}, },
}) })
return NextResponse.json(survey) return NextResponse.json(survey)
@ -17,8 +17,8 @@ export async function PUT(request: Request, context: { params: { id: string } })
const body = await request.json() const body = await request.json()
try { try {
// @ts-ignore // @ts-ignore
const survey = await prisma.SD_SURVEY_SALES_BASIC_INFO.update({ const survey = await prisma.SD_SERVEY_SALES_BASIC_INFO.update({
where: { ID: Number(id) }, where: { id: Number(id) },
data: { data: {
...body, ...body,
}, },
@ -37,22 +37,22 @@ export async function DELETE(request: Request, context: { params: { id: string }
//@ts-ignore //@ts-ignore
await prisma.$transaction(async (tx) => { await prisma.$transaction(async (tx) => {
// @ts-ignore // @ts-ignore
const detailData = await tx.SD_SURVEY_SALES_BASIC_INFO.findUnique({ const detailData = await tx.SD_SERVEY_SALES_BASIC_INFO.findUnique({
where: { ID: Number(id) }, where: { id: Number(id) },
select: { select: {
DETAIL_INFO: true, detail_info: true,
}, },
}) })
console.log('detailData:: ', detailData) console.log('detailData:: ', detailData)
if (detailData?.DETAIL_INFO?.ID) { if (detailData?.detail_info?.id) {
// @ts-ignore // @ts-ignore
await tx.SD_SURVEY_SALES_DETAIL_INFO.delete({ await tx.SD_SERVEY_SALES_DETAIL_INFO.delete({
where: { ID: Number(detailData?.DETAIL_INFO?.ID) }, where: { id: Number(detailData?.detail_info?.id) },
}) })
} }
// @ts-ignore // @ts-ignore
await tx.SD_SURVEY_SALES_BASIC_INFO.delete({ await tx.SD_SERVEY_SALES_BASIC_INFO.delete({
where: { ID: Number(id) }, where: { id: Number(id) },
}) })
}) })
return NextResponse.json({ message: 'Survey deleted successfully' }) return NextResponse.json({ message: 'Survey deleted successfully' })
@ -65,46 +65,43 @@ export async function DELETE(request: Request, context: { params: { id: string }
export async function PATCH(request: Request, context: { params: { id: string } }) { export async function PATCH(request: Request, context: { params: { id: string } }) {
const { id } = await context.params const { id } = await context.params
const body = await request.json() const body = await request.json()
if (body.submit) { if (body.submit) {
// @ts-ignore // @ts-ignore
const survey = await prisma.SD_SURVEY_SALES_BASIC_INFO.update({ const survey = await prisma.SD_SERVEY_SALES_BASIC_INFO.update({
where: { ID: Number(id) }, where: { id: Number(id) },
data: { data: {
SUBMISSION_STATUS: true, submission_status: true,
SUBMISSION_DATE: new Date(), submission_date: new Date(),
}, },
}) })
return NextResponse.json({ message: 'Survey confirmed successfully' }) return NextResponse.json({ message: 'Survey confirmed successfully' })
} else { } else {
// @ts-ignore // @ts-ignore
const hasDetails = await prisma.SD_SURVEY_SALES_DETAIL_INFO.findUnique({ const hasDetails = await prisma.SD_SERVEY_SALES_DETAIL_INFO.findUnique({
where: { BASIC_INFO_ID: Number(id) }, where: { basic_info_id: Number(id) },
}) })
console.log('hasDetails:: ', hasDetails)
if (hasDetails) { if (hasDetails) {
//@ts-ignore //@ts-ignore
const result = await prisma.SD_SURVEY_SALES_BASIC_INFO.update({ const result = await prisma.SD_SERVEY_SALES_BASIC_INFO.update({
where: { ID: Number(id) }, where: { id: Number(id) },
data: { data: {
UPT_DT: new Date(), updated_at: new Date(),
DETAIL_INFO: { detail_info: {
update: body.DETAIL_INFO, update: body.detail_info,
}, },
}, },
}) })
return NextResponse.json(result) return NextResponse.json(result)
} else { } else {
// @ts-ignore // @ts-ignore
const survey = await prisma.SD_SURVEY_SALES_BASIC_INFO.update({ const survey = await prisma.SD_SERVEY_SALES_BASIC_INFO.update({
where: { ID: Number(id) }, where: { id: Number(id) },
data: { data: {
DETAIL_INFO: { detail_info: {
create: body.DETAIL_INFO, create: body.detail_info,
}, },
}, },
}) })
console.log(survey)
return NextResponse.json({ message: 'Survey detail created successfully' }) return NextResponse.json({ message: 'Survey detail created successfully' })
} }
} }

View File

@ -1,211 +1,105 @@
import { NextResponse } from 'next/server' import { NextResponse } from 'next/server'
import { prisma } from '@/libs/prisma' import { prisma } from '@/libs/prisma'
// Types
type SearchParams = {
keyword?: string | null
searchOption?: string | null
isMySurvey?: string | null
sort?: string | null
offset?: string | null
memberRole?: string | null
store?: string | null
builderNo?: string | null
}
type WhereCondition = {
AND?: any[]
OR?: any[]
[key: string]: any
}
// Constants
const SEARCH_OPTIONS = [
'BUILDING_NAME',
'REPRESENTATIVE',
'STORE',
'CONSTRUCTION_POINT',
'CUSTOMER_NAME',
'POST_CODE',
'ADDRESS',
'ADDRESS_DETAIL',
] as const
const ITEMS_PER_PAGE = 10
// Helper functions
const createKeywordSearchCondition = (keyword: string, searchOption: string): WhereCondition => {
const where: WhereCondition = {}
if (searchOption === 'all') {
where.OR = []
// ID 검색 조건 추가
if (keyword.match(/^\d+$/) || !isNaN(Number(keyword))) {
where.OR.push({
ID: { equals: Number(keyword) },
})
}
// 다른 필드 검색 조건 추가
where.OR.push(
...SEARCH_OPTIONS.map((field) => ({
[field]: { contains: keyword },
})),
)
} else if (SEARCH_OPTIONS.includes(searchOption as any)) {
where[searchOption] = { contains: keyword }
} else if (searchOption === 'id') {
where.ID = { equals: Number(keyword) }
}
return where
}
const createMemberRoleCondition = (params: SearchParams): WhereCondition => {
const where: WhereCondition = { AND: [] }
switch (params.memberRole) {
// 1차점: 같은 판매점에서 작성된 매물 + 2차점에서 제출받은 매물
case 'Admin':
where.OR = [
{
AND: [
{ STORE: { equals: params.store } },
{ SUBMISSION_STATUS: { equals: false } }
]
},
{
AND: [
{ STORE: { endsWith: params.store } },
{ SUBMISSION_STATUS: { equals: true } }
]
}
]
break
// 2차점: 같은 판매점에서 작성된 매물 + Builder에게 제출받은 매물
case 'Admin_Sub':
where.OR = [
{
AND: [
{ STORE: { equals: params.store } },
{ CONSTRUCTION_POINT: { equals: null } },
{ SUBMISSION_STATUS: { equals: false } }
]
},
{
AND: [
{ STORE: { equals: params.store } },
{ CONSTRUCTION_POINT: { not: null } },
{ SUBMISSION_STATUS: { equals: true } }
]
}
]
break
// 2차점 시공권한: 같은 시공ID에서 작성된 매물
case 'Builder':
where.AND?.push({
CONSTRUCTION_POINT: { equals: params.builderNo },
SUBMISSION_STATUS: { equals: false },
})
break
// 시공점: 같은 시공ID에서 작성된 매물
case 'Partner':
where.AND?.push({
CONSTRUCTION_POINT: { equals: params.builderNo },
SUBMISSION_STATUS: { equals: false },
})
break
// 모든 매물 조회 가능
case 'T01':
case 'User':
break
}
return where
}
// API Routes
export async function POST(request: Request) { export async function POST(request: Request) {
try { const body = await request.json()
const body = await request.json() // @ts-ignore
// @ts-ignore const res = await prisma.SD_SERVEY_SALES_BASIC_INFO.create({
const res = await prisma.SD_SURVEY_SALES_BASIC_INFO.create({ data: body,
data: body, })
}) return NextResponse.json(res)
return NextResponse.json(res)
} catch (error) {
console.error('Error creating survey:', error)
return NextResponse.json({ error: 'Failed to create survey' }, { status: 500 })
}
} }
export async function GET(request: Request) { export async function GET(request: Request) {
const { searchParams } = new URL(request.url)
const keyword = searchParams.get('keyword')
const searchOption = searchParams.get('searchOption')
const isMySurvey = searchParams.get('isMySurvey')
const sort = searchParams.get('sort')
const offset = searchParams.get('offset')
const store = searchParams.get('store')
const construction_point = searchParams.get('construction_point')
const searchOptions = ['building_name', 'representative', 'store', 'construction_point', 'customer_name', 'post_code', 'address', 'address_detail']
try { try {
const { searchParams } = new URL(request.url) const where: any = {}
const params: SearchParams = {
keyword: searchParams.get('keyword'), if (isMySurvey !== null && isMySurvey !== undefined) {
searchOption: searchParams.get('searchOption'), where.representative = isMySurvey
isMySurvey: searchParams.get('isMySurvey'),
sort: searchParams.get('sort'),
offset: searchParams.get('offset'),
memberRole: searchParams.get('memberRole'),
store: searchParams.get('store'),
builderNo: searchParams.get('builderNo'),
} }
const where: WhereCondition = {} if (keyword && keyword.trim() !== '' && searchOption) {
if (searchOption === 'all') {
// 내가 작성한 매물 조건 where.OR = []
if (params.isMySurvey) { if (keyword.match(/^\d+$/) || !isNaN(Number(keyword))) {
where.REPRESENTATIVE = params.isMySurvey where.OR.push({
id: {
equals: Number(keyword),
},
})
}
where.OR.push(
...searchOptions.map((field) => ({
[field]: {
contains: keyword,
},
})),
)
} else if (searchOptions.includes(searchOption)) {
where[searchOption] = {
contains: keyword,
}
} else if (searchOption === 'id') {
where[searchOption] = {
equals: Number(keyword),
}
}
} }
// 키워드 검색 조건 where.AND = []
if (params.keyword && params.searchOption) { if (store) {
Object.assign(where, createKeywordSearchCondition(params.keyword, params.searchOption)) where.AND.push({
store: {
equals: store,
},
})
}
if (construction_point) {
where.AND.push({
construction_point: {
equals: construction_point,
},
})
} }
// 회원 유형 조건 if (offset) {
Object.assign(where, createMemberRoleCondition(params))
// 데이터 조회
if (params.offset) {
// @ts-ignore // @ts-ignore
const res = await prisma.SD_SURVEY_SALES_BASIC_INFO.findMany({ const res = await prisma.SD_SERVEY_SALES_BASIC_INFO.findMany({
where, where,
orderBy: params.sort === 'created' ? { REG_DT: 'desc' } : { UPT_DT: 'desc' }, orderBy: sort === 'created' ? { created_at: 'desc' } : { updated_at: 'desc' },
skip: Number(params.offset), skip: Number(offset),
take: ITEMS_PER_PAGE, take: 10,
}) })
return NextResponse.json(res) return NextResponse.json(res)
} else {
// @ts-ignore
const count = await prisma.SD_SERVEY_SALES_BASIC_INFO.count({
where,
})
return NextResponse.json(count)
} }
// 전체 개수 조회
// @ts-ignore
const count = await prisma.SD_SURVEY_SALES_BASIC_INFO.count({ where })
return NextResponse.json(count)
} catch (error) { } catch (error) {
console.error('Error fetching surveys:', error) console.error(error)
return NextResponse.json({ error: 'Failed to fetch surveys' }, { status: 500 }) throw error
} }
} }
export async function PUT(request: Request) { export async function PUT(request: Request) {
try { const body = await request.json()
const body = await request.json() const detailInfo = { ...body.detail_info, basic_info_id: body.id }
const detailInfo = { ...body.detail_info, BASIC_INFO_ID: body.id } // @ts-ignore
// @ts-ignore const res = await prisma.SD_SERVEY_SALES_DETAIL_INFO.create({
const res = await prisma.SD_SURVEY_SALES_DETAIL_INFO.create({ data: detailInfo,
data: detailInfo, })
}) return NextResponse.json({ message: 'Survey sales updated successfully' })
return NextResponse.json({ message: 'Survey sales updated successfully' })
} catch (error) {
console.error('Error updating survey:', error)
return NextResponse.json({ error: 'Failed to update survey' }, { status: 500 })
}
} }

View File

@ -28,7 +28,7 @@ export default async function RootLayout({ children, header, footer, floatBtn }:
const cookieStore = await cookies() const cookieStore = await cookies()
const session = await getIronSession<SessionData>(cookieStore, sessionOptions) const session = await getIronSession<SessionData>(cookieStore, sessionOptions)
const sessionData = session.isLoggedIn ? JSON.stringify(session) : '' const sessionData = JSON.stringify(session)
return ( return (
<ReactQueryProviders> <ReactQueryProviders>

View File

@ -20,7 +20,7 @@ export default function DataTable() {
const { setBasicInfoSelected, setRoofInfoSelected } = useSurveySaleTabState() const { setBasicInfoSelected, setRoofInfoSelected } = useSurveySaleTabState()
useEffect(() => { useEffect(() => {
if (surveyDetail?.REPRESENTATIVE && surveyDetail?.STORE && surveyDetail?.CONSTRUCTION_POINT) { if (surveyDetail?.representative && surveyDetail?.store && surveyDetail?.construction_point) {
setIsTemporary(false) setIsTemporary(false)
} }
if (tab === 'roof-info') { if (tab === 'roof-info') {
@ -50,24 +50,24 @@ export default function DataTable() {
<span className="text-red-500"></span> <span className="text-red-500"></span>
</td> </td>
) : ( ) : (
<td>{surveyDetail?.ID}</td> <td>{surveyDetail?.id}</td>
)} )}
</tr> </tr>
<tr> <tr>
<th></th> <th></th>
<td>{surveyDetail?.REG_DT ? new Date(surveyDetail?.REG_DT).toLocaleString() : ''}</td> <td>{surveyDetail?.created_at ? new Date(surveyDetail?.created_at).toLocaleString() : ''}</td>
</tr> </tr>
<tr> <tr>
<th></th> <th></th>
<td>{surveyDetail?.UPT_DT ? new Date(surveyDetail?.UPT_DT).toLocaleString() : ''}</td> <td>{surveyDetail?.updated_at ? new Date(surveyDetail?.updated_at).toLocaleString() : ''}</td>
</tr> </tr>
<tr> <tr>
<th></th> <th></th>
<td> <td>
{surveyDetail?.SUBMISSION_STATUS && surveyDetail?.SUBMISSION_DATE ? ( {surveyDetail?.submission_status && surveyDetail?.submission_date ? (
<> <>
{/* TODO: 제출한 판매점 ID 추가 필요 */} {/* TODO: 제출한 판매점 ID 추가 필요 */}
<div>{new Date(surveyDetail.SUBMISSION_DATE).toLocaleString()}</div> <div>{new Date(surveyDetail.submission_date).toLocaleString()}</div>
<div> ID...</div> <div> ID...</div>
</> </>
) : ( ) : (

View File

@ -8,20 +8,20 @@ export default function DetailButton({ isTemporary, surveyId, representative }:
const router = useRouter() const router = useRouter()
const { session } = useSessionStore() const { session } = useSessionStore()
const { submitSurvey, deleteSurvey } = useServey(surveyId) const { submitSurvey, deleteSurvey } = useServey(surveyId)
const [userId, setUserId] = useState('') const [userNm, setUserNm] = useState('')
useEffect(() => { useEffect(() => {
if (session?.isLoggedIn) { if (session?.isLoggedIn) {
setUserId(session?.userId ?? '') setUserNm(session?.userNm ?? '')
} }
}, [session, setUserId]) }, [session, setUserNm])
const handleSubmit = async () => { const handleSubmit = async () => {
if (isTemporary) { if (isTemporary) {
alert('一時保存されたデータは提出できません。') alert('一時保存されたデータは提出できません。')
return return
} }
if (userId === representative) { if (userNm === representative) {
if (confirm('提出しますか??')) { if (confirm('提出しますか??')) {
if (surveyId) { if (surveyId) {
// TODO: 제출 페이지 추가 // TODO: 제출 페이지 추가
@ -34,7 +34,7 @@ export default function DetailButton({ isTemporary, surveyId, representative }:
} }
} }
const handleUpdate = () => { const handleUpdate = () => {
if (userId === representative) { if (userNm === representative) {
router.push(`/survey-sale/basic-info?id=${surveyId}&isTemp=${isTemporary}`) router.push(`/survey-sale/basic-info?id=${surveyId}&isTemp=${isTemporary}`)
} else { } else {
alert('担当者のみ修正可能です。') alert('担当者のみ修正可能です。')
@ -43,7 +43,7 @@ export default function DetailButton({ isTemporary, surveyId, representative }:
const handleDelete = async () => { const handleDelete = async () => {
if (confirm('削除しますか?')) { if (confirm('削除しますか?')) {
if (surveyId) { if (surveyId) {
if (userId === representative) { if (userNm === representative) {
await deleteSurvey() await deleteSurvey()
router.push('/survey-sale') router.push('/survey-sale')
} else { } else {

View File

@ -14,7 +14,7 @@ export default function DetailForm({
const [isTemporary, setIsTemporary] = useState(true) const [isTemporary, setIsTemporary] = useState(true)
useEffect(() => { useEffect(() => {
if (surveyDetail?.REPRESENTATIVE && surveyDetail?.STORE && surveyDetail?.CONSTRUCTION_POINT) { if (surveyDetail?.representative && surveyDetail?.store && surveyDetail?.construction_point) {
setIsTemporary(false) setIsTemporary(false)
} }
}, [surveyDetail]) }, [surveyDetail])
@ -28,15 +28,15 @@ export default function DetailForm({
<div className="data-form-wrap"> <div className="data-form-wrap">
<div className="data-input-form-bx"> <div className="data-input-form-bx">
<div className="data-input-form-tit"></div> <div className="data-input-form-tit"></div>
<input type="text" className="input-frame" disabled defaultValue={surveyDetail?.REPRESENTATIVE} /> <input type="text" className="input-frame" disabled defaultValue={surveyDetail?.representative} />
</div> </div>
<div className="data-input-form-bx"> <div className="data-input-form-bx">
<div className="data-input-form-tit"></div> <div className="data-input-form-tit"></div>
<input type="text" className="input-frame" disabled defaultValue={surveyDetail?.STORE ?? ''} /> <input type="text" className="input-frame" disabled defaultValue={surveyDetail?.store ?? ''} />
</div> </div>
<div className="data-input-form-bx"> <div className="data-input-form-bx">
<div className="data-input-form-tit"></div> <div className="data-input-form-tit"></div>
<input type="text" className="input-frame" disabled defaultValue={surveyDetail?.CONSTRUCTION_POINT ?? ''} /> <input type="text" className="input-frame" disabled defaultValue={surveyDetail?.construction_point ?? ''} />
</div> </div>
</div> </div>
</div> </div>
@ -45,18 +45,18 @@ export default function DetailForm({
<div className="data-form-wrap"> <div className="data-form-wrap">
<div className="data-input-form-bx"> <div className="data-input-form-bx">
<div className="data-input-form-tit">調</div> <div className="data-input-form-tit">調</div>
<input type="text" className="input-frame" disabled defaultValue={surveyDetail?.INVESTIGATION_DATE ?? ''} /> <input type="text" className="input-frame" disabled defaultValue={surveyDetail?.investigation_date ?? ''} />
</div> </div>
<div className="data-input-form-bx"> <div className="data-input-form-bx">
<div className="data-input-form-tit"></div> <div className="data-input-form-tit"></div>
<input type="text" className="input-frame" disabled defaultValue={surveyDetail?.BUILDING_NAME ?? ''} /> <input type="text" className="input-frame" disabled defaultValue={surveyDetail?.building_name ?? ''} />
</div> </div>
<div className="data-input-form-bx"> <div className="data-input-form-bx">
<div className="data-input-form-tit"></div> <div className="data-input-form-tit"></div>
<input type="text" className="input-frame" disabled defaultValue={surveyDetail?.CUSTOMER_NAME ?? ''} /> <input type="text" className="input-frame" disabled defaultValue={surveyDetail?.customer_name ?? ''} />
</div> </div>
</div> </div>
<DetailButton isTemporary={isTemporary} surveyId={Number(surveyDetail?.ID)} representative={surveyDetail?.REPRESENTATIVE ?? ''} /> <DetailButton isTemporary={isTemporary} surveyId={Number(surveyDetail?.id)} representative={surveyDetail?.representative ?? ''} />
</div> </div>
</> </>
) )

View File

@ -30,12 +30,12 @@ export default function RoofDetailForm({
<div className="data-input-form-bx"> <div className="data-input-form-bx">
{/* 전기 계약 용량 */} {/* 전기 계약 용량 */}
<div className="data-input-form-tit"></div> <div className="data-input-form-tit"></div>
<input className="input-frame" type="text" placeholder="-" readOnly value={surveyDetail?.DETAIL_INFO?.CONTRACT_CAPACITY ?? ''} /> <input className="input-frame" type="text" placeholder="-" readOnly value={surveyDetail?.detail_info?.contract_capacity ?? ''} />
</div> </div>
{/* 전기 소매 회사 */} {/* 전기 소매 회사 */}
<div className="data-input-form-bx"> <div className="data-input-form-bx">
<div className="data-input-form-tit"></div> <div className="data-input-form-tit"></div>
<input className="input-frame" type="text" placeholder="-" readOnly value={surveyDetail?.DETAIL_INFO?.RETAIL_COMPANY ?? ''} /> <input className="input-frame" type="text" placeholder="-" readOnly value={surveyDetail?.detail_info?.retail_company ?? ''} />
</div> </div>
{/* 전기 부대 설비 */} {/* 전기 부대 설비 */}
<div className="data-input-form-bx"> <div className="data-input-form-bx">
@ -46,7 +46,7 @@ export default function RoofDetailForm({
<input <input
type="checkbox" type="checkbox"
id={`${item.id}`} id={`${item.id}`}
checked={makeNumArr(surveyDetail?.DETAIL_INFO?.SUPPLEMENTARY_FACILITIES ?? '').includes(String(item.id))} checked={makeNumArr(surveyDetail?.detail_info?.supplementary_facilities ?? '').includes(String(item.id))}
readOnly readOnly
/> />
<label htmlFor={`${item.id}`}>{item.name}</label> <label htmlFor={`${item.id}`}>{item.name}</label>
@ -56,7 +56,7 @@ export default function RoofDetailForm({
<input <input
type="checkbox" type="checkbox"
id={`supplementary_facilities_etc`} id={`supplementary_facilities_etc`}
checked={surveyDetail?.DETAIL_INFO?.SUPPLEMENTARY_FACILITIES_ETC !== null} checked={surveyDetail?.detail_info?.supplementary_facilities_etc !== null}
readOnly readOnly
/> />
<label htmlFor={`supplementary_facilities_etc`}> ()</label> <label htmlFor={`supplementary_facilities_etc`}> ()</label>
@ -68,19 +68,19 @@ export default function RoofDetailForm({
className="input-frame" className="input-frame"
placeholder="-" placeholder="-"
readOnly readOnly
value={surveyDetail?.DETAIL_INFO?.SUPPLEMENTARY_FACILITIES_ETC ?? ''} value={surveyDetail?.detail_info?.supplementary_facilities_etc ?? ''}
/> />
</div> </div>
</div> </div>
{/* 설치 희망 시스템 */} {/* 설치 희망 시스템 */}
<div className="data-input-form-bx"> <div className="data-input-form-bx">
<div className="data-input-form-tit"></div> <div className="data-input-form-tit"></div>
<SelectedBox column="INSTALLATION_SYSTEM" detailInfoData={surveyDetail?.DETAIL_INFO ?? null} /> <SelectedBox column="installation_system" detailInfoData={surveyDetail?.detail_info ?? null} />
</div> </div>
{/* 건축 연수 */} {/* 건축 연수 */}
<div className="data-input-form-bx"> <div className="data-input-form-bx">
<div className="data-input-form-tit"></div> <div className="data-input-form-tit"></div>
<SelectedBox column="CONSTRUCTION_YEAR" detailInfoData={surveyDetail?.DETAIL_INFO ?? null} /> <SelectedBox column="construction_year" detailInfoData={surveyDetail?.detail_info ?? null} />
</div> </div>
{/* 지붕재 */} {/* 지붕재 */}
<div className="data-input-form-bx"> <div className="data-input-form-bx">
@ -91,63 +91,63 @@ export default function RoofDetailForm({
<input <input
type="checkbox" type="checkbox"
id={`${item.id}`} id={`${item.id}`}
checked={makeNumArr(surveyDetail?.DETAIL_INFO?.ROOF_MATERIAL ?? '').includes(String(item.id))} checked={makeNumArr(surveyDetail?.detail_info?.roof_material ?? '').includes(String(item.id))}
readOnly readOnly
/> />
<label htmlFor={`${item.id}`}>{item.name}</label> <label htmlFor={`${item.id}`}>{item.name}</label>
</div> </div>
))} ))}
<div className="check-form-box"> <div className="check-form-box">
<input type="checkbox" id={`roof_material_etc`} checked={surveyDetail?.DETAIL_INFO?.ROOF_MATERIAL_ETC !== null} readOnly /> <input type="checkbox" id={`roof_material_etc`} checked={surveyDetail?.detail_info?.roof_material_etc !== null} readOnly />
<label htmlFor={`roof_material_etc`}> ()</label> <label htmlFor={`roof_material_etc`}> ()</label>
</div> </div>
</div> </div>
<div className="data-input"> <div className="data-input">
<input type="text" className="input-frame" placeholder="-" readOnly value={surveyDetail?.DETAIL_INFO?.ROOF_MATERIAL_ETC ?? ''} /> <input type="text" className="input-frame" placeholder="-" readOnly value={surveyDetail?.detail_info?.roof_material_etc ?? ''} />
</div> </div>
</div> </div>
{/* 지붕 모양 */} {/* 지붕 모양 */}
<div className="data-input-form-bx"> <div className="data-input-form-bx">
<div className="data-input-form-tit"></div> <div className="data-input-form-tit"></div>
<SelectedBox column="ROOF_SHAPE" detailInfoData={surveyDetail?.DETAIL_INFO ?? null} /> <SelectedBox column="roof_shape" detailInfoData={surveyDetail?.detail_info ?? null} />
</div> </div>
{/* 지붕 경사도 */} {/* 지붕 경사도 */}
<div className="data-input-form-bx"> <div className="data-input-form-bx">
<div className="data-input-form-tit"></div> <div className="data-input-form-tit"></div>
<div className="data-input flex"> <div className="data-input flex">
<input className="input-frame" type="text" placeholder="-" readOnly value={surveyDetail?.DETAIL_INFO?.ROOF_SLOPE ?? ''} /> <input className="input-frame" type="text" placeholder="-" readOnly value={surveyDetail?.detail_info?.roof_slope ?? ''} />
<span></span> <span></span>
</div> </div>
</div> </div>
{/* 주택 구조 */} {/* 주택 구조 */}
<div className="data-input-form-bx"> <div className="data-input-form-bx">
<div className="data-input-form-tit"></div> <div className="data-input-form-tit"></div>
<RadioSelected column="HOUSE_STRUCTURE" detailInfoData={surveyDetail?.DETAIL_INFO ?? null} /> <RadioSelected column="house_structure" detailInfoData={surveyDetail?.detail_info ?? null} />
</div> </div>
{/* 서까래 재질 */} {/* 서까래 재질 */}
<div className="data-input-form-bx"> <div className="data-input-form-bx">
<div className="data-input-form-tit"></div> <div className="data-input-form-tit"></div>
<RadioSelected column="RAFTER_MATERIAL" detailInfoData={surveyDetail?.DETAIL_INFO ?? null} /> <RadioSelected column="rafter_material" detailInfoData={surveyDetail?.detail_info ?? null} />
</div> </div>
{/* 서까래 크기 */} {/* 서까래 크기 */}
<div className="data-input-form-bx"> <div className="data-input-form-bx">
<div className="data-input-form-tit"></div> <div className="data-input-form-tit"></div>
<SelectedBox column="RAFTER_SIZE" detailInfoData={surveyDetail?.DETAIL_INFO ?? null} /> <SelectedBox column="rafter_size" detailInfoData={surveyDetail?.detail_info ?? null} />
</div> </div>
{/* 서까래 피치 */} {/* 서까래 피치 */}
<div className="data-input-form-bx"> <div className="data-input-form-bx">
<div className="data-input-form-tit"></div> <div className="data-input-form-tit"></div>
<SelectedBox column="RAFTER_PITCH" detailInfoData={surveyDetail?.DETAIL_INFO ?? null} /> <SelectedBox column="rafter_pitch" detailInfoData={surveyDetail?.detail_info ?? null} />
</div> </div>
{/* 서까래 방향 */} {/* 서까래 방향 */}
<div className="data-input-form-bx"> <div className="data-input-form-bx">
<div className="data-input-form-tit"></div> <div className="data-input-form-tit"></div>
<RadioSelected column="RAFTER_DIRECTION" detailInfoData={surveyDetail?.DETAIL_INFO ?? null} /> <RadioSelected column="rafter_direction" detailInfoData={surveyDetail?.detail_info ?? null} />
</div> </div>
{/* 노지판 종류 */} {/* 노지판 종류 */}
<div className="data-input-form-bx"> <div className="data-input-form-bx">
<div className="data-input-form-tit"></div> <div className="data-input-form-tit"></div>
<SelectedBox column="OPEN_FIELD_PLATE_KIND" detailInfoData={surveyDetail?.DETAIL_INFO ?? null} /> <SelectedBox column="open_field_plate_kind" detailInfoData={surveyDetail?.detail_info ?? null} />
</div> </div>
{/* 노지판 두께 */} {/* 노지판 두께 */}
<div className="data-input-form-bx"> <div className="data-input-form-bx">
@ -158,7 +158,7 @@ export default function RoofDetailForm({
type="text" type="text"
placeholder="-" placeholder="-"
readOnly readOnly
value={surveyDetail?.DETAIL_INFO?.OPEN_FIELD_PLATE_THICKNESS ?? ''} value={surveyDetail?.detail_info?.open_field_plate_thickness ?? ''}
/> />
<span>mm</span> <span>mm</span>
</div> </div>
@ -166,37 +166,37 @@ export default function RoofDetailForm({
{/* 누수 흔적 */} {/* 누수 흔적 */}
<div className="data-input-form-bx"> <div className="data-input-form-bx">
<div className="data-input-form-tit"></div> <div className="data-input-form-tit"></div>
<RadioSelected column="LEAK_TRACE" detailInfoData={surveyDetail?.DETAIL_INFO ?? null} /> <RadioSelected column="leak_trace" detailInfoData={surveyDetail?.detail_info ?? null} />
</div> </div>
{/* 방수재 종류 */} {/* 방수재 종류 */}
<div className="data-input-form-bx"> <div className="data-input-form-bx">
<div className="data-input-form-tit"></div> <div className="data-input-form-tit"></div>
<RadioSelected column="WATERPROOF_MATERIAL" detailInfoData={surveyDetail?.DETAIL_INFO ?? null} /> <RadioSelected column="waterproof_material" detailInfoData={surveyDetail?.detail_info ?? null} />
</div> </div>
{/* 단열재 유무 */} {/* 단열재 유무 */}
<div className="data-input-form-bx"> <div className="data-input-form-bx">
<div className="data-input-form-tit"></div> <div className="data-input-form-tit"></div>
<RadioSelected column="INSULATION_PRESENCE" detailInfoData={surveyDetail?.DETAIL_INFO ?? null} /> <RadioSelected column="insulation_presence" detailInfoData={surveyDetail?.detail_info ?? null} />
</div> </div>
{/* 구조 순서 */} {/* 구조 순서 */}
<div className="data-input-form-bx"> <div className="data-input-form-bx">
<div className="data-input-form-tit"></div> <div className="data-input-form-tit"></div>
<SelectedBox column="STRUCTURE_ORDER" detailInfoData={surveyDetail?.DETAIL_INFO ?? null} /> <SelectedBox column="structure_order" detailInfoData={surveyDetail?.detail_info ?? null} />
</div> </div>
{/* 설치 가능 여부 */} {/* 설치 가능 여부 */}
<div className="data-input-form-bx"> <div className="data-input-form-bx">
<div className="data-input-form-tit"></div> <div className="data-input-form-tit"></div>
<SelectedBox column="INSTALLATION_AVAILABILITY" detailInfoData={surveyDetail?.DETAIL_INFO ?? null} /> <SelectedBox column="installation_availability" detailInfoData={surveyDetail?.detail_info ?? null} />
</div> </div>
{/* 메모 */} {/* 메모 */}
<div className="data-input-form-bx"> <div className="data-input-form-bx">
<div className="data-input-form-tit"></div> <div className="data-input-form-tit"></div>
<div className="data-input"> <div className="data-input">
<textarea className="textarea-form" placeholder="-" readOnly value={surveyDetail?.DETAIL_INFO?.MEMO ?? ''} /> <textarea className="textarea-form" placeholder="-" readOnly value={surveyDetail?.detail_info?.memo ?? ''} />
</div> </div>
</div> </div>
</div> </div>
<DetailButton isTemporary={false} surveyId={Number(surveyDetail?.ID)} representative={surveyDetail?.REPRESENTATIVE ?? ''} /> <DetailButton isTemporary={false} surveyId={Number(surveyDetail?.id)} representative={surveyDetail?.representative ?? ''} />
</div> </div>
</> </>
) )
@ -204,14 +204,16 @@ export default function RoofDetailForm({
const SelectedBox = ({ column, detailInfoData }: { column: string; detailInfoData: SurveyDetailInfo | null }) => { const SelectedBox = ({ column, detailInfoData }: { column: string; detailInfoData: SurveyDetailInfo | null }) => {
const selectedId = detailInfoData?.[column as keyof SurveyDetailInfo] const selectedId = detailInfoData?.[column as keyof SurveyDetailInfo]
const etcValue = detailInfoData?.[`${column}_ETC` as keyof SurveyDetailInfo] const etcValue = detailInfoData?.[`${column}_etc` as keyof SurveyDetailInfo]
return ( return (
<> <>
<select className="select-form mb10" name={column} id={column} disabled value={selectedId ? 'selected' : etcValue ? 'etc' : ''}> <select className="select-form mb10" name={column} id={column} disabled value={selectedId ? 'selected' : etcValue ? 'etc' : ''}>
<option value="">-</option> <option value="">-</option>
<option value="etc"> ()</option> <option value="etc"> ()</option>
<option value="selected">{selectBoxOptions[column as keyof typeof selectBoxOptions][Number(selectedId)]?.name}</option> <option value="selected">
{typeof selectedId === 'number' ? selectBoxOptions[column as keyof typeof selectBoxOptions][selectedId]?.name : ''}
</option>
</select> </select>
{etcValue && <input type="text" className="input-frame" readOnly value={etcValue.toString()} />} {etcValue && <input type="text" className="input-frame" readOnly value={etcValue.toString()} />}
</> </>
@ -220,30 +222,28 @@ const SelectedBox = ({ column, detailInfoData }: { column: string; detailInfoDat
const RadioSelected = ({ column, detailInfoData }: { column: string; detailInfoData: SurveyDetailInfo | null }) => { const RadioSelected = ({ column, detailInfoData }: { column: string; detailInfoData: SurveyDetailInfo | null }) => {
let selectedId = detailInfoData?.[column as keyof SurveyDetailInfo] let selectedId = detailInfoData?.[column as keyof SurveyDetailInfo]
if (column === 'LEAK_TRACE') { if (column === 'leak_trace') {
selectedId = Number(selectedId) selectedId = Number(selectedId)
if (!selectedId) selectedId = 2
} }
let etcValue = null let etcValue = null
if (column !== 'RAFTER_DIRECTION') { if (column !== 'rafter_direction') {
etcValue = detailInfoData?.[`${column}_ETC` as keyof SurveyDetailInfo] etcValue = detailInfoData?.[`${column}_etc` as keyof SurveyDetailInfo]
} }
const etcChecked = etcValue !== null && etcValue !== undefined && etcValue !== '' const etcChecked = etcValue !== null && etcValue !== undefined && etcValue !== ''
console.log('column: selectedId', column, selectedId)
return ( return (
<> <>
{radioEtcData[column as keyof typeof radioEtcData].map((item) => ( {radioEtcData[column as keyof typeof radioEtcData].map((item) => (
<div className="radio-form-box mb10" key={item.id}> <div className="radio-form-box mb10" key={item.id}>
<input type="radio" name={column} id={`${item.id}`} disabled checked={Number(selectedId) === item.id} /> <input type="radio" name={column} id={`${item.id}`} disabled checked={selectedId === item.id} />
<label htmlFor={`${item.id}`}>{item.label}</label> <label htmlFor={`${item.id}`}>{item.label}</label>
</div> </div>
))} ))}
{column !== 'RAFTER_DIRECTION' && column !== 'LEAK_TRACE' && column !== 'INSULATION_PRESENCE' && ( {column !== 'rafter_direction' && column !== 'leak_trace' && column !== 'insulation_presence' && (
<div className="radio-form-box mb10"> <div className="radio-form-box mb10">
<input type="radio" name={column} id={`${column}_ETC`} value="etc" disabled checked={etcChecked} /> <input type="radio" name={column} id={`${column}_etc`} value="etc" disabled checked={etcChecked} />
<label htmlFor={`${column}_ETC`}> ()</label> <label htmlFor={`${column}_etc`}> ()</label>
</div> </div>
)} )}
{etcChecked && ( {etcChecked && (

View File

@ -11,20 +11,20 @@ import { useSessionStore } from '@/store/session'
import { useUserType } from '@/hooks/useUserType' import { useUserType } from '@/hooks/useUserType'
const defaultBasicInfoForm: SurveyBasicRequest = { const defaultBasicInfoForm: SurveyBasicRequest = {
REPRESENTATIVE: '', representative: '',
STORE: null, store: null,
CONSTRUCTION_POINT: null, construction_point: null,
INVESTIGATION_DATE: new Date().toLocaleDateString('en-CA'), investigation_date: new Date().toLocaleDateString('en-CA'),
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,
} }
const REQUIRED_FIELDS: (keyof SurveyBasicRequest)[] = ['REPRESENTATIVE', 'BUILDING_NAME', 'CUSTOMER_NAME'] const REQUIRED_FIELDS: (keyof SurveyBasicRequest)[] = ['representative', 'building_name', 'customer_name']
export default function BasicForm() { export default function BasicForm() {
const searchParams = useSearchParams() const searchParams = useSearchParams()
@ -37,34 +37,32 @@ export default function BasicForm() {
const [basicInfoData, setBasicInfoData] = useState<SurveyBasicRequest>(defaultBasicInfoForm) const [basicInfoData, setBasicInfoData] = useState<SurveyBasicRequest>(defaultBasicInfoForm)
const { addressData } = useAddressStore() const { addressData } = useAddressStore()
const { memberRole, store, builderNo } = useUserType() const { userType, store, construction_point } = useUserType()
const { session } = useSessionStore() const { session } = useSessionStore()
const popupController = usePopupController() const popupController = usePopupController()
useEffect(() => { useEffect(() => {
if (surveyDetail) { if (surveyDetail) {
const { ID, UPT_DT, REG_DT, DETAIL_INFO, ...rest } = surveyDetail const { id, updated_at, created_at, detail_info, ...rest } = surveyDetail
setBasicInfoData(rest) setBasicInfoData(rest)
} }
if (addressData) { if (addressData) {
setBasicInfoData({ setBasicInfoData({
...basicInfoData, ...basicInfoData,
POST_CODE: addressData.post_code, post_code: addressData.post_code,
ADDRESS: addressData.address, address: addressData.address,
ADDRESS_DETAIL: addressData.address_detail, address_detail: addressData.address_detail,
}) })
} }
if (session?.isLoggedIn) { if (session?.isLoggedIn) {
setBasicInfoData((prev) => ({ setBasicInfoData((prev) => ({
...prev, ...prev,
REPRESENTATIVE: session?.userId ?? '', representative: session?.userNm ?? '',
STORE: store ?? '',
CONSTRUCTION_POINT: builderNo ?? '',
})) }))
} }
setBasicInfoSelected() setBasicInfoSelected()
}, [surveyDetail, addressData, session?.isLoggedIn, session?.userNm, store, builderNo]) }, [surveyDetail, addressData, session?.isLoggedIn, session?.userNm])
const focusInput = (input: keyof SurveyBasicRequest) => { const focusInput = (input: keyof SurveyBasicRequest) => {
const inputElement = document.getElementById(input) const inputElement = document.getElementById(input)
@ -119,11 +117,11 @@ export default function BasicForm() {
type="text" type="text"
className="input-frame" className="input-frame"
id="representative" id="representative"
value={session?.userId ? session?.userId : basicInfoData.REPRESENTATIVE} value={session?.userNm ? session?.userNm : basicInfoData.representative}
onChange={(e) => handleChange('REPRESENTATIVE', e.target.value)} onChange={(e) => handleChange('representative', e.target.value)}
/> />
</div> </div>
{(memberRole === 'Builder' || memberRole?.includes('Admin')) && ( {(userType === 'order' || userType?.includes('musubi')) && (
<> <>
<div className="data-input-form-bx"> <div className="data-input-form-bx">
<div className="data-input-form-tit"></div> <div className="data-input-form-tit"></div>
@ -131,21 +129,21 @@ export default function BasicForm() {
type="text" type="text"
className="input-frame" className="input-frame"
id="store" id="store"
value={store ? store : basicInfoData.STORE ?? ''} value={store ? store : basicInfoData.store ?? ''}
onChange={(e) => handleChange('STORE', e.target.value)} onChange={(e) => handleChange('store', e.target.value)}
/> />
</div> </div>
</> </>
)} )}
{(memberRole === 'Partner' || memberRole === 'Builder') && ( {(userType === 'partner' || userType === 'musubi_con') && (
<div className="data-input-form-bx"> <div className="data-input-form-bx">
<div className="data-input-form-tit"></div> <div className="data-input-form-tit"></div>
<input <input
type="text" type="text"
className="input-frame" className="input-frame"
id="construction_point" id="construction_point"
value={builderNo ? builderNo : basicInfoData.CONSTRUCTION_POINT ?? ''} value={construction_point ? construction_point : basicInfoData.construction_point ?? ''}
onChange={(e) => handleChange('CONSTRUCTION_POINT', e.target.value)} onChange={(e) => handleChange('construction_point', e.target.value)}
/> />
</div> </div>
)} )}
@ -163,9 +161,9 @@ export default function BasicForm() {
<input <input
type="date" type="date"
className="date-frame" className="date-frame"
id="INVESTIGATION_DATE" id="investigation_date"
value={basicInfoData.INVESTIGATION_DATE ?? ''} value={basicInfoData.investigation_date ?? ''}
onChange={(e) => handleChange('INVESTIGATION_DATE', e.target.value)} onChange={(e) => handleChange('investigation_date', e.target.value)}
/> />
</div> </div>
</div> </div>
@ -174,9 +172,9 @@ export default function BasicForm() {
<input <input
type="text" type="text"
className="input-frame" className="input-frame"
id="BUILDING_NAME" id="building_name"
value={basicInfoData.BUILDING_NAME ?? ''} value={basicInfoData.building_name ?? ''}
onChange={(e) => handleChange('BUILDING_NAME', e.target.value)} onChange={(e) => handleChange('building_name', e.target.value)}
/> />
</div> </div>
<div className="data-input-form-bx"> <div className="data-input-form-bx">
@ -184,24 +182,24 @@ export default function BasicForm() {
<input <input
type="text" type="text"
className="input-frame" className="input-frame"
id="CUSTOMER_NAME" id="customer_name"
value={basicInfoData.CUSTOMER_NAME ?? ''} value={basicInfoData.customer_name ?? ''}
onChange={(e) => handleChange('CUSTOMER_NAME', e.target.value)} onChange={(e) => handleChange('customer_name', e.target.value)}
/> />
</div> </div>
<div className="data-input-form-bx"> <div className="data-input-form-bx">
<div className="data-input-form-tit"></div> <div className="data-input-form-tit"></div>
<div className="form-flex"> <div className="form-flex">
<div className="form-bx"> <div className="form-bx">
<input type="text" className="input-frame" id="POST_CODE" value={basicInfoData.POST_CODE ?? ''} readOnly /> <input type="text" className="input-frame" id="post_code" value={basicInfoData.post_code ?? ''} readOnly />
</div> </div>
<div className="form-bx"> <div className="form-bx">
<select <select
className="select-form" className="select-form"
name="address" name="address"
id="ADDRESS" id="address"
value={basicInfoData.ADDRESS ?? ''} value={basicInfoData.address ?? ''}
onChange={(e) => handleChange('ADDRESS', e.target.value)} onChange={(e) => handleChange('address', e.target.value)}
> >
<option value=""></option> <option value=""></option>
</select> </select>
@ -218,9 +216,9 @@ export default function BasicForm() {
<input <input
type="text" type="text"
className="input-frame" className="input-frame"
id="ADDRESS_DETAIL" id="address_detail"
value={basicInfoData.ADDRESS_DETAIL ?? ''} value={basicInfoData.address_detail ?? ''}
onChange={(e) => handleChange('ADDRESS_DETAIL', e.target.value)} onChange={(e) => handleChange('address_detail', e.target.value)}
/> />
</div> </div>
</div> </div>

View File

@ -24,7 +24,7 @@ export default function MultiCheckbox({
setDetailInfoData: (data: any) => void setDetailInfoData: (data: any) => void
detailInfoData: SurveyDetailRequest detailInfoData: SurveyDetailRequest
}) { }) {
const selectList = column === 'SUPPLEMENTARY_FACILITIES' ? supplementary_facilities : roof_material const selectList = column === 'supplementary_facilities' ? supplementary_facilities : roof_material
const [isOtherChecked, setIsOtherChecked] = useState(false) const [isOtherChecked, setIsOtherChecked] = useState(false)
const [otherValue, setOtherValue] = useState('') const [otherValue, setOtherValue] = useState('')
@ -37,9 +37,9 @@ export default function MultiCheckbox({
} }
useEffect(() => { useEffect(() => {
if (detailInfoData[`${column}_ETC` as keyof SurveyDetailRequest]) { if (detailInfoData[`${column}_etc` as keyof SurveyDetailRequest]) {
setIsOtherChecked(true) setIsOtherChecked(true)
setOtherValue(detailInfoData[`${column}_ETC` as keyof SurveyDetailRequest] as string) setOtherValue(detailInfoData[`${column}_etc` as keyof SurveyDetailRequest] as string)
} }
}, [detailInfoData]) }, [detailInfoData])
@ -52,7 +52,7 @@ export default function MultiCheckbox({
newValue = value.filter((v) => v !== String(dataIndex)) newValue = value.filter((v) => v !== String(dataIndex))
} else { } else {
// 체크 // 체크
if (column === 'ROOF_MATERIAL') { if (column === 'roof_material') {
// 기타가 체크되어 있는지 확인 // 기타가 체크되어 있는지 확인
const isOtherSelected = isOtherChecked const isOtherSelected = isOtherChecked
// 현재 선택된 항목 수 + 기타 선택 여부 // 현재 선택된 항목 수 + 기타 선택 여부
@ -73,23 +73,27 @@ export default function MultiCheckbox({
} }
const handleOtherCheckbox = () => { const handleOtherCheckbox = () => {
if (column === 'ROOF_MATERIAL') { if (column === 'roof_material') {
const value = makeNumArr(String(detailInfoData[column as keyof SurveyDetailRequest] ?? '')) const value = makeNumArr(String(detailInfoData[column as keyof SurveyDetailRequest] ?? ''))
// 현재 선택된 항목 수
const currentSelected = value.length const currentSelected = value.length
if (!isOtherChecked && currentSelected >= 2) { if (!isOtherChecked && currentSelected >= 2) {
alert('Up to two roofing materials can be selected.') alert('Up to two roofing materials can be selected.')
return return
} }
} }
const newIsOtherChecked = !isOtherChecked setIsOtherChecked(!isOtherChecked)
setIsOtherChecked(newIsOtherChecked) if (!isOtherChecked) {
setOtherValue('') setOtherValue('')
setDetailInfoData({
setDetailInfoData({ ...detailInfoData,
...detailInfoData, [`${column}_etc`]: null,
[`${column}_ETC`]: newIsOtherChecked ? '' : null, })
}) } else {
setOtherValue('')
}
} }
const handleOtherInputChange = (e: React.ChangeEvent<HTMLInputElement>) => { const handleOtherInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
@ -97,13 +101,13 @@ export default function MultiCheckbox({
setOtherValue(value) setOtherValue(value)
setDetailInfoData({ setDetailInfoData({
...detailInfoData, ...detailInfoData,
[`${column}_ETC`]: value, [`${column}_etc`]: value,
}) })
} }
return ( return (
<> <>
{column === 'SUPPLEMENTARY_FACILITIES' ? ( {column === 'supplementary_facilities' ? (
<> <>
<div className="data-input-form-tit"> <div className="data-input-form-tit">
<span></span> <span></span>

View File

@ -2,25 +2,25 @@
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import { SurveyDetailRequest } from '@/types/Survey' import { SurveyDetailRequest } from '@/types/Survey'
type RadioEtcKeys = 'HOUSE_STRUCTURE' | 'RAFTER_MATERIAL' | 'WATERPROOF_MATERIAL' | 'INSULATION_PRESENCE' | 'RAFTER_DIRECTION' | 'LEAK_TRACE' type RadioEtcKeys = 'house_structure' | 'rafter_material' | 'waterproof_material' | 'insulation_presence' | 'rafter_direction' | 'leak_trace'
const translateJapanese: Record<RadioEtcKeys, string> = { const translateJapanese: Record<RadioEtcKeys, string> = {
HOUSE_STRUCTURE: '住宅構造', house_structure: '住宅構造',
RAFTER_MATERIAL: '垂木材質', rafter_material: '垂木材質',
WATERPROOF_MATERIAL: '防水材の種類', waterproof_material: '防水材の種類',
INSULATION_PRESENCE: '断熱材の有無', insulation_presence: '断熱材の有無',
RAFTER_DIRECTION: '垂木の方向', rafter_direction: '垂木の方向',
LEAK_TRACE: '水漏れの痕跡', leak_trace: '水漏れの痕跡',
} }
export const radioEtcData: Record<RadioEtcKeys, { id: number; label: string }[]> = { export const radioEtcData: Record<RadioEtcKeys, { id: number; label: string }[]> = {
HOUSE_STRUCTURE: [ house_structure: [
{ {
id: 1, id: 1,
label: '木製', label: '木製',
}, },
], ],
RAFTER_MATERIAL: [ rafter_material: [
{ {
id: 1, id: 1,
label: '木製', label: '木製',
@ -30,13 +30,13 @@ export const radioEtcData: Record<RadioEtcKeys, { id: number; label: string }[]>
label: '強制', label: '強制',
}, },
], ],
WATERPROOF_MATERIAL: [ waterproof_material: [
{ {
id: 1, id: 1,
label: 'アスファルト屋根94022kg以上', label: 'アスファルト屋根94022kg以上',
}, },
], ],
INSULATION_PRESENCE: [ insulation_presence: [
{ {
id: 1, id: 1,
label: 'なし', label: 'なし',
@ -46,7 +46,7 @@ export const radioEtcData: Record<RadioEtcKeys, { id: number; label: string }[]>
label: 'あり', label: 'あり',
}, },
], ],
RAFTER_DIRECTION: [ rafter_direction: [
{ {
id: 1, id: 1,
label: '垂直垂木', label: '垂直垂木',
@ -56,7 +56,7 @@ export const radioEtcData: Record<RadioEtcKeys, { id: number; label: string }[]>
label: '水平垂木', label: '水平垂木',
}, },
], ],
LEAK_TRACE: [ leak_trace: [
{ {
id: 1, id: 1,
label: 'あり', label: 'あり',
@ -81,53 +81,35 @@ export default function RadioEtc({
const [etcValue, setEtcValue] = useState('') const [etcValue, setEtcValue] = useState('')
useEffect(() => { useEffect(() => {
if (detailInfoData[`${column}_ETC` as keyof SurveyDetailRequest]) { if (detailInfoData[`${column}_etc` as keyof SurveyDetailRequest]) {
setIsEtcSelected(true) setIsEtcSelected(true)
setEtcValue(detailInfoData[`${column}_ETC` as keyof SurveyDetailRequest] as string) setEtcValue(detailInfoData[`${column}_etc` as keyof SurveyDetailRequest] as string)
} }
}, [detailInfoData]) }, [detailInfoData])
const handleRadioChange = (e: React.ChangeEvent<HTMLInputElement>) => { const handleRadioChange = (e: React.ChangeEvent<HTMLInputElement>) => {
// const value = e.target.value
// if (column === 'INSULATION_PRESENCE') {
// setIsEtcSelected(value === '2')
// setDetailInfoData({
// ...detailInfoData,
// [column]: value,
// })
// } else if (value === 'etc') {
// setIsEtcSelected(true)
// setDetailInfoData({
// ...detailInfoData,
// [column]: null,
// })
// } else {
// setIsEtcSelected(false)
// setEtcValue('')
// setDetailInfoData({
// ...detailInfoData,
// [column]: value,
// [`${column}_ETC`]: null,
// })
// }
const value = e.target.value const value = e.target.value
const isSpecialCase = column === 'INSULATION_PRESENCE' if (column === 'insulation_presence') {
const isEtc = value === 'etc' setIsEtcSelected(value === '2')
const isSpecialEtc = isSpecialCase && value === '2' setDetailInfoData({
...detailInfoData,
const updatedData: typeof detailInfoData = { [column]: Number(value),
...detailInfoData, })
[column]: isEtc ? null : value, } else if (value === 'etc') {
[`${column}_ETC`]: isEtc ? '' : null, setIsEtcSelected(true)
setDetailInfoData({
...detailInfoData,
[column]: null,
})
} else {
setIsEtcSelected(false)
setEtcValue('')
setDetailInfoData({
...detailInfoData,
[column]: Number(value),
[`${column}_etc`]: null,
})
} }
if (isSpecialEtc) {
updatedData[column] = value
}
setIsEtcSelected(isEtc || isSpecialEtc)
if (!isEtc) setEtcValue('')
setDetailInfoData(updatedData)
} }
const handleEtcInputChange = (e: React.ChangeEvent<HTMLInputElement>) => { const handleEtcInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
@ -135,7 +117,7 @@ export default function RadioEtc({
setEtcValue(value) setEtcValue(value)
setDetailInfoData({ setDetailInfoData({
...detailInfoData, ...detailInfoData,
[`${column}_ETC`]: value, [`${column}_etc`]: value,
}) })
} }
@ -148,24 +130,24 @@ export default function RadioEtc({
type="radio" type="radio"
name={column} name={column}
id={`${column}_${item.id}`} id={`${column}_${item.id}`}
value={item.id.toString()} value={item.id}
onChange={handleRadioChange} onChange={handleRadioChange}
checked={detailInfoData[column] === item.id.toString()} checked={detailInfoData[column] === item.id}
/> />
<label htmlFor={`${column}_${item.id}`}>{item.label}</label> <label htmlFor={`${column}_${item.id}`}>{item.label}</label>
</div> </div>
))} ))}
{column !== 'INSULATION_PRESENCE' && ( {column !== 'insulation_presence' && (
<div className="radio-form-box mb10"> <div className="radio-form-box mb10">
<input type="radio" name={column} id={`${column}_ETC`} value="etc" onChange={handleRadioChange} checked={isEtcSelected} /> <input type="radio" name={column} id={`${column}_etc`} value="etc" onChange={handleRadioChange} checked={isEtcSelected} />
<label htmlFor={`${column}_ETC`}> ()</label> <label htmlFor={`${column}_etc`}> ()</label>
</div> </div>
)} )}
<div className="data-input"> <div className="data-input">
<input <input
type="text" type="text"
className="input-frame" className="input-frame"
disabled={column === 'INSULATION_PRESENCE' ? !isEtcSelected : !isEtcSelected} disabled={column === 'insulation_presence' ? !isEtcSelected : !isEtcSelected}
value={etcValue} value={etcValue}
onChange={handleEtcInputChange} onChange={handleEtcInputChange}
/> />

View File

@ -11,41 +11,41 @@ import SelectBoxEtc from './SelectBoxEtc'
import RadioEtc from './RadioEtc' import RadioEtc from './RadioEtc'
const defaultDetailInfoForm: SurveyDetailRequest = { const defaultDetailInfoForm: SurveyDetailRequest = {
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: '1', house_structure: 1,
HOUSE_STRUCTURE_ETC: null, house_structure_etc: null,
RAFTER_MATERIAL: '1', rafter_material: 1,
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: '1', rafter_direction: 1,
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,
INSULATION_PRESENCE: '1', insulation_presence: 1,
INSULATION_PRESENCE_ETC: null, insulation_presence_etc: null,
STRUCTURE_ORDER: null, structure_order: null,
STRUCTURE_ORDER_ETC: null, structure_order_etc: null,
INSTALLATION_AVAILABILITY: null, installation_availability: null,
INSTALLATION_AVAILABILITY_ETC: null, installation_availability_etc: null,
MEMO: null, memo: null,
} }
export default function RoofInfoForm() { export default function RoofInfoForm() {
@ -64,14 +64,14 @@ export default function RoofInfoForm() {
const [detailInfoData, setDetailInfoData] = useState<SurveyDetailRequest>(defaultDetailInfoForm) const [detailInfoData, setDetailInfoData] = useState<SurveyDetailRequest>(defaultDetailInfoForm)
useEffect(() => { useEffect(() => {
if (surveyDetail?.DETAIL_INFO) { if (surveyDetail?.detail_info) {
const { ID, UPT_DT, REG_DT, BASIC_INFO_ID, ...rest } = surveyDetail.DETAIL_INFO const { id, updated_at, created_at, basic_info_id, ...rest } = surveyDetail.detail_info
setDetailInfoData(rest) setDetailInfoData(rest)
} }
}, [surveyDetail]) }, [surveyDetail])
const handleNumberInput = (key: keyof SurveyDetailRequest, value: number | string) => { const handleNumberInput = (key: keyof SurveyDetailRequest, value: number | string) => {
if (key === 'ROOF_SLOPE' || key === 'OPEN_FIELD_PLATE_THICKNESS') { if (key === 'roof_slope' || key === 'open_field_plate_thickness') {
const stringValue = value.toString() const stringValue = value.toString()
if (stringValue.length > 5) { if (stringValue.length > 5) {
alert('保存できるサイズを超えました。') alert('保存できるサイズを超えました。')
@ -86,7 +86,7 @@ export default function RoofInfoForm() {
} }
setDetailInfoData({ ...detailInfoData, [key]: value.toString() }) setDetailInfoData({ ...detailInfoData, [key]: value.toString() })
} else { } else {
setDetailInfoData({ ...detailInfoData, [key]: value.toString() }) setDetailInfoData({ ...detailInfoData, [key]: value })
} }
} }
@ -99,20 +99,19 @@ export default function RoofInfoForm() {
} }
const handleUnitInput = (value: string) => { const handleUnitInput = (value: string) => {
const numericValue = detailInfoData.CONTRACT_CAPACITY?.replace(/[^0-9.]/g, '') || '' const numericValue = detailInfoData.contract_capacity?.replace(/[^0-9.]/g, '') || ''
setDetailInfoData({ setDetailInfoData({
...detailInfoData, ...detailInfoData,
CONTRACT_CAPACITY: numericValue ? `${numericValue} ${value}` : value, contract_capacity: numericValue ? `${numericValue} ${value}` : value,
}) })
} }
const handleSave = async () => { const handleSave = async () => {
console.log(detailInfoData)
if (id) { if (id) {
const emptyField = validateSurveyDetail(detailInfoData) const emptyField = validateSurveyDetail(detailInfoData)
if (emptyField.trim() === '') { if (emptyField.trim() === '') {
const updatedBasicInfoData = { const updatedBasicInfoData = {
DETAIL_INFO: detailInfoData, detail_info: detailInfoData,
} }
try { try {
createSurveyDetail({ createSurveyDetail({
@ -152,17 +151,17 @@ export default function RoofInfoForm() {
type="number" type="number"
inputMode="decimal" inputMode="decimal"
className="input-frame" className="input-frame"
value={detailInfoData.CONTRACT_CAPACITY?.split(' ')[0] ?? ''} value={detailInfoData.contract_capacity?.split(' ')[0] ?? ''}
onChange={(e) => handleNumberInput('CONTRACT_CAPACITY', e.target.value)} onChange={(e) => handleNumberInput('contract_capacity', e.target.value)}
/> />
</div> </div>
<div className="data-input"> <div className="data-input">
<select <select
className="select-form" className="select-form"
name="CONTRACT_CAPACITY_UNIT" name="contract_capacity_unit"
id="CONTRACT_CAPACITY_UNIT" id="contract_capacity_unit"
onChange={(e) => handleUnitInput(e.target.value)} onChange={(e) => handleUnitInput(e.target.value)}
value={detailInfoData.CONTRACT_CAPACITY?.split(' ')[1] ?? ''} value={detailInfoData.contract_capacity?.split(' ')[1] ?? ''}
> >
<option value="" hidden> <option value="" hidden>
@ -178,16 +177,16 @@ export default function RoofInfoForm() {
<input <input
type="text" type="text"
className="input-frame" className="input-frame"
value={detailInfoData.RETAIL_COMPANY ?? ''} value={detailInfoData.retail_company ?? ''}
onChange={(e) => handleTextInput('RETAIL_COMPANY', e.target.value)} onChange={(e) => handleTextInput('retail_company', e.target.value)}
/> />
</div> </div>
{/* 전기 부대 설비 - supplementary_facilities */} {/* 전기 부대 설비 - supplementary_facilities */}
<div className="data-input-form-bx"> <div className="data-input-form-bx">
<MultiCheckEtc column={'SUPPLEMENTARY_FACILITIES'} setDetailInfoData={setDetailInfoData} detailInfoData={detailInfoData} /> <MultiCheckEtc column={'supplementary_facilities'} setDetailInfoData={setDetailInfoData} detailInfoData={detailInfoData} />
</div> </div>
{/* 설치 희망 시스템 - installation_system */} {/* 설치 희망 시스템 - installation_system */}
<SelectBoxEtc column={'INSTALLATION_SYSTEM'} setDetailInfoData={setDetailInfoData} detailInfoData={detailInfoData} /> <SelectBoxEtc column={'installation_system'} setDetailInfoData={setDetailInfoData} detailInfoData={detailInfoData} />
</div> </div>
</div> </div>
@ -195,13 +194,13 @@ export default function RoofInfoForm() {
<div className="sale-roof-title"></div> <div className="sale-roof-title"></div>
<div className="data-form-wrap"> <div className="data-form-wrap">
{/* 건축 연수 - construction_year */} {/* 건축 연수 - construction_year */}
<SelectBoxEtc column={'CONSTRUCTION_YEAR'} setDetailInfoData={setDetailInfoData} detailInfoData={detailInfoData} /> <SelectBoxEtc column={'construction_year'} setDetailInfoData={setDetailInfoData} detailInfoData={detailInfoData} />
{/* 지붕재 - roof_material */} {/* 지붕재 - roof_material */}
<div className="data-input-form-bx"> <div className="data-input-form-bx">
<MultiCheckEtc column={'ROOF_MATERIAL'} setDetailInfoData={setDetailInfoData} detailInfoData={detailInfoData} /> <MultiCheckEtc column={'roof_material'} setDetailInfoData={setDetailInfoData} detailInfoData={detailInfoData} />
</div> </div>
{/* 지붕 모양 - roof_shape */} {/* 지붕 모양 - roof_shape */}
<SelectBoxEtc column={'ROOF_SHAPE'} setDetailInfoData={setDetailInfoData} detailInfoData={detailInfoData} /> <SelectBoxEtc column={'roof_shape'} setDetailInfoData={setDetailInfoData} detailInfoData={detailInfoData} />
{/* 지붕 경사도 - roof_slope */} {/* 지붕 경사도 - roof_slope */}
<div className="data-input-form-bx"> <div className="data-input-form-bx">
<div className="data-input-form-tit"></div> <div className="data-input-form-tit"></div>
@ -211,20 +210,20 @@ export default function RoofInfoForm() {
step={0.1} step={0.1}
inputMode="decimal" inputMode="decimal"
className="input-frame" className="input-frame"
value={detailInfoData.ROOF_SLOPE ?? ''} value={detailInfoData.roof_slope ?? ''}
onChange={(e) => handleNumberInput('ROOF_SLOPE', e.target.value)} onChange={(e) => handleNumberInput('roof_slope', e.target.value)}
/> />
<span></span> <span></span>
</div> </div>
</div> </div>
{/* 주택 구조 - house_structure */} {/* 주택 구조 - house_structure */}
<RadioEtc column={'HOUSE_STRUCTURE'} setDetailInfoData={setDetailInfoData} detailInfoData={detailInfoData} /> <RadioEtc column={'house_structure'} setDetailInfoData={setDetailInfoData} detailInfoData={detailInfoData} />
{/* 서까래 재질 - rafter_material */} {/* 서까래 재질 - rafter_material */}
<RadioEtc column={'RAFTER_MATERIAL'} setDetailInfoData={setDetailInfoData} detailInfoData={detailInfoData} /> <RadioEtc column={'rafter_material'} setDetailInfoData={setDetailInfoData} detailInfoData={detailInfoData} />
{/* 서까래 크기 - rafter_size */} {/* 서까래 크기 - rafter_size */}
<SelectBoxEtc column={'RAFTER_SIZE'} setDetailInfoData={setDetailInfoData} detailInfoData={detailInfoData} /> <SelectBoxEtc column={'rafter_size'} setDetailInfoData={setDetailInfoData} detailInfoData={detailInfoData} />
{/* 서까래 피치 - rafter_pitch */} {/* 서까래 피치 - rafter_pitch */}
<SelectBoxEtc column={'RAFTER_PITCH'} setDetailInfoData={setDetailInfoData} detailInfoData={detailInfoData} /> <SelectBoxEtc column={'rafter_pitch'} setDetailInfoData={setDetailInfoData} detailInfoData={detailInfoData} />
{/* 서까래 방향 - rafter_direction */} {/* 서까래 방향 - rafter_direction */}
<div className="data-input-form-bx"> <div className="data-input-form-bx">
<div className="data-input-form-tit red-f"></div> <div className="data-input-form-tit red-f"></div>
@ -232,29 +231,29 @@ export default function RoofInfoForm() {
<div className="radio-form-box"> <div className="radio-form-box">
<input <input
type="radio" type="radio"
name="RAFTER_DIRECTION" name="rafter_direction"
id="RAFTER_DIRECTION_1" id="rafter_direction_1"
value={1} value={1}
onChange={(e) => handleNumberInput('RAFTER_DIRECTION', Number(e.target.value))} onChange={(e) => handleNumberInput('rafter_direction', Number(e.target.value))}
checked={detailInfoData.RAFTER_DIRECTION === '1'} checked={detailInfoData.rafter_direction === 1}
/> />
<label htmlFor="RAFTER_DIRECTION_1"></label> <label htmlFor="rafter_direction_1"></label>
</div> </div>
<div className="radio-form-box"> <div className="radio-form-box">
<input <input
type="radio" type="radio"
name="RAFTER_DIRECTION" name="rafter_direction"
id="RAFTER_DIRECTION_2" id="rafter_direction_2"
value={2} value={2}
onChange={(e) => handleNumberInput('RAFTER_DIRECTION', Number(e.target.value))} onChange={(e) => handleNumberInput('rafter_direction', Number(e.target.value))}
checked={detailInfoData.RAFTER_DIRECTION === '2'} checked={detailInfoData.rafter_direction === 2}
/> />
<label htmlFor="RAFTER_DIRECTION_2"></label> <label htmlFor="rafter_direction_2"></label>
</div> </div>
</div> </div>
</div> </div>
{/* 노지판 종류 - open_field_plate_kind */} {/* 노지판 종류 - open_field_plate_kind */}
<SelectBoxEtc column={'OPEN_FIELD_PLATE_KIND'} setDetailInfoData={setDetailInfoData} detailInfoData={detailInfoData} /> <SelectBoxEtc column={'open_field_plate_kind'} setDetailInfoData={setDetailInfoData} detailInfoData={detailInfoData} />
{/* 노지판 두께 - open_field_plate_thickness */} {/* 노지판 두께 - open_field_plate_thickness */}
<div className="data-input-form-bx"> <div className="data-input-form-bx">
<div className="data-input-form-tit"> <div className="data-input-form-tit">
@ -266,8 +265,8 @@ export default function RoofInfoForm() {
step={0.1} step={0.1}
inputMode="decimal" inputMode="decimal"
className="input-frame" className="input-frame"
value={detailInfoData.OPEN_FIELD_PLATE_THICKNESS ?? ''} value={detailInfoData.open_field_plate_thickness ?? ''}
onChange={(e) => handleNumberInput('OPEN_FIELD_PLATE_THICKNESS', e.target.value)} onChange={(e) => handleNumberInput('open_field_plate_thickness', e.target.value)}
/> />
<span>mm</span> <span>mm</span>
</div> </div>
@ -279,33 +278,33 @@ export default function RoofInfoForm() {
<div className="radio-form-box"> <div className="radio-form-box">
<input <input
type="radio" type="radio"
name="LEAK_TRACE" name="leak_trace"
id="LEAK_TRACE_1" id="leak_trace_1"
checked={detailInfoData.LEAK_TRACE === true} checked={detailInfoData.leak_trace === true}
onChange={(e) => handleBooleanInput('LEAK_TRACE', true)} onChange={(e) => handleBooleanInput('leak_trace', true)}
/> />
<label htmlFor="LEAK_TRACE_1"></label> <label htmlFor="leak_trace_1"></label>
</div> </div>
<div className="radio-form-box"> <div className="radio-form-box">
<input <input
type="radio" type="radio"
name="LEAK_TRACE" name="leak_trace"
id="LEAK_TRACE_2" id="leak_trace_2"
checked={detailInfoData.LEAK_TRACE === false} checked={detailInfoData.leak_trace === false}
onChange={(e) => handleBooleanInput('LEAK_TRACE', false)} onChange={(e) => handleBooleanInput('leak_trace', false)}
/> />
<label htmlFor="LEAK_TRACE_2"></label> <label htmlFor="leak_trace_2"></label>
</div> </div>
</div> </div>
</div> </div>
{/* 방수재 종류 - waterproof_material */} {/* 방수재 종류 - waterproof_material */}
<RadioEtc column={'WATERPROOF_MATERIAL'} setDetailInfoData={setDetailInfoData} detailInfoData={detailInfoData} /> <RadioEtc column={'waterproof_material'} setDetailInfoData={setDetailInfoData} detailInfoData={detailInfoData} />
{/* 단열재 유무 - insulation_presence */} {/* 단열재 유무 - insulation_presence */}
<RadioEtc column={'INSULATION_PRESENCE'} setDetailInfoData={setDetailInfoData} detailInfoData={detailInfoData} /> <RadioEtc column={'insulation_presence'} setDetailInfoData={setDetailInfoData} detailInfoData={detailInfoData} />
{/* 노지판 종류 - open_field_plate_kind */} {/* 노지판 종류 - open_field_plate_kind */}
<SelectBoxEtc column={'STRUCTURE_ORDER'} setDetailInfoData={setDetailInfoData} detailInfoData={detailInfoData} /> <SelectBoxEtc column={'structure_order'} setDetailInfoData={setDetailInfoData} detailInfoData={detailInfoData} />
{/* 설치 가능 여부 - installation_availability */} {/* 설치 가능 여부 - installation_availability */}
<SelectBoxEtc column={'INSTALLATION_AVAILABILITY'} setDetailInfoData={setDetailInfoData} detailInfoData={detailInfoData} /> <SelectBoxEtc column={'installation_availability'} setDetailInfoData={setDetailInfoData} detailInfoData={detailInfoData} />
{/* 메모 - memo */} {/* 메모 - memo */}
<div className="data-input-form-bx"> <div className="data-input-form-bx">
<div className="data-input-form-tit"></div> <div className="data-input-form-tit"></div>
@ -321,10 +320,10 @@ export default function RoofInfoForm() {
<div className="data-input"> <div className="data-input">
<textarea <textarea
className="textarea-form" className="textarea-form"
name="MEMO" name="memo"
id="MEMO" id="memo"
value={detailInfoData.MEMO ?? ''} value={detailInfoData.memo ?? ''}
onChange={(e) => handleTextInput('MEMO', e.target.value)} onChange={(e) => handleTextInput('memo', e.target.value)}
placeholder="例: 漏れの兆候があるため、正確な点検が必要です." placeholder="例: 漏れの兆候があるため、正確な点検が必要です."
></textarea> ></textarea>
</div> </div>

View File

@ -2,39 +2,39 @@ import type { SurveyDetailRequest } from '@/types/Survey'
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
export type SelectBoxKeys = export type SelectBoxKeys =
| 'INSTALLATION_SYSTEM' | 'installation_system'
| 'CONSTRUCTION_YEAR' | 'construction_year'
| 'ROOF_SHAPE' | 'roof_shape'
| 'RAFTER_PITCH' | 'rafter_pitch'
| 'RAFTER_SIZE' | 'rafter_size'
| 'OPEN_FIELD_PLATE_KIND' | 'open_field_plate_kind'
| 'STRUCTURE_ORDER' | 'structure_order'
| 'INSTALLATION_AVAILABILITY' | 'installation_availability'
const font: Record<SelectBoxKeys, string> = { const font: Record<SelectBoxKeys, string> = {
INSTALLATION_SYSTEM: 'data-input-form-tit red-f', installation_system: 'data-input-form-tit red-f',
CONSTRUCTION_YEAR: 'data-input-form-tit red-f', construction_year: 'data-input-form-tit red-f',
ROOF_SHAPE: 'data-input-form-tit', roof_shape: 'data-input-form-tit',
RAFTER_PITCH: 'data-input-form-tit red-f', rafter_pitch: 'data-input-form-tit red-f',
RAFTER_SIZE: 'data-input-form-tit red-f', rafter_size: 'data-input-form-tit red-f',
OPEN_FIELD_PLATE_KIND: 'data-input-form-tit', open_field_plate_kind: 'data-input-form-tit',
STRUCTURE_ORDER: 'data-input-form-tit red-f', structure_order: 'data-input-form-tit red-f',
INSTALLATION_AVAILABILITY: 'data-input-form-tit', installation_availability: 'data-input-form-tit',
} }
const translateJapanese: Record<SelectBoxKeys, string> = { const translateJapanese: Record<SelectBoxKeys, string> = {
INSTALLATION_SYSTEM: '設置希望システム', installation_system: '設置希望システム',
CONSTRUCTION_YEAR: '建築年数', construction_year: '建築年数',
ROOF_SHAPE: '屋根の形状', roof_shape: '屋根の形状',
RAFTER_PITCH: '垂木傾斜', rafter_pitch: '垂木傾斜',
RAFTER_SIZE: '垂木サイズ', rafter_size: '垂木サイズ',
OPEN_FIELD_PLATE_KIND: '路地板の種類', open_field_plate_kind: '路地板の種類',
STRUCTURE_ORDER: '屋根構造の順序', structure_order: '屋根構造の順序',
INSTALLATION_AVAILABILITY: '屋根製品名 設置可否確認', installation_availability: '屋根製品名 設置可否確認',
} }
export const selectBoxOptions: Record<SelectBoxKeys, { id: number; name: string }[]> = { export const selectBoxOptions: Record<SelectBoxKeys, { id: number; name: string }[]> = {
INSTALLATION_SYSTEM: [ installation_system: [
{ {
id: 1, id: 1,
name: '太陽光発電', //태양광발전 name: '太陽光発電', //태양광발전
@ -48,7 +48,7 @@ export const selectBoxOptions: Record<SelectBoxKeys, { id: number; name: string
name: '蓄電池システム', //축전지시스템 name: '蓄電池システム', //축전지시스템
}, },
], ],
CONSTRUCTION_YEAR: [ construction_year: [
{ {
id: 1, id: 1,
name: '新築', //신축 name: '新築', //신축
@ -58,7 +58,7 @@ export const selectBoxOptions: Record<SelectBoxKeys, { id: number; name: string
name: '既築', //기존 name: '既築', //기존
}, },
], ],
ROOF_SHAPE: [ roof_shape: [
{ {
id: 1, id: 1,
name: '切妻', //박공지붕 name: '切妻', //박공지붕
@ -72,7 +72,7 @@ export const selectBoxOptions: Record<SelectBoxKeys, { id: number; name: string
name: '片流れ', //한쪽흐름 name: '片流れ', //한쪽흐름
}, },
], ],
RAFTER_SIZE: [ rafter_size: [
{ {
id: 1, id: 1,
name: '幅35mm以上×高さ48mm以上', name: '幅35mm以上×高さ48mm以上',
@ -90,7 +90,7 @@ export const selectBoxOptions: Record<SelectBoxKeys, { id: number; name: string
name: '幅38mm以上×高さ40mm以上', name: '幅38mm以上×高さ40mm以上',
}, },
], ],
RAFTER_PITCH: [ rafter_pitch: [
{ {
id: 1, id: 1,
name: '(455mm以下', name: '(455mm以下',
@ -104,7 +104,7 @@ export const selectBoxOptions: Record<SelectBoxKeys, { id: number; name: string
name: '606mm以下', name: '606mm以下',
}, },
], ],
OPEN_FIELD_PLATE_KIND: [ open_field_plate_kind: [
{ {
id: 1, id: 1,
name: '構造用合板', //구조용합판 name: '構造用合板', //구조용합판
@ -122,7 +122,7 @@ export const selectBoxOptions: Record<SelectBoxKeys, { id: number; name: string
name: '小幅板', //소판 name: '小幅板', //소판
}, },
], ],
STRUCTURE_ORDER: [ structure_order: [
{ {
id: 1, id: 1,
name: '屋根材', //지붕재 name: '屋根材', //지붕재
@ -140,7 +140,7 @@ export const selectBoxOptions: Record<SelectBoxKeys, { id: number; name: string
name: '垂木', //서까래 name: '垂木', //서까래
}, },
], ],
INSTALLATION_AVAILABILITY: [ installation_availability: [
{ {
id: 1, id: 1,
name: '確認済み', //확인완료 name: '確認済み', //확인완료
@ -165,32 +165,35 @@ export default function SelectBoxForm({
const [etcValue, setEtcValue] = useState('') const [etcValue, setEtcValue] = useState('')
useEffect(() => { useEffect(() => {
if (detailInfoData[`${column}_ETC` as keyof SurveyDetailRequest]) { if (detailInfoData[`${column}_etc` as keyof SurveyDetailRequest]) {
setIsEtcSelected(true) setIsEtcSelected(true)
setEtcValue(detailInfoData[`${column}_ETC` as keyof SurveyDetailRequest] as string) setEtcValue(detailInfoData[`${column}_etc` as keyof SurveyDetailRequest] as string)
} }
}, [detailInfoData]) }, [detailInfoData])
const handleSelectChange = (e: React.ChangeEvent<HTMLSelectElement>) => { const handleSelectChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
const value = e.target.value const value = e.target.value
const isSpecialCase = column === 'CONSTRUCTION_YEAR' || column === 'INSTALLATION_AVAILABILITY' if (column === 'installation_availability' || column === 'construction_year') {
const isEtc = value === 'etc' setIsEtcSelected(value === '2') // 건축 연수 & 설치 가능 여부 컬럼 2번 선택 시 input 활성화
const isSpecialEtc = isSpecialCase && value === '2' setDetailInfoData({
...detailInfoData,
const updatedData: typeof detailInfoData = { [column]: Number(value),
...detailInfoData, })
[column]: isEtc ? null : value, } else if (value === 'etc') {
[`${column}_ETC`]: isEtc ? '' : null, setIsEtcSelected(true) // 기타 선택 시 input 활성화
setDetailInfoData({
...detailInfoData,
[column]: null,
})
} else {
setIsEtcSelected(false) // 기타 선택 해제 시 input 비활성화
setEtcValue('')
setDetailInfoData({
...detailInfoData,
[`${column}_etc`]: null,
[column]: Number(value),
})
} }
// 건축연수 + 설치가능여부는 2번 선택 시 input 활성화
if (isSpecialEtc) {
updatedData[column] = value
}
setIsEtcSelected(isEtc || isSpecialEtc)
if (!isEtc) setEtcValue('')
setDetailInfoData(updatedData)
} }
const handleEtcInputChange = (e: React.ChangeEvent<HTMLInputElement>) => { const handleEtcInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
@ -198,31 +201,31 @@ export default function SelectBoxForm({
setEtcValue(value) setEtcValue(value)
setDetailInfoData({ setDetailInfoData({
...detailInfoData, ...detailInfoData,
[`${column}_ETC`]: value, [`${column}_etc`]: value,
}) })
} }
return ( return (
<> <>
<div className="data-input-form-bx"> <div className="data-input-form-bx">
<div className={font[column as keyof typeof font]}>{translateJapanese[column as keyof typeof translateJapanese]}</div> <div className={font[column]}>{translateJapanese[column]}</div>
<div className="data-input mb5"> <div className="data-input mb5">
<select <select
className="select-form" className="select-form"
name={column} name={column}
id={column} id={column}
onChange={handleSelectChange} onChange={handleSelectChange}
value={detailInfoData[column] ? detailInfoData[column] : detailInfoData[`${column}_ETC`] ? 'etc' : isEtcSelected ? 'etc' : ''} value={detailInfoData[column] ? detailInfoData[column] : detailInfoData[`${column}_etc`] ? 'etc' : ''}
> >
<option value="" hidden> <option value="" hidden>
</option> </option>
{selectBoxOptions[column as keyof typeof selectBoxOptions].map((option) => ( {selectBoxOptions[column].map((option) => (
<option key={option.id} value={option.id}> <option key={option.id} value={option.id}>
{option.name} {option.name}
</option> </option>
))} ))}
{column !== 'INSTALLATION_AVAILABILITY' && column !== 'CONSTRUCTION_YEAR' && <option value="etc"> ()</option>} {column !== 'installation_availability' && column !== 'construction_year' && <option value="etc"> ()</option>}
</select> </select>
</div> </div>
<div className="data-input"> <div className="data-input">
@ -232,10 +235,10 @@ export default function SelectBoxForm({
value={etcValue ?? ''} value={etcValue ?? ''}
onChange={handleEtcInputChange} onChange={handleEtcInputChange}
disabled={ disabled={
column === 'INSTALLATION_AVAILABILITY' column === 'installation_availability'
? !Boolean(detailInfoData[column]) ? !Boolean(detailInfoData[column])
: column === 'CONSTRUCTION_YEAR' : column === 'construction_year'
? detailInfoData[column] !== '2' // 既築(2)가 아닐 때 비활성화 ? detailInfoData[column] !== 2 // 既築(2)가 아닐 때 비활성화
: !isEtcSelected : !isEtcSelected
} }
/> />

View File

@ -6,8 +6,7 @@ import { useEffect, useState } from 'react'
import { useRouter } from 'next/navigation' import { useRouter } from 'next/navigation'
import SearchForm from './SearchForm' import SearchForm from './SearchForm'
import { useSurveyFilterStore } from '@/store/surveyFilterStore' import { useSurveyFilterStore } from '@/store/surveyFilterStore'
import { MemberRole } from '@/hooks/useUserType' import { UserType } from '@/hooks/useUserType'
import { useSessionStore } from '@/store/session'
export default function ListTable() { export default function ListTable() {
const router = useRouter() const router = useRouter()
@ -16,9 +15,7 @@ export default function ListTable() {
const [heldSurveyList, setHeldSurveyList] = useState<typeof surveyList>([]) const [heldSurveyList, setHeldSurveyList] = useState<typeof surveyList>([])
const [hasMore, setHasMore] = useState(false) const [hasMore, setHasMore] = useState(false)
const [memberRole, setMemberRole] = useState<MemberRole>() const [memberType, setMemberType] = useState<UserType>('hwj')
const { session } = useSessionStore()
useEffect(() => { useEffect(() => {
if (surveyList && surveyList.length > 0) { if (surveyList && surveyList.length > 0) {
@ -32,8 +29,9 @@ export default function ListTable() {
} }
setHasMore(surveyListCount > offset + 10) setHasMore(surveyListCount > offset + 10)
} }
setMemberRole(session.role as MemberRole) // 회원 유형 설정 이후 변경
}, [surveyList, surveyListCount, offset, session]) setMemberType('hwj')
}, [surveyList, surveyListCount, offset])
const handleDetailClick = (id: number) => { const handleDetailClick = (id: number) => {
router.push(`/survey-sale/${id}`) router.push(`/survey-sale/${id}`)
@ -47,22 +45,22 @@ export default function ListTable() {
return ( return (
<> <>
<SearchForm onItemsInit={handleItemsInit} memberRole={memberRole as MemberRole} /> <SearchForm onItemsInit={handleItemsInit} memberType={memberType} />
{heldSurveyList.length > 0 ? ( {heldSurveyList.length > 0 ? (
<div className="sale-frame"> <div className="sale-frame">
<ul className="sale-list-wrap"> <ul className="sale-list-wrap">
{heldSurveyList.map((survey) => ( {heldSurveyList.map((survey) => (
<li className="sale-list-item cursor-pointer" key={survey.ID} onClick={() => handleDetailClick(survey.ID)}> <li className="sale-list-item cursor-pointer" key={survey.id} onClick={() => handleDetailClick(survey.id)}>
<div className="sale-item-bx"> <div className="sale-item-bx">
<div className="sale-item-date-bx"> <div className="sale-item-date-bx">
<div className="sale-item-num">{survey.ID}</div> <div className="sale-item-num">{survey.id}</div>
<div className="sale-item-date">{survey.INVESTIGATION_DATE}</div> <div className="sale-item-date">{survey.investigation_date}</div>
</div> </div>
<div className="sale-item-tit">{survey.BUILDING_NAME}</div> <div className="sale-item-tit">{survey.building_name}</div>
<div className="sale-item-customer">{survey.CUSTOMER_NAME}</div> <div className="sale-item-customer">{survey.customer_name}</div>
<div className="sale-item-update-bx"> <div className="sale-item-update-bx">
<div className="sale-item-name">{survey.REPRESENTATIVE}</div> <div className="sale-item-name">{survey.representative}</div>
<div className="sale-item-update">{new Date(survey.UPT_DT).toLocaleString()}</div> <div className="sale-item-update">{new Date(survey.updated_at).toLocaleString()}</div>
</div> </div>
</div> </div>
</li> </li>

View File

@ -1,11 +1,11 @@
'use client' 'use client'
import { SEARCH_OPTIONS, SEARCH_OPTIONS_ENUM, SEARCH_OPTIONS_PARTNERS, useSurveyFilterStore } from '@/store/surveyFilterStore' import { SEARCH_OPTIONS, SEARCH_OPTIONS_ENUM, SEARCH_OPTIONS_PARTNERS, useSurveyFilterStore } from '@/store/surveyFilterStore'
import { MemberRole } from '@/hooks/useUserType' import { UserType } from '@/hooks/useUserType'
import { useRouter } from 'next/navigation' import { useRouter } from 'next/navigation'
import { useState } from 'react' import { useState } from 'react'
export default function SearchForm({ onItemsInit, memberRole }: { onItemsInit: () => void; memberRole: MemberRole }) { export default function SearchForm({ onItemsInit, memberType }: { onItemsInit: () => void; memberType: UserType }) {
const router = useRouter() const router = useRouter()
const { setSearchOption, setSort, setIsMySurvey, setKeyword, isMySurvey, keyword, searchOption, sort } = useSurveyFilterStore() const { setSearchOption, setSort, setIsMySurvey, setKeyword, isMySurvey, keyword, searchOption, sort } = useSurveyFilterStore()
const [searchKeyword, setSearchKeyword] = useState(keyword) const [searchKeyword, setSearchKeyword] = useState(keyword)
@ -20,7 +20,7 @@ export default function SearchForm({ onItemsInit, memberRole }: { onItemsInit: (
setKeyword(searchKeyword) setKeyword(searchKeyword)
onItemsInit() onItemsInit()
} }
const searchOptions = memberRole === 'Partner' ? SEARCH_OPTIONS_PARTNERS : SEARCH_OPTIONS const searchOptions = memberType === 'partner' ? SEARCH_OPTIONS_PARTNERS : SEARCH_OPTIONS
return ( return (
<div className="sale-frame"> <div className="sale-frame">

View File

@ -1,19 +1,10 @@
'use client' 'use client'
import { usePopupController } from '@/store/popupController' import { usePopupController } from '@/store/popupController'
import React from 'react'
export default function DoubleBtnAlert() { export default function DoubleBtnAlert() {
const { alertMsg, alert2BtnYes, alert2BtnNo, setAlert2 } = usePopupController() const { alertMsg, alert2BtnYes, alert2BtnNo } = usePopupController()
const handleAlert2BtnYes = () => {
alert2BtnYes()
setAlert2(false)
}
const handleAlert2BtnNo = () => {
alert2BtnNo()
setAlert2(false)
}
return ( return (
<div className="modal-popup alert"> <div className="modal-popup alert">
@ -22,12 +13,12 @@ export default function DoubleBtnAlert() {
<div className="alert-tit">{alertMsg}</div> <div className="alert-tit">{alertMsg}</div>
<div className="alert-btn-wrap"> <div className="alert-btn-wrap">
<div className="alert-btn-bx"> <div className="alert-btn-bx">
<button className="btn-frame red min" onClick={() => handleAlert2BtnYes()}> <button className="btn-frame red min" onClick={() => alert2BtnYes()}>
</button> </button>
</div> </div>
<div className="alert-btn-bx"> <div className="alert-btn-bx">
<button className="btn-frame n-blue min" onClick={() => handleAlert2BtnNo()}> <button className="btn-frame n-blue min" onClick={() => alert2BtnNo()}>
</button> </button>
</div> </div>

View File

@ -120,7 +120,7 @@ export default function Header() {
</button> </button>
</li> </li>
<li className="side-footer-item"> <li className="side-footer-item">
<button>{session.userId}</button> <button>Jynoadmin</button>
</li> </li>
<li className="side-footer-item"> <li className="side-footer-item">
<button onClick={() => router.push('/')}>HOME</button> <button onClick={() => router.push('/')}>HOME</button>

View File

@ -1,30 +0,0 @@
import { suitableApi } from '@/api/suitable'
export function useSuitable() {
const getCategories = async () => {
try {
return await suitableApi.getCategory()
} catch (error) {
console.error('카테고리 데이터 로드 실패:', error)
return []
}
}
const getSuitables = async () => {
try {
return await suitableApi.getList()
} catch (error) {
console.error('지붕재 데이터 로드 실패:', error)
}
}
const updateSearchResults = async (selectedCategory: string | undefined, searchValue: string | undefined) => {
try {
return await suitableApi.getList(selectedCategory, searchValue)
} catch (error) {
console.error('지붕재 데이터 검색 실패:', error)
}
}
return { getCategories, getSuitables, updateSearchResults }
}

View File

@ -41,13 +41,13 @@ export function useServey(id?: number): {
} { } {
const queryClient = useQueryClient() const queryClient = useQueryClient()
const { keyword, searchOption, isMySurvey, sort, offset } = useSurveyFilterStore() const { keyword, searchOption, isMySurvey, sort, offset } = useSurveyFilterStore()
const { store, builderNo, memberRole } = useUserType() const { store, construction_point } = useUserType()
const { data: surveyList, isLoading: isLoadingSurveyList } = useQuery({ const { data: surveyList, isLoading: isLoadingSurveyList } = useQuery({
queryKey: ['survey', 'list', keyword, searchOption, isMySurvey, sort, offset, store, builderNo, memberRole], queryKey: ['survey', 'list', keyword, searchOption, isMySurvey, sort, offset, store, construction_point],
queryFn: async () => { queryFn: async () => {
const resp = await axiosInstance(null).get<SurveyBasicInfo[]>('/api/survey-sales', { const resp = await axiosInstance(null).get<SurveyBasicInfo[]>('/api/survey-sales', {
params: { keyword, searchOption, isMySurvey, sort, offset, store, builderNo, memberRole }, params: { keyword, searchOption, isMySurvey, sort, offset, store, construction_point },
}) })
return resp.data return resp.data
}, },
@ -77,7 +77,7 @@ export function useServey(id?: number): {
const { mutateAsync: createSurvey, isPending: isCreatingSurvey } = useMutation({ const { mutateAsync: createSurvey, isPending: isCreatingSurvey } = useMutation({
mutationFn: async (survey: SurveyBasicRequest) => { mutationFn: async (survey: SurveyBasicRequest) => {
const resp = await axiosInstance(null).post<SurveyBasicInfo>('/api/survey-sales', survey) const resp = await axiosInstance(null).post<SurveyBasicInfo>('/api/survey-sales', survey)
return resp.data.ID ?? 0 return resp.data.id ?? 0
}, },
onSuccess: (data) => { onSuccess: (data) => {
queryClient.invalidateQueries({ queryKey: ['survey', 'list'] }) queryClient.invalidateQueries({ queryKey: ['survey', 'list'] })
@ -138,29 +138,28 @@ export function useServey(id?: number): {
const validateSurveyDetail = (surveyDetail: SurveyDetailRequest) => { const validateSurveyDetail = (surveyDetail: SurveyDetailRequest) => {
const requiredFields = [ const requiredFields = [
'INSTALLATION_SYSTEM', 'installation_system',
'CONSTRUCTION_YEAR', 'construction_year',
'RAFTER_SIZE', 'rafter_size',
'RAFTER_PITCH', 'rafter_pitch',
'RAFTER_DIRECTION', 'rafter_direction',
'WATERPROOF_MATERIAL', 'waterproof_material',
'INSULATION_PRESENCE', 'insulation_presence',
'STRUCTURE_ORDER', 'structure_order',
] as const ] as const
const etcFields = ['INSTALLATION_SYSTEM', 'CONSTRUCTION_YEAR', 'RAFTER_SIZE', 'RAFTER_PITCH', 'WATERPROOF_MATERIAL', 'STRUCTURE_ORDER'] as const const etcFields = ['installation_system', 'construction_year', 'rafter_size', 'rafter_pitch', 'waterproof_material', 'structure_order'] as const
const emptyField = requiredFields.find((field) => { const emptyField = requiredFields.find((field) => {
if (etcFields.includes(field as (typeof etcFields)[number])) { if (etcFields.includes(field as (typeof etcFields)[number])) {
return surveyDetail[field as keyof SurveyDetailRequest] === null && surveyDetail[`${field}_ETC` as keyof SurveyDetailRequest] === null return surveyDetail[field as keyof SurveyDetailRequest] === null && surveyDetail[`${field}_etc` as keyof SurveyDetailRequest] === null
} else {
return surveyDetail[field as keyof SurveyDetailRequest] === null
} }
return surveyDetail[field as keyof SurveyDetailRequest] === null
}) })
const contractCapacity = surveyDetail.CONTRACT_CAPACITY const contractCapacity = surveyDetail.contract_capacity
if (contractCapacity && contractCapacity.trim() !== '' && contractCapacity.split(' ')?.length === 1) { if (contractCapacity && contractCapacity.trim() !== '' && contractCapacity.split(' ')?.length === 1) {
return 'CONTRACT_CAPACITY_UNIT' return 'contract_capacity_unit'
} }
return emptyField || '' return emptyField || ''

View File

@ -1,31 +1,24 @@
import { useSessionStore } from '@/store/session' import { useSessionStore } from '@/store/session'
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
export type MemberRole = 'T01' | 'Admin' | 'Admin_Sub' | 'Builder' | 'Partner' | 'User' export type UserType = 'hwj' | 'order' | 'musubi' | 'musubi_con' | 'partner'
// TO1 - else
// Admin - 1차점, Admin_Sub - 2차점, Builder - 2차점 시공사, Partner - 파트너사, User - else
// 로그인 된 회원 유형에 따라 조사 매물 목록 변경됨 // 로그인 된 회원 유형에 따라 조사 매물 목록 변경됨
export function useUserType() { export function useUserType() {
const { session } = useSessionStore() const { session } = useSessionStore()
const [memberRole, setMemberRole] = useState<MemberRole | null>(null) const [userType, setUserType] = useState<UserType | null>(null)
const [store, setStore] = useState<string | null>(null) const [store, setStore] = useState<string | null>(null)
const [builderNo, setBuilderNo] = useState<string | null>(null) const [construction_point, setConstructionPoint] = useState<string | null>(null)
// TODO: 회원 유형 설정
useEffect(() => { useEffect(() => {
if (!session?.isLoggedIn) return if (!session?.isLoggedIn) return
setMemberRole(session.role as MemberRole) setUserType('musubi_con')
if (session.role === 'T01') {
setStore(null)
} else {
setStore(session.storeId)
}
setBuilderNo(session.builderNo)
}, [session]) }, [session])
return { return {
memberRole, userType,
store, store,
builderNo, construction_point,
} }
} }

View File

@ -7,12 +7,6 @@ import { usePathname } from 'next/navigation'
import { useEffect } from 'react' import { useEffect } from 'react'
import { useSessionStore } from '@/store/session' import { useSessionStore } from '@/store/session'
declare global {
interface Window {
neoConfirm: (msg?: string, alertBtn2Yes?: Function, alertBtn2No?: Function) => boolean
}
}
interface EdgeProviderProps { interface EdgeProviderProps {
children: React.ReactNode children: React.ReactNode
sessionData: string sessionData: string
@ -50,24 +44,29 @@ export default function EdgeProvider({ children, sessionData }: EdgeProviderProp
setAlert2(true) setAlert2(true)
} }
//alert 함수 변경해서 바인딩
useEffect(() => { useEffect(() => {
//alert 함수 변경해서 바인딩
window.alert = function (msg, alertBtn = () => setAlert(false)) { window.alert = function (msg, alertBtn = () => setAlert(false)) {
alertFunc(msg, alertBtn) alertFunc(msg, alertBtn)
} }
// confirm 함수 변경해서 바인딩 window.confirm = function (msg = '', alert2BtnYes = () => setAlert2(false), alert2BtnNo = () => setAlert2(false)) {
window.neoConfirm = function (msg: string | undefined, alertBtn2Yes?: Function, alertBtn2No?: Function) { alertFunc2(
if (!msg) return false msg,
alertFunc2(msg, alertBtn2Yes || (() => {}), alertBtn2No || (() => {})) () => {
alert2BtnYes()
return true
},
() => {
alert2BtnNo()
return false
},
)
return false return false
} }
// 서버 세션이 있으면 zuatand 세션 데이터 갱신 setSession({
if (sessionData && sessionData !== '') { ...session,
setSession({ ...JSON.parse(sessionData),
...session, })
...JSON.parse(sessionData),
})
}
}, []) }, [])
/** /**

View File

@ -41,7 +41,6 @@ const initialState: InitialState = {
custCd: null, custCd: null,
builderNo: null, builderNo: null,
isLoggedIn: false, isLoggedIn: false,
role: null,
}, },
} }

View File

@ -1,68 +0,0 @@
import { create } from 'zustand'
import { Suitable, suitableApi } from '@/api/suitable'
interface SuitableState {
// // 검색 결과 리스트
// searchResults: Suitable[]
// // 초기 데이터 로드
// fetchInitializeData: () => Promise<void>
// // 검색 결과 설정
// setSearchResults: (results: Suitable[]) => void
// // 검색 결과 초기화
// resetSearchResults: () => void
// 선택된 아이템 리스트
selectedItems: Suitable[]
// 선택된 아이템 추가
addSelectedItem: (item: Suitable) => void
// 선택된 아이템 제거
removeSelectedItem: (itemId: number) => void
// 선택된 아이템 모두 제거
clearSelectedItems: () => void
}
export const useSuitableStore = create<SuitableState>((set) => ({
// // 초기 상태
// searchResults: [],
// // 초기 데이터 로드
// fetchInitializeData: async () => {
// const suitables = await fetchInitialSuitablee()
// set({ searchResults: suitables })
// },
// // 검색 결과 설정
// setSearchResults: (results) => set({ searchResults: results }),
// // 검색 결과 초기화
// resetSearchResults: () => set({ searchResults: [] }),
// 초기 상태
selectedItems: [],
// 선택된 아이템 추가 (중복 방지)
addSelectedItem: (item) =>
set((state) => ({
selectedItems: state.selectedItems.some((i) => i.id === item.id) ? state.selectedItems : [...state.selectedItems, item],
})),
// 선택된 아이템 제거
removeSelectedItem: (itemId) =>
set((state) => ({
selectedItems: state.selectedItems.filter((item) => item.id !== itemId),
})),
// 선택된 아이템 모두 제거
clearSelectedItems: () => set({ selectedItems: [] }),
}))
// // 전체 데이터 초기화 함수
// async function fetchInitialSuitablee() {
// try {
// const suitable = await suitableApi.getList()
// return suitable
// } catch (error) {
// console.error('초기 데이터 로드 실패:', error)
// return []
// }
// }

View File

@ -27,5 +27,4 @@ export interface SessionData {
custCd: null custCd: null
builderNo: null builderNo: null
isLoggedIn: boolean isLoggedIn: boolean
role: string | null
} }

View File

@ -1,117 +1,117 @@
import { SEARCH_OPTIONS_ENUM, SEARCH_OPTIONS_PARTNERS_ENUM, SORT_OPTIONS_ENUM } from '@/store/surveyFilterStore' import { SEARCH_OPTIONS_ENUM, SEARCH_OPTIONS_PARTNERS_ENUM, SORT_OPTIONS_ENUM } from '@/store/surveyFilterStore'
export type SurveyBasicInfo = { export type SurveyBasicInfo = {
ID: number id: number
REPRESENTATIVE: string representative: string
STORE: string | null store: string | null
CONSTRUCTION_POINT: string | null construction_point: string | null
INVESTIGATION_DATE: string | null investigation_date: string | null
BUILDING_NAME: string | null building_name: string | null
CUSTOMER_NAME: string | null customer_name: string | null
POST_CODE: string | null post_code: string | null
ADDRESS: string | null address: string | null
ADDRESS_DETAIL: string | null address_detail: string | null
SUBMISSION_STATUS: boolean submission_status: boolean
SUBMISSION_DATE: string | null submission_date: string | null
DETAIL_INFO: SurveyDetailInfo | null detail_info: SurveyDetailInfo | null
REG_DT: Date created_at: Date
UPT_DT: Date updated_at: Date
} }
export type SurveyDetailInfo = { export type SurveyDetailInfo = {
ID: number id: number
BASIC_INFO_ID: number basic_info_id: number
CONTRACT_CAPACITY: string | null contract_capacity: string | null
RETAIL_COMPANY: string | null retail_company: string | null
SUPPLEMENTARY_FACILITIES: string | null // number 배열 supplementary_facilities: string | null // number 배열
SUPPLEMENTARY_FACILITIES_ETC: string | null supplementary_facilities_etc: string | null
INSTALLATION_SYSTEM: string | null installation_system: number | null
INSTALLATION_SYSTEM_ETC: string | null installation_system_etc: string | null
CONSTRUCTION_YEAR: string | null construction_year: number | null
CONSTRUCTION_YEAR_ETC: string | null construction_year_etc: string | null
ROOF_MATERIAL: string | null // number 배열 roof_material: string | null // number 배열
ROOF_MATERIAL_ETC: string | null roof_material_etc: string | null
ROOF_SHAPE: string | null roof_shape: number | null
ROOF_SHAPE_ETC: string | null roof_shape_etc: string | null
ROOF_SLOPE: string | null roof_slope: string | null
HOUSE_STRUCTURE: string | null house_structure: number | null
HOUSE_STRUCTURE_ETC: string | null house_structure_etc: string | null
RAFTER_MATERIAL: string | null rafter_material: number | null
RAFTER_MATERIAL_ETC: string | null rafter_material_etc: string | null
RAFTER_SIZE: string | null rafter_size: number | null
RAFTER_SIZE_ETC: string | null rafter_size_etc: string | null
RAFTER_PITCH: string | null rafter_pitch: number | null
RAFTER_PITCH_ETC: string | null rafter_pitch_etc: string | null
RAFTER_DIRECTION: string | null rafter_direction: number | null
OPEN_FIELD_PLATE_KIND: string | null open_field_plate_kind: number | null
OPEN_FIELD_PLATE_KIND_ETC: string | null open_field_plate_kind_etc: string | null
OPEN_FIELD_PLATE_THICKNESS: string | null open_field_plate_thickness: string | null
LEAK_TRACE: boolean | null leak_trace: boolean | null
WATERPROOF_MATERIAL: string | null waterproof_material: number | null
WATERPROOF_MATERIAL_ETC: string | null waterproof_material_etc: string | null
INSULATION_PRESENCE: string | null insulation_presence: number | null
INSULATION_PRESENCE_ETC: string | null insulation_presence_etc: string | null
STRUCTURE_ORDER: string | null structure_order: number | null
STRUCTURE_ORDER_ETC: string | null structure_order_etc: string | null
INSTALLATION_AVAILABILITY: string | null installation_availability: number | null
INSTALLATION_AVAILABILITY_ETC: string | null installation_availability_etc: string | null
MEMO: string | null memo: string | null
REG_DT: Date created_at: Date
UPT_DT: Date updated_at: Date
} }
export type SurveyBasicRequest = { export type SurveyBasicRequest = {
REPRESENTATIVE: string representative: string
STORE: string | null store: string | null
CONSTRUCTION_POINT: string | null construction_point: string | null
INVESTIGATION_DATE: string | null investigation_date: string | null
BUILDING_NAME: string | null building_name: string | null
CUSTOMER_NAME: string | null customer_name: string | null
POST_CODE: string | null post_code: string | null
ADDRESS: string | null address: string | null
ADDRESS_DETAIL: string | null address_detail: string | null
SUBMISSION_STATUS: boolean submission_status: boolean
SUBMISSION_DATE: string | null submission_date: string | null
} }
export type SurveyDetailRequest = { export type SurveyDetailRequest = {
CONTRACT_CAPACITY: string | null contract_capacity: string | null
RETAIL_COMPANY: string | null retail_company: string | null
SUPPLEMENTARY_FACILITIES: string | null // number 배열 supplementary_facilities: string | null // number 배열
SUPPLEMENTARY_FACILITIES_ETC: string | null supplementary_facilities_etc: string | null
INSTALLATION_SYSTEM: string | null installation_system: number | null
INSTALLATION_SYSTEM_ETC: string | null installation_system_etc: string | null
CONSTRUCTION_YEAR: string | null construction_year: number | null
CONSTRUCTION_YEAR_ETC: string | null construction_year_etc: string | null
ROOF_MATERIAL: string | null // number 배열 roof_material: string | null // number 배열
ROOF_MATERIAL_ETC: string | null roof_material_etc: string | null
ROOF_SHAPE: string | null roof_shape: number | null
ROOF_SHAPE_ETC: string | null roof_shape_etc: string | null
ROOF_SLOPE: string | null roof_slope: string | null
HOUSE_STRUCTURE: string | null house_structure: number | null
HOUSE_STRUCTURE_ETC: string | null house_structure_etc: string | null
RAFTER_MATERIAL: string | null rafter_material: number | null
RAFTER_MATERIAL_ETC: string | null rafter_material_etc: string | null
RAFTER_SIZE: string | null rafter_size: number | null
RAFTER_SIZE_ETC: string | null rafter_size_etc: string | null
RAFTER_PITCH: string | null rafter_pitch: number | null
RAFTER_PITCH_ETC: string | null rafter_pitch_etc: string | null
RAFTER_DIRECTION: string | null rafter_direction: number | null
OPEN_FIELD_PLATE_KIND: string | null open_field_plate_kind: number | null
OPEN_FIELD_PLATE_KIND_ETC: string | null open_field_plate_kind_etc: string | null
OPEN_FIELD_PLATE_THICKNESS: string | null open_field_plate_thickness: string | null
LEAK_TRACE: boolean | null leak_trace: boolean | null
WATERPROOF_MATERIAL: string | null waterproof_material: number | null
WATERPROOF_MATERIAL_ETC: string | null waterproof_material_etc: string | null
INSULATION_PRESENCE: string | null insulation_presence: number | null
INSULATION_PRESENCE_ETC: string | null insulation_presence_etc: string | null
STRUCTURE_ORDER: string | null structure_order: number | null
STRUCTURE_ORDER_ETC: string | null structure_order_etc: string | null
INSTALLATION_AVAILABILITY: string | null installation_availability: number | null
INSTALLATION_AVAILABILITY_ETC: string | null installation_availability_etc: string | null
MEMO: string | null memo: string | null
} }
export type SurveyDetailCoverRequest = { export type SurveyDetailCoverRequest = {
DETAIL_INFO: SurveyDetailRequest detail_info: SurveyDetailRequest
} }

View File

@ -1,7 +0,0 @@
export const confirmParamsSerialize = ({ msg, yes, no }: { msg: string; yes: () => void; no: () => void }) => {
return JSON.stringify({ msg, yes, no })
}
export const confirmParamsDeserialize = (params: string) => {
return JSON.parse(params)
}