feature/survey : 조사매물 오류 해결 및 변경사항 적용 #49
@ -2,13 +2,13 @@ NEXT_PUBLIC_RUN_MODE=development
|
||||
# 모바일 디바이스로 로컬 서버 확인하려면 자신 IP 주소로 변경
|
||||
# 다시 로컬에서 개발할때는 localhost로 변경
|
||||
#route handler
|
||||
NEXT_PUBLIC_API_URL=http://localhost:3000
|
||||
NEXT_PUBLIC_API_URL=http://172.30.1.65:3000
|
||||
|
||||
#qsp 로그인 api
|
||||
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
|
||||
NEXT_PUBLIC_INQUIRY_API_URL=http://172.23.4.129:8110
|
||||
|
||||
#QPARTNER 로그인 api
|
||||
DB_HOST=202.218.61.226
|
||||
|
||||
@ -2,13 +2,13 @@ NEXT_PUBLIC_RUN_MODE=local
|
||||
# 모바일 디바이스로 로컬 서버 확인하려면 자신 IP 주소로 변경
|
||||
# 다시 로컬에서 개발할때는 localhost로 변경
|
||||
#route handler
|
||||
NEXT_PUBLIC_API_URL=http://localhost:3000
|
||||
NEXT_PUBLIC_API_URL=http://172.30.1.65:3000
|
||||
|
||||
#qsp 로그인 api
|
||||
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
|
||||
NEXT_PUBLIC_INQUIRY_API_URL=http://172.23.4.129:8110
|
||||
|
||||
#QPARTNER 로그인 api
|
||||
DB_HOST=202.218.61.226
|
||||
|
||||
@ -6,7 +6,7 @@ NEXT_PUBLIC_API_URL=http://1.248.227.176:3000
|
||||
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
|
||||
NEXT_PUBLIC_INQUIRY_API_URL=http://172.23.4.129:8110
|
||||
|
||||
#QPARTNER 로그인 api
|
||||
DB_HOST=202.218.61.226
|
||||
|
||||
@ -19,15 +19,16 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
|
||||
}
|
||||
}
|
||||
|
||||
const getNewSrlNo = async (srlNo: string, storeId: string) => {
|
||||
const getNewSrlNo = async (srlNo: string, storeId: string, role: string) => {
|
||||
const srlRole = role === 'T01' || role === 'Admin' ? 'HO' : role === 'Admin_Sub' || role === 'Builder' ? 'HM' : ''
|
||||
|
||||
let newSrlNo = srlNo
|
||||
console.log('srlNo:: ', srlNo)
|
||||
if (srlNo.startsWith('一時保存')) {
|
||||
//@ts-ignore
|
||||
const lastSurvey = await prisma.SD_SURVEY_SALES_BASIC_INFO.findFirst({
|
||||
where: {
|
||||
SRL_NO: {
|
||||
startsWith: storeId,
|
||||
startsWith: srlRole + storeId,
|
||||
},
|
||||
},
|
||||
orderBy: {
|
||||
@ -35,7 +36,9 @@ const getNewSrlNo = async (srlNo: string, storeId: string) => {
|
||||
},
|
||||
})
|
||||
const lastNo = lastSurvey ? parseInt(lastSurvey.SRL_NO.slice(-3)) : 0
|
||||
|
||||
newSrlNo =
|
||||
srlRole +
|
||||
storeId +
|
||||
new Date().getFullYear().toString().slice(-2) +
|
||||
(new Date().getMonth() + 1).toString().padStart(2, '0') +
|
||||
@ -52,7 +55,7 @@ export async function PUT(request: NextRequest, { params }: { params: Promise<{
|
||||
const { detailInfo, ...basicInfo } = body.survey
|
||||
|
||||
// PUT 요청 시 임시저장 여부 확인 후 임시저장 시 기존 SRL_NO 사용, 기본 저장 시 새로운 SRL_NO 생성
|
||||
const newSrlNo = body.isTemporary ? body.survey.srlNo : await getNewSrlNo(body.survey.srlNo, body.storeId)
|
||||
const newSrlNo = body.isTemporary ? body.survey.srlNo : await getNewSrlNo(body.survey.srlNo, body.storeId, body.role)
|
||||
// @ts-ignore
|
||||
const survey = await prisma.SD_SURVEY_SALES_BASIC_INFO.update({
|
||||
where: { ID: Number(id) },
|
||||
@ -113,9 +116,6 @@ export async function PATCH(request: NextRequest, { params }: { params: Promise<
|
||||
const { id } = await params
|
||||
const body = await request.json()
|
||||
|
||||
// 제출 시 기존 SRL_NO 확인 후 '임시저장'으로 시작하면 새로운 SRL_NO 생성
|
||||
const newSrlNo = await getNewSrlNo(body.srlNo, body.storeId)
|
||||
|
||||
if (body.targetId) {
|
||||
// @ts-ignore
|
||||
const survey = await prisma.SD_SURVEY_SALES_BASIC_INFO.update({
|
||||
@ -125,11 +125,9 @@ export async function PATCH(request: NextRequest, { params }: { params: Promise<
|
||||
SUBMISSION_DATE: new Date(),
|
||||
SUBMISSION_TARGET_ID: body.targetId,
|
||||
UPT_DT: new Date(),
|
||||
SRL_NO: newSrlNo,
|
||||
},
|
||||
})
|
||||
console.log(survey)
|
||||
return NextResponse.json({ message: 'Survey confirmed successfully' })
|
||||
return NextResponse.json({ message: 'Survey confirmed successfully', data: survey })
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error updating survey:', error)
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import { NextResponse } from 'next/server'
|
||||
import { prisma } from '@/libs/prisma'
|
||||
import { convertToSnakeCase } from '@/utils/common-utils'
|
||||
import { equal } from 'assert'
|
||||
/**
|
||||
* 검색 파라미터
|
||||
*/
|
||||
@ -32,6 +31,7 @@ const SEARCH_OPTIONS = [
|
||||
'POST_CODE', // 우편번호
|
||||
'ADDRESS', // 주소
|
||||
'ADDRESS_DETAIL', // 상세주소
|
||||
'SRL_NO', // 등록번호
|
||||
] as const
|
||||
|
||||
// 페이지당 항목 수
|
||||
@ -50,13 +50,6 @@ const createKeywordSearchCondition = (keyword: string, searchOption: string): Wh
|
||||
// 모든 필드 검색 시 OR 조건 사용
|
||||
where.OR = []
|
||||
|
||||
// ID가 숫자인 경우 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 },
|
||||
@ -65,15 +58,6 @@ const createKeywordSearchCondition = (keyword: string, searchOption: string): Wh
|
||||
} else if (SEARCH_OPTIONS.includes(searchOption.toUpperCase() as any)) {
|
||||
// 특정 필드 검색
|
||||
where[searchOption.toUpperCase()] = { contains: keyword }
|
||||
} else if (searchOption === 'id') {
|
||||
// ID 검색 (숫자 변환 필요)
|
||||
const number = Number(keyword)
|
||||
if (!isNaN(number)) {
|
||||
where.ID = { equals: number }
|
||||
} else {
|
||||
// 유효하지 않은 ID 검색 시 빈 결과 반환
|
||||
where.ID = { equals: null }
|
||||
}
|
||||
}
|
||||
return where
|
||||
}
|
||||
@ -91,7 +75,7 @@ const createMemberRoleCondition = (params: SearchParams): WhereCondition => {
|
||||
where.OR = [
|
||||
{
|
||||
// 같은 판매점에서 작성한 제출/제출되지 않은 매물
|
||||
AND: [{ STORE: { equals: params.store } }],
|
||||
AND: [{ STORE_ID: { equals: params.store } }],
|
||||
},
|
||||
{
|
||||
// MUSUBI (시공권한 X) 가 ORDER 에 제출한 매물
|
||||
@ -105,7 +89,7 @@ const createMemberRoleCondition = (params: SearchParams): WhereCondition => {
|
||||
{
|
||||
// MUSUBI (시공권한 X) 같은 판매점에서 작성한 제출/제출되지 않은 매물
|
||||
AND: [
|
||||
{ STORE: { equals: params.store } },
|
||||
{ STORE_ID: { equals: params.store } },
|
||||
{
|
||||
OR: [{ CONSTRUCTION_POINT: { equals: null } }, { CONSTRUCTION_POINT: { equals: '' } }],
|
||||
},
|
||||
@ -125,9 +109,10 @@ const createMemberRoleCondition = (params: SearchParams): WhereCondition => {
|
||||
|
||||
case 'Builder': // MUSUBI (시공권한 O)
|
||||
case 'Partner': // PARTNER
|
||||
// 같은 시공ID에서 작성된 매물
|
||||
// 시공점이 있고 STORE_ID가 시공ID와 같은 매물
|
||||
where.AND?.push({
|
||||
CONSTRUCTION_POINT: { equals: params.builderNo },
|
||||
CONSTRUCTION_POINT: { not: null },
|
||||
STORE_ID: { equals: params.builderNo },
|
||||
})
|
||||
break
|
||||
|
||||
@ -141,7 +126,7 @@ const createMemberRoleCondition = (params: SearchParams): WhereCondition => {
|
||||
},
|
||||
},
|
||||
{
|
||||
STORE: {
|
||||
STORE_ID: {
|
||||
equals: params.store,
|
||||
},
|
||||
},
|
||||
@ -165,11 +150,11 @@ export async function GET(request: Request) {
|
||||
const params: SearchParams = {
|
||||
keyword: searchParams.get('keyword'),
|
||||
searchOption: searchParams.get('searchOption'),
|
||||
isMySurvey: searchParams.get('isMySurvey'),
|
||||
isMySurvey: searchParams.get('isMySurvey'), //representativeId
|
||||
sort: searchParams.get('sort'),
|
||||
offset: searchParams.get('offset'),
|
||||
role: searchParams.get('role'),
|
||||
store: searchParams.get('store'),
|
||||
store: searchParams.get('store'), //storeId
|
||||
builderNo: searchParams.get('builderNo'),
|
||||
}
|
||||
|
||||
@ -178,7 +163,7 @@ export async function GET(request: Request) {
|
||||
|
||||
// 내가 작성한 매물 조건 적용
|
||||
if (params.isMySurvey) {
|
||||
where.AND.push({ REPRESENTATIVE: params.isMySurvey })
|
||||
where.AND.push({ REPRESENTATIVE_ID: params.isMySurvey })
|
||||
}
|
||||
|
||||
// 키워드 검색 조건 적용
|
||||
@ -242,11 +227,21 @@ export async function POST(request: Request) {
|
||||
try {
|
||||
const body = await request.json()
|
||||
|
||||
// 임시 저장 시 임시저장 + 000 으로 저장
|
||||
// 기본 저장 시 판매점ID + yyMMdd + 000 으로 저장
|
||||
const role =
|
||||
body.role === 'T01' || body.role === 'Admin'
|
||||
? 'HO'
|
||||
: body.role === 'Admin_Sub' || body.role === 'Builder'
|
||||
? 'HM'
|
||||
: body.role === 'Partner'
|
||||
? ''
|
||||
: null
|
||||
|
||||
// 임시 저장 시 임시저장으로 저장
|
||||
// 기본 저장 시 (HO/HM) + 판매점ID + yyMMdd + 000 으로 저장
|
||||
const baseSrlNo =
|
||||
body.survey.srlNo ??
|
||||
body.storeId +
|
||||
role +
|
||||
body.storeId +
|
||||
new Date().getFullYear().toString().slice(-2) +
|
||||
(new Date().getMonth() + 1).toString().padStart(2, '0') +
|
||||
new Date().getDate().toString().padStart(2, '0')
|
||||
@ -255,7 +250,7 @@ export async function POST(request: Request) {
|
||||
const lastSurvey = await prisma.SD_SURVEY_SALES_BASIC_INFO.findFirst({
|
||||
where: {
|
||||
SRL_NO: {
|
||||
startsWith: body.storeId,
|
||||
startsWith: role + body.storeId,
|
||||
},
|
||||
},
|
||||
orderBy: {
|
||||
|
||||
151
src/components/popup/SurveySaleSubmitPopup.tsx
Normal file
151
src/components/popup/SurveySaleSubmitPopup.tsx
Normal file
@ -0,0 +1,151 @@
|
||||
import Image from 'next/image'
|
||||
import { usePopupController } from '@/store/popupController'
|
||||
import { useParams } from 'next/navigation'
|
||||
import { useServey } from '@/hooks/useSurvey'
|
||||
import { useState } from 'react'
|
||||
import { useSessionStore } from '@/store/session'
|
||||
|
||||
interface SubmitFormData {
|
||||
store: string
|
||||
sender: string
|
||||
receiver: string
|
||||
reference: string
|
||||
title: string
|
||||
contents: string
|
||||
}
|
||||
|
||||
interface FormField {
|
||||
id: keyof SubmitFormData
|
||||
name: string
|
||||
required: boolean
|
||||
}
|
||||
|
||||
const FORM_FIELDS: FormField[] = [
|
||||
{ id: 'store', name: '提出販売店', required: true },
|
||||
{ id: 'sender', name: '発送者', required: true },
|
||||
{ id: 'receiver', name: '受信者', required: true },
|
||||
{ id: 'reference', name: '参考', required: false },
|
||||
{ id: 'title', name: 'タイトル', required: true },
|
||||
{ id: 'contents', name: '内容', required: true },
|
||||
]
|
||||
|
||||
export default function SurveySaleSubmitPopup() {
|
||||
const popupController = usePopupController()
|
||||
const { session } = useSessionStore()
|
||||
const params = useParams()
|
||||
const routeId = params.id
|
||||
|
||||
const [submitData, setSubmitData] = useState<SubmitFormData>({
|
||||
store: '',
|
||||
sender: session?.email ?? '',
|
||||
receiver: '',
|
||||
reference: '',
|
||||
title: '[HANASYS現地調査] 調査物件が提出.',
|
||||
contents: '',
|
||||
})
|
||||
|
||||
const { submitSurvey, isSubmittingSurvey } = useServey(Number(routeId))
|
||||
|
||||
const handleInputChange = (field: keyof SubmitFormData, value: string) => {
|
||||
setSubmitData((prev) => ({ ...prev, [field]: value }))
|
||||
}
|
||||
|
||||
const validateData = (data: SubmitFormData): boolean => {
|
||||
const requiredFields = FORM_FIELDS.filter((field) => field.required)
|
||||
|
||||
for (const field of requiredFields) {
|
||||
if (!data[field.id].trim()) {
|
||||
const element = document.getElementById(field.id)
|
||||
if (element) {
|
||||
element.focus()
|
||||
}
|
||||
alert(`${field.name}は必須入力項目です。`)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
const handleSubmit = () => {
|
||||
if (validateData(submitData)) {
|
||||
window.neoConfirm('送信しますか? 送信後は変更・修正することはできません。', () => {
|
||||
submitSurvey({ targetId: submitData.store })
|
||||
if (!isSubmittingSurvey) {
|
||||
popupController.setSurveySaleSubmitPopup(false)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const handleClose = () => {
|
||||
popupController.setSurveySaleSubmitPopup(false)
|
||||
}
|
||||
|
||||
const renderFormField = (field: FormField) => {
|
||||
// const isReadOnly = (field.id === 'store' && session?.role !== 'Partner') || (field.id === 'receiver' && session?.role !== 'Partner')
|
||||
const isReadOnly = false
|
||||
|
||||
return (
|
||||
<div className="data-input-form-bx" key={field.id}>
|
||||
<div className="data-input-form-tit">
|
||||
{field.name} {field.required && <i className="import">*</i>}
|
||||
</div>
|
||||
<div className="data-input">
|
||||
{field.id === 'contents' ? (
|
||||
<textarea
|
||||
className="textarea-form"
|
||||
id={field.id}
|
||||
value={submitData[field.id]}
|
||||
onChange={(e) => handleInputChange(field.id, e.target.value)}
|
||||
/>
|
||||
) : (
|
||||
<input
|
||||
className="input-frame"
|
||||
type="text"
|
||||
id={field.id}
|
||||
value={submitData[field.id]}
|
||||
onChange={(e) => handleInputChange(field.id, e.target.value)}
|
||||
readOnly={isReadOnly}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="modal-popup">
|
||||
<div className="modal-dialog">
|
||||
<div className="modal-content">
|
||||
<div className="modal-header">
|
||||
<div className="modal-header-inner">
|
||||
<div className="modal-name-wrap">
|
||||
<div className="modal-img">
|
||||
<Image src="/assets/images/layout/modal_header_icon04.svg" width={19} height={22} alt="" />
|
||||
</div>
|
||||
<div className="modal-name">調査物件の提出</div>
|
||||
</div>
|
||||
<button className="modal-close" onClick={handleClose}></button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="modal-body">
|
||||
<div className="data-form-wrap">{FORM_FIELDS.map(renderFormField)}</div>
|
||||
<div className="btn-flex-wrap">
|
||||
<div className="btn-bx">
|
||||
<button className="btn-frame n-blue icon" onClick={handleClose}>
|
||||
閉じる<i className="btn-arr"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div className="btn-bx">
|
||||
<button className="btn-frame red icon" onClick={handleSubmit} disabled={isSubmittingSurvey}>
|
||||
転送<i className="btn-arr"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@ -18,21 +18,17 @@ type Address = {
|
||||
|
||||
export default function ZipCodePopup() {
|
||||
const [searchValue, setSearchValue] = useState('') //search 데이터 유무
|
||||
const [selected, setSelected] = useState('')
|
||||
const { setAddressData } = useAddressStore()
|
||||
const { getZipCode } = useServey()
|
||||
const [addressInfo, setAddressInfo] = useState<Address[] | null>([])
|
||||
|
||||
//search 데이터 value 추가
|
||||
|
||||
const popupController = usePopupController()
|
||||
|
||||
const handleApply = () => {
|
||||
console.log(addressInfo?.[0])
|
||||
const handleApply = (item: Address) => {
|
||||
setAddressData({
|
||||
post_code: addressInfo?.[0]?.zipcode || '',
|
||||
address: addressInfo?.[0]?.address1 || '',
|
||||
address_detail: addressInfo?.[0]?.address2 + ' ' + addressInfo?.[0]?.address3 || '',
|
||||
post_code: item.zipcode || '',
|
||||
address: item.address1 || '',
|
||||
address_detail: item.address2 + ' ' + item.address3 || '',
|
||||
})
|
||||
popupController.setZipCodePopup(false)
|
||||
}
|
||||
@ -71,7 +67,18 @@ export default function ZipCodePopup() {
|
||||
<div className="zip-code-search-wrap">
|
||||
<div className="zip-code-search-input">
|
||||
<div className="search-input">
|
||||
<input type="text" className="search-frame" value={searchValue} placeholder="Search" onChange={handleChange} />
|
||||
<input
|
||||
type="text"
|
||||
className="search-frame"
|
||||
value={searchValue}
|
||||
placeholder="Search"
|
||||
onChange={handleChange}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter') {
|
||||
handleSearch()
|
||||
}
|
||||
}}
|
||||
/>
|
||||
{/*input에 데이터 있으면 삭제버튼 보임 */}
|
||||
{searchValue && <button className="del-icon" onClick={() => setSearchValue('')}></button>}
|
||||
<button className="search-icon" onClick={handleSearch}></button>
|
||||
@ -89,7 +96,12 @@ export default function ZipCodePopup() {
|
||||
</thead>
|
||||
<tbody>
|
||||
{addressInfo?.map((item, index) => (
|
||||
<tr key={`${item.zipcode}-${index}`} onClick={() => setSelected(item.zipcode)}>
|
||||
<tr
|
||||
key={`${item.zipcode}-${index}`}
|
||||
onClick={() => {
|
||||
handleApply(item)
|
||||
}}
|
||||
>
|
||||
<td>{item.address1}</td>
|
||||
<td>{item.address2}</td>
|
||||
<td>{item.address3}</td>
|
||||
@ -97,18 +109,6 @@ export default function ZipCodePopup() {
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
<div className="btn-flex-wrap">
|
||||
<div className="btn-bx">
|
||||
<button className="btn-frame red icon" onClick={handleApply}>
|
||||
住所の適用<i className="btn-arr"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div className="btn-bx">
|
||||
<button className="btn-frame n-blue icon" onClick={() => popupController.setZipCodePopup(false)}>
|
||||
閉じる<i className="btn-arr"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -20,12 +20,16 @@ export default function BasicForm(props: { basicInfo: SurveyBasicRequest; setBas
|
||||
setBasicInfoSelected()
|
||||
}, [])
|
||||
|
||||
// 시공권한 user(Builder), Partner 계정은 조사매물 등록 할 때 STORE_ID에 시공점ID가 들어감
|
||||
// 권한 별 목록 필터링 시 시공권한 user(Builder), Partner는 시공점ID가 같은 것들만 조회
|
||||
useEffect(() => {
|
||||
if (session?.isLoggedIn) {
|
||||
setBasicInfo({
|
||||
...basicInfo,
|
||||
representative: session.userNm ?? '',
|
||||
representativeId: session.userId ?? null,
|
||||
store: session.role === 'Partner' ? null : session.storeNm ?? null,
|
||||
storeId: session.role === 'Partner' || session.role === 'Builder' ? session.builderNo : session.storeId ?? null,
|
||||
constructionPoint: session.builderNo ?? null,
|
||||
})
|
||||
}
|
||||
@ -137,7 +141,7 @@ export default function BasicForm(props: { basicInfo: SurveyBasicRequest; setBas
|
||||
<div className="form-flex">
|
||||
{/* 우편번호 */}
|
||||
<div className="form-bx">
|
||||
<input type="text" className="input-frame" readOnly={mode === 'READ'} defaultValue={basicInfo?.postCode ?? ''} disabled />
|
||||
<input type="text" className="input-frame" readOnly={true} defaultValue={basicInfo?.postCode ?? ''} />
|
||||
</div>
|
||||
{/* 도도부현 */}
|
||||
<div className="form-bx">
|
||||
@ -145,11 +149,13 @@ export default function BasicForm(props: { basicInfo: SurveyBasicRequest; setBas
|
||||
</div>
|
||||
</div>
|
||||
{/* 주소 */}
|
||||
<div className="form-btn">
|
||||
<button className="btn-frame n-blue icon" onClick={() => popupController.setZipCodePopup(true)}>
|
||||
郵便番号<i className="btn-arr"></i>
|
||||
</button>
|
||||
</div>
|
||||
{mode !== 'READ' && (
|
||||
<div className="form-btn">
|
||||
<button className="btn-frame n-blue icon" onClick={() => popupController.setZipCodePopup(true)}>
|
||||
郵便番号<i className="btn-arr"></i>
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="data-input-form-bx">
|
||||
|
||||
@ -5,6 +5,7 @@ import { useSessionStore } from '@/store/session'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useParams, useRouter, useSearchParams } from 'next/navigation'
|
||||
import { requiredFields, useServey } from '@/hooks/useSurvey'
|
||||
import { usePopupController } from '@/store/popupController'
|
||||
|
||||
export default function ButtonForm(props: {
|
||||
mode: Mode
|
||||
@ -22,14 +23,12 @@ export default function ButtonForm(props: {
|
||||
const params = useParams()
|
||||
const routeId = params.id
|
||||
|
||||
const popupController = usePopupController()
|
||||
// ------------------------------------------------------------
|
||||
const [saveData, setSaveData] = useState({
|
||||
...props.data.basic,
|
||||
detailInfo: props.data.roof,
|
||||
})
|
||||
|
||||
// !!!!!!!!!!
|
||||
const [tempTargetId, setTempTargetId] = useState('')
|
||||
// --------------------------------------------------------------
|
||||
// 권한
|
||||
|
||||
@ -73,8 +72,8 @@ export default function ButtonForm(props: {
|
||||
// 저장/임시저장/수정
|
||||
const id = Number(routeId) ? Number(routeId) : Number(idParam)
|
||||
|
||||
const { deleteSurvey, submitSurvey, updateSurvey } = useServey(Number(id))
|
||||
const { validateSurveyDetail, createSurvey } = useServey()
|
||||
const { deleteSurvey, updateSurvey, isDeletingSurvey, isUpdatingSurvey } = useServey(Number(id))
|
||||
const { validateSurveyDetail, createSurvey, isCreatingSurvey } = useServey()
|
||||
|
||||
const handleSave = (isTemporary: boolean, isSubmitProcess = false) => {
|
||||
const emptyField = validateSurveyDetail(props.data.roof)
|
||||
@ -112,35 +111,19 @@ export default function ButtonForm(props: {
|
||||
const saveProcess = async (emptyField: string | null, isSubmitProcess?: boolean) => {
|
||||
if (emptyField?.trim() === '') {
|
||||
if (idParam) {
|
||||
if (isSubmitProcess) {
|
||||
const updatedData = {
|
||||
...saveData,
|
||||
submissionStatus: true,
|
||||
submissionDate: new Date().toISOString(),
|
||||
submissionTargetId: tempTargetId,
|
||||
}
|
||||
await updateSurvey({ survey: updatedData, isTemporary: false, storeId: session.storeId ?? '' })
|
||||
router.push(`/survey-sale/${idParam}`)
|
||||
} else {
|
||||
await updateSurvey({ survey: saveData, isTemporary: false, storeId: session.storeId ?? '' })
|
||||
router.push(`/survey-sale/${idParam}`)
|
||||
await updateSurvey({ survey: saveData, isTemporary: false, storeId: session.storeId ?? '' })
|
||||
router.push(`/survey-sale/${idParam}`)
|
||||
} else {
|
||||
const id = await createSurvey(saveData)
|
||||
router.push(`/survey-sale/${id}`)
|
||||
}
|
||||
if (isSubmitProcess) {
|
||||
if (!isCreatingSurvey && !isUpdatingSurvey) {
|
||||
popupController.setSurveySaleSubmitPopup(true)
|
||||
}
|
||||
} else {
|
||||
if (isSubmitProcess) {
|
||||
const updatedData = {
|
||||
...saveData,
|
||||
submissionStatus: true,
|
||||
submissionDate: new Date().toISOString(),
|
||||
submissionTargetId: tempTargetId,
|
||||
}
|
||||
const id = await createSurvey(updatedData)
|
||||
submitProcess(id)
|
||||
} else {
|
||||
const id = await createSurvey(saveData)
|
||||
router.push(`/survey-sale/${id}`)
|
||||
}
|
||||
alert('保存されました。')
|
||||
}
|
||||
alert('保存されました。')
|
||||
} else {
|
||||
if (emptyField?.includes('Unit')) {
|
||||
alert('電気契約容量の単位を入力してください。')
|
||||
@ -158,34 +141,30 @@ export default function ButtonForm(props: {
|
||||
if (routeId) {
|
||||
window.neoConfirm('削除しますか?', async () => {
|
||||
await deleteSurvey()
|
||||
router.push('/survey-sale')
|
||||
if (!isDeletingSurvey) {
|
||||
alert('削除されました。')
|
||||
router.push('/survey-sale')
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if (props.data.basic.srlNo?.startsWith('一時保存')) {
|
||||
if (props.data.basic.srlNo?.startsWith('一時保存') && Number(routeId)) {
|
||||
alert('一時保存されたデータは提出できません。')
|
||||
return
|
||||
}
|
||||
if (tempTargetId.trim() === '') {
|
||||
alert('提出対象店舗を入力してください。')
|
||||
return
|
||||
}
|
||||
window.neoConfirm('提出しますか?', async () => {
|
||||
if (Number(routeId)) {
|
||||
submitProcess()
|
||||
} else {
|
||||
if (Number(routeId)) {
|
||||
window.neoConfirm('提出しますか?', async () => {
|
||||
popupController.setSurveySaleSubmitPopup(true)
|
||||
})
|
||||
} else {
|
||||
window.neoConfirm('記入した情報を保存して送信しますか?', async () => {
|
||||
handleSave(false, true)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const submitProcess = async (saveId?: number) => {
|
||||
await submitSurvey({ saveId: saveId, targetId: tempTargetId, storeId: session.storeId ?? '', srlNo: '一時保存' })
|
||||
alert('提出されました。')
|
||||
router.push('/survey-sale')
|
||||
}
|
||||
// ------------------------------------------------------------
|
||||
|
||||
if (mode === 'READ' && isSubmit && isSubmiter) {
|
||||
@ -208,7 +187,7 @@ export default function ButtonForm(props: {
|
||||
<ListButton />
|
||||
<EditButton setMode={setMode} id={id.toString()} mode={mode} />
|
||||
{(isWriter || !isSubmiter) && <DeleteButton handleDelete={handleDelete} />}
|
||||
{!isSubmit && isSubmiter && <SubmitButton handleSubmit={handleSubmit} setTempTargetId={setTempTargetId} />}
|
||||
{!isSubmit && isSubmiter && <SubmitButton handleSubmit={handleSubmit} />}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
@ -219,7 +198,7 @@ export default function ButtonForm(props: {
|
||||
<ListButton />
|
||||
<TempButton setMode={setMode} handleSave={handleSave} />
|
||||
<SaveButton handleSave={handleSave} />
|
||||
{session?.role !== 'T01' && <SubmitButton handleSubmit={handleSubmit} setTempTargetId={setTempTargetId} />}{' '}
|
||||
{session?.role !== 'T01' && <SubmitButton handleSubmit={handleSubmit} />}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
@ -259,8 +238,8 @@ function EditButton(props: { setMode: (mode: Mode) => void; id: string; mode: Mo
|
||||
)
|
||||
}
|
||||
|
||||
function SubmitButton(props: { handleSubmit: () => void; setTempTargetId: (targetId: string) => void }) {
|
||||
const { handleSubmit, setTempTargetId } = props
|
||||
function SubmitButton(props: { handleSubmit: () => void }) {
|
||||
const { handleSubmit } = props
|
||||
return (
|
||||
<>
|
||||
<div className="btn-bx">
|
||||
@ -269,9 +248,6 @@ function SubmitButton(props: { handleSubmit: () => void; setTempTargetId: (targe
|
||||
提出<i className="btn-arr"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div>
|
||||
<input type="text" placeholder="temp target id" onChange={(e) => setTempTargetId(e.target.value)} />
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
@ -54,9 +54,10 @@ export default function DataTable() {
|
||||
<td>
|
||||
{surveyDetail?.submissionStatus && surveyDetail?.submissionDate ? (
|
||||
<>
|
||||
{/* TODO: 제출한 판매점 ID 추가 필요 */}
|
||||
<div>{new Date(surveyDetail.submissionDate).toLocaleString()}</div>
|
||||
<div>{surveyDetail.store}</div>
|
||||
<div>
|
||||
({surveyDetail.store} - {surveyDetail.storeId})
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
'-'
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
'use client'
|
||||
|
||||
import type { Mode, SurveyBasicInfo, SurveyBasicRequest, SurveyDetailRequest } from '@/types/Survey'
|
||||
import type { Mode, SurveyBasicRequest, SurveyDetailRequest } from '@/types/Survey'
|
||||
import { useEffect, useState } from 'react'
|
||||
import ButtonForm from './ButtonForm'
|
||||
import BasicForm from './BasicForm'
|
||||
import RoofForm from './RoofForm'
|
||||
import { useParams, useRouter, useSearchParams } from 'next/navigation'
|
||||
import { useParams, useSearchParams } from 'next/navigation'
|
||||
import { useServey } from '@/hooks/useSurvey'
|
||||
|
||||
const roofInfoForm: SurveyDetailRequest = {
|
||||
@ -48,7 +48,9 @@ const roofInfoForm: SurveyDetailRequest = {
|
||||
|
||||
const basicInfoForm: SurveyBasicRequest = {
|
||||
representative: '',
|
||||
representativeId: null,
|
||||
store: null,
|
||||
storeId: null,
|
||||
constructionPoint: null,
|
||||
investigationDate: new Date().toLocaleDateString('en-CA'),
|
||||
buildingName: null,
|
||||
|
||||
@ -265,11 +265,12 @@ export default function RoofForm(props: {
|
||||
<div className="data-input-form-bx">
|
||||
{/* 전기 계약 용량 */}
|
||||
<div className="data-input-form-tit">電気契約容量</div>
|
||||
{mode === 'READ' && <input type="text" className="input-frame" value={roofInfo?.contractCapacity ?? ''} disabled={mode === 'READ'} />}
|
||||
{mode === 'READ' && <input type="text" className="input-frame" value={roofInfo?.contractCapacity ?? ''} readOnly={mode === 'READ'} />}
|
||||
{mode !== 'READ' && (
|
||||
<div className="data-input mb5">
|
||||
<input
|
||||
type="number"
|
||||
inputMode="numeric"
|
||||
id="contractCapacity"
|
||||
className="input-frame"
|
||||
value={roofInfo?.contractCapacity?.split(' ')[0] ?? ''}
|
||||
@ -343,11 +344,13 @@ export default function RoofForm(props: {
|
||||
</div>
|
||||
</div>
|
||||
<div className="data-input-form-bx">
|
||||
{/* 지붕 경사도도 */}
|
||||
{/* 지붕 경사도 */}
|
||||
<div className="data-input-form-tit">屋根の斜面</div>
|
||||
<div className="data-input flex">
|
||||
<input
|
||||
type="number"
|
||||
inputMode="numeric"
|
||||
id="roofSlope"
|
||||
className="input-frame"
|
||||
value={roofInfo?.roofSlope ?? ''}
|
||||
disabled={mode === 'READ'}
|
||||
@ -388,28 +391,32 @@ export default function RoofForm(props: {
|
||||
</div>
|
||||
</div>
|
||||
<div className="data-input-form-bx">
|
||||
{/* 노지판 종류류 */}
|
||||
{/* 노지판 종류 */}
|
||||
<div className="data-input-form-tit">路地板の種類</div>
|
||||
<div className="data-input mb5">
|
||||
<SelectedBox mode={mode} column="openFieldPlateKind" detailInfoData={roofInfo as SurveyDetailInfo} setRoofInfo={setRoofInfo} />
|
||||
</div>
|
||||
</div>
|
||||
<div className="data-input-form-bx">
|
||||
{/* 노지판 두께 */}
|
||||
<div className="data-input-form-tit">
|
||||
路地板厚<span>※小幅板を選択した場合, 厚さ. 小幅板間の間隔寸法を記載</span>
|
||||
{roofInfo.openFieldPlateKind === '4' && (
|
||||
<div className="data-input-form-bx">
|
||||
{/* 노지판 두께 */}
|
||||
<div className="data-input-form-tit">
|
||||
路地板厚<span>※小幅板を選択した場合, 厚さ. 小幅板間の間隔寸法を記載</span>
|
||||
</div>
|
||||
<div className="data-input flex">
|
||||
<input
|
||||
type="number"
|
||||
inputMode="numeric"
|
||||
id="openFieldPlateThickness"
|
||||
className="input-frame"
|
||||
value={roofInfo?.openFieldPlateThickness ?? ''}
|
||||
disabled={mode === 'READ'}
|
||||
onChange={(e) => handleNumberInput('openFieldPlateThickness', e.target.value)}
|
||||
/>
|
||||
<span>mm</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="data-input flex">
|
||||
<input
|
||||
type="text"
|
||||
className="input-frame"
|
||||
value={roofInfo?.openFieldPlateThickness ?? ''}
|
||||
disabled={mode === 'READ'}
|
||||
onChange={(e) => handleNumberInput('openFieldPlateThickness', e.target.value)}
|
||||
/>
|
||||
<span>mm</span>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<div className="data-input-form-bx">
|
||||
{/* 누수 흔적 */}
|
||||
<div className="data-input-form-tit ">水漏れの痕跡</div>
|
||||
@ -516,7 +523,7 @@ const SelectedBox = ({
|
||||
name={column}
|
||||
id={column}
|
||||
disabled={mode === 'READ'}
|
||||
value={selectedId ? Number(selectedId) : etcValue ? 'etc' : ''}
|
||||
value={selectedId ? Number(selectedId) : etcValue || isEtcSelected ? 'etc' : ''}
|
||||
onChange={handleSelectChange}
|
||||
>
|
||||
{selectBoxOptions[column as keyof typeof selectBoxOptions].map((item) => (
|
||||
@ -536,11 +543,12 @@ const SelectedBox = ({
|
||||
<div className={`data-input ${column === 'constructionYear' ? 'flex' : ''}`}>
|
||||
<input
|
||||
type={column === 'constructionYear' ? 'number' : 'text'}
|
||||
inputMode={column === 'constructionYear' ? 'numeric' : 'text'}
|
||||
className="input-frame"
|
||||
placeholder="-"
|
||||
value={detailInfoData[`${column}Etc` as keyof SurveyDetailInfo]?.toString() ?? ''}
|
||||
onChange={handleEtcInputChange}
|
||||
disabled={isInputDisabled()}
|
||||
readOnly={isInputDisabled()}
|
||||
/>
|
||||
{column === 'constructionYear' && <span>年</span>}
|
||||
</div>
|
||||
@ -644,7 +652,7 @@ const RadioSelected = ({
|
||||
placeholder="-"
|
||||
value={detailInfoData[`${column}Etc` as keyof SurveyDetailInfo]?.toString() ?? ''}
|
||||
onChange={handleEtcInputChange}
|
||||
disabled={isInputDisabled()}
|
||||
readOnly={isInputDisabled()}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
@ -678,7 +686,7 @@ const MultiCheck = ({
|
||||
newValue = selectedValues.filter((v) => v !== String(id))
|
||||
} else {
|
||||
if (isRoofMaterial) {
|
||||
const totalSelected = selectedValues.length + (isOtherSelected ? 1 : 0)
|
||||
const totalSelected = selectedValues.length + (isOtherSelected || isOtherCheck ? 1 : 0)
|
||||
if (totalSelected >= 2) {
|
||||
alert('屋根材は最大2個まで選択できます。')
|
||||
return
|
||||
@ -749,7 +757,7 @@ const MultiCheck = ({
|
||||
placeholder="-"
|
||||
value={roofInfo[`${column}Etc` as keyof SurveyDetailInfo]?.toString() ?? ''}
|
||||
onChange={handleOtherInputChange}
|
||||
disabled={isInputDisabled()}
|
||||
readOnly={isInputDisabled()}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
import LoadMoreButton from '@/components/LoadMoreButton'
|
||||
import { useServey } from '@/hooks/useSurvey'
|
||||
import { useEffect, useState, useMemo, useRef } from 'react'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useRouter, usePathname } from 'next/navigation'
|
||||
import SearchForm from './SearchForm'
|
||||
import { useSurveyFilterStore } from '@/store/surveyFilterStore'
|
||||
@ -27,7 +27,7 @@ export default function ListTable() {
|
||||
}, [pathname])
|
||||
|
||||
useEffect(() => {
|
||||
if (!session.isLoggedIn || !('data' in surveyList)) return
|
||||
if (!session.isLoggedIn || isLoadingSurveyList) return
|
||||
if ('count' in surveyList && surveyList.count > 0) {
|
||||
if (offset > 0) {
|
||||
setHeldSurveyList((prev) => [...prev, ...surveyList.data])
|
||||
@ -45,14 +45,12 @@ export default function ListTable() {
|
||||
router.push(`/survey-sale/${id}`)
|
||||
}
|
||||
|
||||
// TODO: 로딩 처리 필요
|
||||
|
||||
return (
|
||||
<>
|
||||
<SearchForm memberRole={session?.role ?? ''} userNm={session?.userNm ?? ''} />
|
||||
<div className="sale-frame">
|
||||
{heldSurveyList.length > 0 ? (
|
||||
<ul className="sale-list-wrap">
|
||||
<SearchForm memberRole={session?.role ?? ''} userId={session?.userId ?? ''} />
|
||||
<div className="sale-frame">
|
||||
{heldSurveyList.length > 0 ? (
|
||||
<ul className="sale-list-wrap">
|
||||
{heldSurveyList.map((survey) => (
|
||||
<li className="sale-list-item cursor-pointer" key={survey.id} onClick={() => handleDetailClick(survey.id)}>
|
||||
<div className="sale-item-bx">
|
||||
@ -67,18 +65,18 @@ export default function ListTable() {
|
||||
<div className="sale-item-update">{new Date(survey.uptDt).toLocaleString()}</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : (
|
||||
<div className="compliace-nosearch">
|
||||
<span className="mb10">作成された物件はありません。</span>
|
||||
</div>
|
||||
)}
|
||||
<div className="sale-edit-btn">
|
||||
<LoadMoreButton hasMore={hasMore} onLoadMore={() => setOffset(offset + 10)} />
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : (
|
||||
<div className="compliace-nosearch">
|
||||
<span className="mb10">作成された物件はありません。</span>
|
||||
</div>
|
||||
)}
|
||||
<div className="sale-edit-btn">
|
||||
<LoadMoreButton hasMore={hasMore} onLoadMore={() => setOffset(offset + 10)} />
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
@ -4,9 +4,9 @@ import { SEARCH_OPTIONS, SEARCH_OPTIONS_ENUM, SEARCH_OPTIONS_PARTNERS, useSurvey
|
||||
import { useRouter } from 'next/navigation'
|
||||
import { useState } from 'react'
|
||||
|
||||
export default function SearchForm({ memberRole, userNm }: { memberRole: string; userNm: string }) {
|
||||
export default function SearchForm({ memberRole, userId }: { memberRole: string; userId: string }) {
|
||||
const router = useRouter()
|
||||
const { setSearchOption, setSort, setIsMySurvey, setKeyword, isMySurvey, keyword, searchOption, sort } = useSurveyFilterStore()
|
||||
const { setSearchOption, setSort, setIsMySurvey, setKeyword, reset, isMySurvey, keyword, searchOption, sort, setOffset } = useSurveyFilterStore()
|
||||
const [searchKeyword, setSearchKeyword] = useState(keyword)
|
||||
const [option, setOption] = useState(searchOption)
|
||||
|
||||
@ -15,6 +15,7 @@ export default function SearchForm({ memberRole, userNm }: { memberRole: string;
|
||||
alert('2文字以上入力してください')
|
||||
return
|
||||
}
|
||||
reset()
|
||||
setKeyword(searchKeyword)
|
||||
setSearchOption(option)
|
||||
}
|
||||
@ -59,6 +60,10 @@ export default function SearchForm({ memberRole, userNm }: { memberRole: string;
|
||||
value={searchKeyword}
|
||||
placeholder="タイトルを入力してください. (2文字以上)"
|
||||
onChange={(e) => {
|
||||
if (e.target.value.length > 30) {
|
||||
alert('30文字以内で入力してください')
|
||||
return
|
||||
}
|
||||
setSearchKeyword(e.target.value)
|
||||
}}
|
||||
onKeyDown={(e) => {
|
||||
@ -75,9 +80,10 @@ export default function SearchForm({ memberRole, userNm }: { memberRole: string;
|
||||
<input
|
||||
type="checkbox"
|
||||
id="ch01"
|
||||
checked={isMySurvey === userNm}
|
||||
checked={isMySurvey === userId}
|
||||
onChange={() => {
|
||||
setIsMySurvey(isMySurvey === userNm ? null : userNm)
|
||||
setOffset(0)
|
||||
setIsMySurvey(isMySurvey === userId ? null : userId)
|
||||
}}
|
||||
/>
|
||||
<label htmlFor="ch01">私が書いた物件</label>
|
||||
@ -90,6 +96,7 @@ export default function SearchForm({ memberRole, userNm }: { memberRole: string;
|
||||
id="sort-option"
|
||||
value={sort}
|
||||
onChange={(e) => {
|
||||
setOffset(0)
|
||||
setSort(e.target.value as 'created' | 'updated')
|
||||
}}
|
||||
>
|
||||
|
||||
@ -7,6 +7,7 @@ import ZipCodePopup from '../popup/ZipCodePopup'
|
||||
import Alert from './common/Alert'
|
||||
import DoubleBtnAlert from './common/DoubleBtnAlert'
|
||||
import SuitableDetailPopup from '../popup/SuitableDetailPopup'
|
||||
import SurveySaleSubmitPopup from '../popup/SurveySaleSubmitPopup'
|
||||
|
||||
export default function PopupController() {
|
||||
const popupController = usePopupController()
|
||||
@ -15,9 +16,10 @@ export default function PopupController() {
|
||||
<>
|
||||
{popupController.memberInfomationPopup && <MemberInfomationPopup />}
|
||||
{popupController.zipCodePopup && <ZipCodePopup />}
|
||||
{popupController.suitableDetailPopup && <SuitableDetailPopup />}
|
||||
{popupController.surveySaleSubmitPopup && <SurveySaleSubmitPopup />}
|
||||
{popupController.alert && <Alert />}
|
||||
{popupController.alert2 && <DoubleBtnAlert />}
|
||||
{popupController.suitableDetailPopup && <SuitableDetailPopup />}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import type { SurveyBasicInfo, SurveyDetailInfo, SurveyDetailRequest, SurveyDetailCoverRequest, SurveyRegistRequest } from '@/types/Survey'
|
||||
import type { SurveyBasicInfo, SurveyDetailRequest, SurveyRegistRequest } from '@/types/Survey'
|
||||
import { useMemo } from 'react'
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { useSurveyFilterStore } from '@/store/surveyFilterStore'
|
||||
@ -62,8 +62,8 @@ export function useServey(id?: number): {
|
||||
isCreatingSurvey: boolean
|
||||
isUpdatingSurvey: boolean
|
||||
isDeletingSurvey: boolean
|
||||
isSubmittingSurvey: boolean
|
||||
createSurvey: (survey: SurveyRegistRequest) => Promise<number>
|
||||
createSurveyDetail: (params: { surveyId: number; surveyDetail: SurveyDetailCoverRequest }) => void
|
||||
updateSurvey: ({ survey, isTemporary, storeId }: { survey: SurveyRegistRequest; isTemporary: boolean; storeId?: string }) => void
|
||||
deleteSurvey: () => Promise<boolean>
|
||||
submitSurvey: (params: { saveId?: number; targetId?: string; storeId?: string; srlNo?: string }) => void
|
||||
@ -90,7 +90,7 @@ export function useServey(id?: number): {
|
||||
isMySurvey,
|
||||
sort,
|
||||
offset,
|
||||
store: session?.storeNm,
|
||||
store: session?.storeId,
|
||||
builderNo: session?.builderNo,
|
||||
role: session?.role,
|
||||
},
|
||||
@ -119,7 +119,11 @@ export function useServey(id?: number): {
|
||||
|
||||
const { mutateAsync: createSurvey, isPending: isCreatingSurvey } = useMutation({
|
||||
mutationFn: async (survey: SurveyRegistRequest) => {
|
||||
const resp = await axiosInstance(null).post<SurveyBasicInfo>('/api/survey-sales', { survey: survey, storeId: session?.storeId ?? null })
|
||||
const resp = await axiosInstance(null).post<SurveyBasicInfo>('/api/survey-sales', {
|
||||
survey: survey,
|
||||
storeId: session?.storeId ?? null,
|
||||
role: session?.role ?? null,
|
||||
})
|
||||
return resp.data.id ?? 0
|
||||
},
|
||||
onSuccess: (data) => {
|
||||
@ -131,12 +135,12 @@ export function useServey(id?: number): {
|
||||
|
||||
const { mutate: updateSurvey, isPending: isUpdatingSurvey } = useMutation({
|
||||
mutationFn: async ({ survey, isTemporary, storeId }: { survey: SurveyRegistRequest; isTemporary: boolean; storeId?: string }) => {
|
||||
console.log('updateSurvey, survey:: ', survey)
|
||||
if (id === undefined) throw new Error('id is required')
|
||||
const resp = await axiosInstance(null).put<SurveyRegistRequest>(`/api/survey-sales/${id}`, {
|
||||
survey: survey,
|
||||
isTemporary: isTemporary,
|
||||
storeId: storeId,
|
||||
role: session?.role ?? null,
|
||||
})
|
||||
return resp.data
|
||||
},
|
||||
@ -158,25 +162,14 @@ export function useServey(id?: number): {
|
||||
},
|
||||
})
|
||||
|
||||
const { mutateAsync: createSurveyDetail } = useMutation({
|
||||
mutationFn: async ({ surveyId, surveyDetail }: { surveyId: number; surveyDetail: SurveyDetailCoverRequest }) => {
|
||||
const resp = await axiosInstance(null).patch<SurveyDetailInfo>(`/api/survey-sales/${surveyId}`, surveyDetail)
|
||||
return resp.data
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['survey', 'list'] })
|
||||
queryClient.invalidateQueries({ queryKey: ['survey', id] })
|
||||
},
|
||||
})
|
||||
|
||||
const { mutateAsync: submitSurvey } = useMutation({
|
||||
mutationFn: async ({ saveId, targetId, storeId, srlNo }: { saveId?: number; targetId?: string; storeId?: string; srlNo?: string }) => {
|
||||
const submitId = saveId ?? id
|
||||
if (!submitId) throw new Error('id is required')
|
||||
const resp = await axiosInstance(null).patch<boolean>(`/api/survey-sales/${submitId}`, {
|
||||
const { mutateAsync: submitSurvey, isPending: isSubmittingSurvey } = useMutation({
|
||||
mutationFn: async ({ targetId, storeId, srlNo }: { targetId?: string; storeId?: string; srlNo?: string }) => {
|
||||
if (!id) throw new Error('id is required')
|
||||
const resp = await axiosInstance(null).patch<boolean>(`/api/survey-sales/${id}`, {
|
||||
targetId,
|
||||
storeId,
|
||||
srlNo,
|
||||
role: session?.role ?? null,
|
||||
})
|
||||
return resp.data
|
||||
},
|
||||
@ -237,10 +230,10 @@ export function useServey(id?: number): {
|
||||
isCreatingSurvey,
|
||||
isUpdatingSurvey,
|
||||
isDeletingSurvey,
|
||||
isSubmittingSurvey,
|
||||
createSurvey,
|
||||
updateSurvey,
|
||||
deleteSurvey,
|
||||
createSurveyDetail,
|
||||
submitSurvey,
|
||||
validateSurveyDetail,
|
||||
getZipCode,
|
||||
|
||||
@ -10,6 +10,8 @@ type PoupControllerState = {
|
||||
alert2: boolean
|
||||
alert2BtnYes: Function
|
||||
alert2BtnNo: Function
|
||||
surveySaleSubmitPopup: boolean
|
||||
setSurveySaleSubmitPopup: (value: boolean) => void
|
||||
setMemberInfomationPopup: (value: boolean) => void
|
||||
setZipCodePopup: (value: boolean) => void
|
||||
setAlert: (value: boolean) => void
|
||||
@ -32,6 +34,7 @@ type InitialState = {
|
||||
alert2BtnYes: Function
|
||||
alert2BtnNo: Function
|
||||
suitableDetailPopup: boolean
|
||||
surveySaleSubmitPopup: boolean
|
||||
}
|
||||
|
||||
const initialState: InitialState = {
|
||||
@ -44,6 +47,7 @@ const initialState: InitialState = {
|
||||
alert2BtnYes: () => {},
|
||||
alert2BtnNo: () => {},
|
||||
suitableDetailPopup: false,
|
||||
surveySaleSubmitPopup: false,
|
||||
}
|
||||
|
||||
export const usePopupController = create<PoupControllerState>((set) => ({
|
||||
@ -57,5 +61,6 @@ export const usePopupController = create<PoupControllerState>((set) => ({
|
||||
setAlert2BtnYes: (value: Function) => set((state) => ({ ...state, alert2BtnYes: value })),
|
||||
setAlert2BtnNo: (value: Function) => set((state) => ({ ...state, alert2BtnNo: value })),
|
||||
setSuitableDetailPopup: (value: boolean) => set((state) => ({ ...state, suitableDetailPopup: value })),
|
||||
setSurveySaleSubmitPopup: (value: boolean, id?: number) => set((state) => ({ ...state, surveySaleSubmitPopup: value, surveySaleSubmitId: id })),
|
||||
reset: () => set(initialState),
|
||||
}))
|
||||
|
||||
@ -6,7 +6,7 @@ export const SEARCH_OPTIONS = [
|
||||
label: '全体',
|
||||
},
|
||||
{
|
||||
id: 'id',
|
||||
id: 'srl_no',
|
||||
label: '登録番号',
|
||||
},
|
||||
{
|
||||
@ -41,7 +41,7 @@ export const SEARCH_OPTIONS_PARTNERS = [
|
||||
label: '全体',
|
||||
},
|
||||
{
|
||||
id: 'id',
|
||||
id: 'srl_no',
|
||||
label: '登録番号',
|
||||
},
|
||||
{
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
export type SurveyBasicInfo = {
|
||||
id: number
|
||||
representative: string
|
||||
representativeId: string | null
|
||||
store: string | null
|
||||
storeId: string | null
|
||||
constructionPoint: string | null
|
||||
investigationDate: string | null
|
||||
buildingName: string | null
|
||||
@ -62,7 +64,9 @@ export type SurveyDetailInfo = {
|
||||
|
||||
export type SurveyBasicRequest = {
|
||||
representative: string
|
||||
representativeId: string | null
|
||||
store: string | null
|
||||
storeId: string | null
|
||||
constructionPoint: string | null
|
||||
investigationDate: string | null
|
||||
buildingName: string | null
|
||||
@ -120,7 +124,9 @@ export type SurveyDetailCoverRequest = {
|
||||
|
||||
export type SurveyRegistRequest = {
|
||||
representative: string
|
||||
representativeId: string | null
|
||||
store: string | null
|
||||
storeId: string | null
|
||||
constructionPoint: string | null
|
||||
investigationDate: string | null
|
||||
buildingName: string | null
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user