diff --git a/src/components/management/StuffDetail.jsx b/src/components/management/StuffDetail.jsx index f5f906d5..0ed19ddc 100644 --- a/src/components/management/StuffDetail.jsx +++ b/src/components/management/StuffDetail.jsx @@ -1067,39 +1067,49 @@ export default function StuffDetail() { return } - // T01 / 1차 user + 2차 ID: firstAgent 검증 후에만 적용 (실패 시 무반영) - get({ url: `/api/object/saleStore/${info.saleStoreId}/firstAgent` }).then((res) => { - logger.debug('[PLANREQ-DEBUG] firstAgent result', { firstAgentId: res?.firstAgentId }) - if (!res?.firstAgentId) { - swalFire({ - title: getMessage('stuff.detail.planReq.message.notMatch'), - type: 'alert', - icon: 'warning', - }) - return - } + // [PLANREQ-FORCE-SELECT 2026-06-05] T01 / 1차 user + 2차 ID + // 매핑 실패해도 모든 필드 적용 + 2차점을 옵션에 강제 추가 + selected + // 1차점 정보(firstAgent) 가 있으면 1차점도 함께 반영 + // 'No data' 응답(4xx + message)도 매핑 실패와 동일하게 처리, 진짜 네트워크 에러만 알림 + const applyOtherSaleStore = () => { applyFields() + setOtherSaleStoreList((prev) => { + const exists = prev.some((o) => o.saleStoreId === info.saleStoreId) + return exists ? prev : [...prev, { saleStoreId: info.saleStoreId, saleStoreName: info.saleStoreName }] + }) setOtherSelOptions(info.saleStoreId) form.setValue('otherSaleStoreId', info.saleStoreId) form.setValue('otherSaleStoreName', info.saleStoreName) form.setValue('otherSaleStoreLevel', info.saleStoreLevel) - const firstAgent = { saleStoreId: res.firstAgentId, saleStoreName: res.firstAgentName } - setSaleStoreList((prev) => { - const exists = prev.some((s) => s.saleStoreId === res.firstAgentId) - return exists ? prev : [...prev, firstAgent] - }) - setShowSaleStoreList((prev) => { - const exists = prev.some((s) => s.saleStoreId === res.firstAgentId) - return exists ? prev : [...prev, firstAgent] - }) - setSelOptions(res.firstAgentId) - form.setValue('saleStoreId', res.firstAgentId) - form.setValue('saleStoreName', res.firstAgentName) - form.setValue('saleStoreLevel', '1') - }).catch(() => { - // 매핑 실패 — 아무것도 적용 안 함 + 사용자에게 알림 + } + get({ url: `/api/object/saleStore/${info.saleStoreId}/firstAgent` }).then((res) => { + logger.debug('[PLANREQ-DEBUG] firstAgent result', { firstAgentId: res?.firstAgentId }) + applyOtherSaleStore() + if (res?.firstAgentId) { + const firstAgent = { saleStoreId: res.firstAgentId, saleStoreName: res.firstAgentName } + setSaleStoreList((prev) => { + const exists = prev.some((s) => s.saleStoreId === res.firstAgentId) + return exists ? prev : [...prev, firstAgent] + }) + setShowSaleStoreList((prev) => { + const exists = prev.some((s) => s.saleStoreId === res.firstAgentId) + return exists ? prev : [...prev, firstAgent] + }) + setSelOptions(res.firstAgentId) + form.setValue('saleStoreId', res.firstAgentId) + form.setValue('saleStoreName', res.firstAgentName) + form.setValue('saleStoreLevel', '1') + } + }).catch((error) => { + // 'No data' 는 1차점 매핑 정보가 없을 뿐 — 2차점만 옵션 추가+select + const message = error?.response?.data?.message + if (message === 'No data') { + applyOtherSaleStore() + return + } + // 진짜 네트워크/서버 에러 swalFire({ - title: getMessage('stuff.detail.planReq.message.notMatch'), + title: getMessage('stuff.detail.planReq.message.networkError'), type: 'alert', icon: 'warning', }) @@ -1861,16 +1871,18 @@ export default function StuffDetail() { )) || null} - + {session?.storeId === 'T01' && ( + + )} @@ -2451,7 +2463,7 @@ export default function StuffDetail() { > ) : null} - {managementState?.tempFlg === '1' ? ( + {managementState?.tempFlg === '1' && session?.storeId === 'T01' ? ( <>