From 1076120516a9924891b9633c8e984263b8a82587 Mon Sep 17 00:00:00 2001 From: ljpark Date: Wed, 8 Jul 2026 10:32:33 +0900 Subject: [PATCH] =?UTF-8?q?dm:=20=EC=A0=84=ED=99=94=EB=B2=88=ED=98=B8=20?= =?UTF-8?q?=ED=8F=AC=EB=A7=B7=20&=20=EB=B9=84=EB=B2=88=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/dm/app/store/sdmMng/index.tsx | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/apps/dm/app/store/sdmMng/index.tsx b/apps/dm/app/store/sdmMng/index.tsx index 0041f5a93..2627909b6 100644 --- a/apps/dm/app/store/sdmMng/index.tsx +++ b/apps/dm/app/store/sdmMng/index.tsx @@ -43,6 +43,34 @@ export const sdmInfoFormSchema = z.object({ export type SdmInfoFormData = z.infer; +const formatTelno = (telno?: string | null) => { + const digits = (telno ?? '').replace(/\D/g, ''); + + if (!digits) { + return ''; + } + + if (digits.startsWith('02')) { + if (digits.length === 9) { + return digits.replace(/(02)(\d{3})(\d{4})/, '$1-$2-$3'); + } + + if (digits.length === 10) { + return digits.replace(/(02)(\d{4})(\d{4})/, '$1-$2-$3'); + } + } + + if (digits.length === 10) { + return digits.replace(/(\d{3})(\d{3})(\d{4})/, '$1-$2-$3'); + } + + if (digits.length === 11) { + return digits.replace(/(\d{3})(\d{4})(\d{4})/, '$1-$2-$3'); + } + + return telno ?? ''; +}; + // 수요처 정보 export type DemandCompBizType = { @@ -694,7 +722,7 @@ export const SdmReducer = (set: any): SdmActions => { dmdInfoId: res.dmdInfoId, zip: res.zip || '', daddr: res.daddr, - telno: res.telno.replace(/(\d{3})(\d{4})(\d{4})/, '$1-$2-$3'), + telno: formatTelno(res.telno), rgtr: res.rgtr, ctpvCd: res.ctpvCd, sggCd: res.sggCd,