260716_02_ENH: 프로젝트에 발신 번호추가 및 리다이렉트 url, api 수정 #4
@@ -130,6 +130,8 @@ const ListContactPageContent = () => {
|
||||
listHeaders={listHeaders}
|
||||
detail={listDetailQuery.data}
|
||||
surveyUrl={projectInfoQuery.data?.surveyUrl}
|
||||
callerTelNum={projectInfoQuery.data?.callerTelNum}
|
||||
resultCodes={resultCodeArray}
|
||||
formValues={formValues}
|
||||
onFieldChange={handleFieldChange}
|
||||
onSaved={() => listDetailQuery.refetch()}
|
||||
|
||||
@@ -39,6 +39,8 @@ import {
|
||||
useUploadScenarioImageMutation, useKartProjectListQuery,
|
||||
} from "@/query/project";
|
||||
import { useCmpnListQuery } from "@/query/cmpn";
|
||||
import { useCallerTelNumListQuery } from "@/query/intranet";
|
||||
import { formatKoreanPhoneNumber } from "@/utils/phone";
|
||||
|
||||
const defaultProjectInfo: ProjectInfo = {
|
||||
prjctIdx: 0,
|
||||
@@ -48,6 +50,7 @@ const defaultProjectInfo: ProjectInfo = {
|
||||
prjctStatus: ProjectStatus.WAITING,
|
||||
ownerDept: '',
|
||||
ownerFw: '',
|
||||
callerTelNum: '',
|
||||
surveyTy: SurveyType.NONE,
|
||||
surveyPrjctCd: '',
|
||||
surveyUrl: '',
|
||||
@@ -61,21 +64,22 @@ const defaultProjectInfo: ProjectInfo = {
|
||||
|
||||
type ExternalTab = 'redirect' | 'api'
|
||||
|
||||
const baseUrl = 'https://kcont.kric.com'
|
||||
const baseUrl = 'https://contact.kric.com'
|
||||
const sidParam = 'sid=[$SID]'
|
||||
const externalPidParamBase = 'contact-pid=[$prjctIdx]'
|
||||
const internalPidParamBase = 'pid=[$prjctIdx]'
|
||||
|
||||
const externalUrls = {
|
||||
redirect: {
|
||||
start: `${baseUrl}/redirect/start?${sidParam}`,
|
||||
complete: `${baseUrl}/redirect/complete?${sidParam}`,
|
||||
screen: `${baseUrl}/redirect/screen?${sidParam}`,
|
||||
quota: `${baseUrl}/redirect/quota?${sidParam}`,
|
||||
complete: `${baseUrl}/redirect/complete?${internalPidParamBase}&${sidParam}`,
|
||||
screen: `${baseUrl}/redirect/screen?${internalPidParamBase}&${sidParam}`,
|
||||
quota: `${baseUrl}/redirect/quota?${internalPidParamBase}&${sidParam}`,
|
||||
},
|
||||
api: {
|
||||
start: `${baseUrl}/api/external/start?${sidParam}`,
|
||||
complete: `${baseUrl}/api/external/complete?${sidParam}`,
|
||||
screen: `${baseUrl}/api/external/screen?${sidParam}`,
|
||||
quota: `${baseUrl}/api/external/quota?${sidParam}`,
|
||||
start: `${baseUrl}/api/external/start?${internalPidParamBase}&${sidParam}`,
|
||||
complete: `${baseUrl}/api/external/complete?${internalPidParamBase}&${sidParam}`,
|
||||
screen: `${baseUrl}/api/external/screen?${internalPidParamBase}&${sidParam}`,
|
||||
quota: `${baseUrl}/api/external/quota?${internalPidParamBase}&${sidParam}`,
|
||||
},
|
||||
} as const
|
||||
|
||||
@@ -111,6 +115,7 @@ const ProjectInfoPage = () => {
|
||||
const resultCodesQuery = useResultCodesQuery(prjctIdx, enabled);
|
||||
const cmpnListQuery = useCmpnListQuery();
|
||||
const assignedCmpnQuery = useAssignedCmpnIdsQuery(prjctIdx, enabled);
|
||||
const callerTelNumListQuery = useCallerTelNumListQuery(mounted);
|
||||
|
||||
const kartEnabled =
|
||||
mounted &&
|
||||
@@ -144,6 +149,7 @@ const ProjectInfoPage = () => {
|
||||
|
||||
|
||||
const surveyProjectArray = kartProjectListQuery.data ?? [];
|
||||
const callerTelNumArray = callerTelNumListQuery.data ?? [];
|
||||
|
||||
const deptArray = useMemo(() => {
|
||||
const teams = Array.from(new Set((users ?? []).map((u) => u.userTeam).filter(Boolean)));
|
||||
@@ -245,7 +251,8 @@ const ProjectInfoPage = () => {
|
||||
const next = {...prev, surveyPrjctCd: value};
|
||||
|
||||
if (value && internalSurvey.has(prev.surveyTy || SurveyType.NONE)) {
|
||||
let surveyUrl = `/project/${value}/INDEX.asp?${sidParam}`;
|
||||
const pidParam = externalPidParamBase.replace('[$prjctIdx]', String(prev.prjctIdx));
|
||||
let surveyUrl = `/project/${value}/INDEX.asp?${pidParam}&${sidParam}`;
|
||||
if (prev.surveyTy === SurveyType.KON) {
|
||||
surveyUrl = `https://kon.kric.com` + surveyUrl
|
||||
} else if (prev.surveyTy === SurveyType.KIWI) {
|
||||
@@ -275,6 +282,8 @@ const ProjectInfoPage = () => {
|
||||
}))
|
||||
}
|
||||
|
||||
const replacePrjctIdx = (url: string) => url.replace('[$prjctIdx]', String(projectInfo.prjctIdx));
|
||||
|
||||
if (!mounted) return <LoadingOverlayAdapter force />
|
||||
|
||||
return (
|
||||
@@ -331,7 +340,7 @@ const ProjectInfoPage = () => {
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div className="grid grid-cols-3 gap-4">
|
||||
<div className="space-y-2">
|
||||
<Label className="text-base">담당 그룹</Label>
|
||||
<KriSingleSelect
|
||||
@@ -357,6 +366,20 @@ const ProjectInfoPage = () => {
|
||||
widthClassName="w-full"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label className="text-base">발신 번호</Label>
|
||||
<KriSingleSelect
|
||||
items={callerTelNumArray}
|
||||
value={projectInfo.callerTelNum || ''}
|
||||
onChange={(value) => handleChange('callerTelNum', value)}
|
||||
getValue={(item) => item.telNum}
|
||||
getLabel={(item) => formatKoreanPhoneNumber(item.telNum)}
|
||||
placeholder="발신 번호를 선택하세요"
|
||||
heightClassName="h-9"
|
||||
widthClassName="w-full"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -451,21 +474,17 @@ const ProjectInfoPage = () => {
|
||||
<div className="font-semibold">리다이렉트 URL</div>
|
||||
|
||||
<div className="grid gap-2">
|
||||
<div className="flex items-center gap-2">
|
||||
<Label className="w-24 text-base">시작:</Label>
|
||||
<Input value={externalUrls.redirect.start} disabled className="bg-white h-9" />
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Label className="w-24 text-base">완료:</Label>
|
||||
<Input value={externalUrls.redirect.complete} disabled className="bg-white h-9" />
|
||||
<Input value={replacePrjctIdx(externalUrls.redirect.complete)} readOnly className="bg-white h-9" />
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Label className="w-24 text-base">스크린 아웃:</Label>
|
||||
<Input value={externalUrls.redirect.screen} disabled className="bg-white h-9" />
|
||||
<Input value={replacePrjctIdx(externalUrls.redirect.screen)} readOnly className="bg-white h-9" />
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Label className="w-24 text-base">쿼터 풀:</Label>
|
||||
<Input value={externalUrls.redirect.quota} disabled className="bg-white h-9" />
|
||||
<Input value={replacePrjctIdx(externalUrls.redirect.quota)} readOnly className="bg-white h-9" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -478,19 +497,19 @@ const ProjectInfoPage = () => {
|
||||
<div className="grid gap-2">
|
||||
<div className="flex items-center gap-2">
|
||||
<Label className="w-24 text-base">시작 API:</Label>
|
||||
<Input value={externalUrls.api.start} disabled className="bg-white h-9" />
|
||||
<Input value={replacePrjctIdx(externalUrls.api.start)} readOnly className="bg-white h-9" />
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Label className="w-24 text-base">완료 API:</Label>
|
||||
<Input value={externalUrls.api.complete} disabled className="bg-white h-9" />
|
||||
<Input value={replacePrjctIdx(externalUrls.api.complete)} readOnly className="bg-white h-9" />
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Label className="w-24 text-base">스크린 API:</Label>
|
||||
<Input value={externalUrls.api.screen} disabled className="bg-white h-9" />
|
||||
<Input value={replacePrjctIdx(externalUrls.api.screen)} readOnly className="bg-white h-9" />
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Label className="w-24 text-base">쿼터 API:</Label>
|
||||
<Input value={externalUrls.api.quota} disabled className="bg-white h-9" />
|
||||
<Input value={replacePrjctIdx(externalUrls.api.quota)} readOnly className="bg-white h-9" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
16
src/app/api/external/[[...slug]]/route.ts
vendored
16
src/app/api/external/[[...slug]]/route.ts
vendored
@@ -6,8 +6,9 @@ import { errorToResponse } from "@kri/common/http";
|
||||
import { getClientIp } from "@kri/common/server";
|
||||
import {
|
||||
EXTERNAL_ACTION_CODE_BY_SLUG,
|
||||
EXTERNAL_ENTRY_TYPE_CODE,
|
||||
ExternalAction,
|
||||
ExternalEntryType,
|
||||
ExternalEntryTypeCode,
|
||||
ExternalEventBody,
|
||||
} from "@/types/external";
|
||||
import {createContactApi} from "@/lib/http-server";
|
||||
@@ -17,8 +18,10 @@ const getHeader = (headers: Headers, name: string): string | null => {
|
||||
return value && value.trim().length > 0 ? value : null;
|
||||
};
|
||||
|
||||
const getEntryType = (headers: Headers): ExternalEntryType => {
|
||||
return getHeader(headers, "x-entry-type") === "redirect" ? "redirect" : "api";
|
||||
const getEntryTypeCode = (headers: Headers): ExternalEntryTypeCode => {
|
||||
return getHeader(headers, "x-entry-type") === "redirect"
|
||||
? EXTERNAL_ENTRY_TYPE_CODE.redirect
|
||||
: EXTERNAL_ENTRY_TYPE_CODE.api;
|
||||
};
|
||||
|
||||
const toExternalAction = (value: string): ExternalAction | null => {
|
||||
@@ -41,13 +44,12 @@ const buildExternalEventBody = (
|
||||
const actionCode = EXTERNAL_ACTION_CODE_BY_SLUG[action];
|
||||
|
||||
return {
|
||||
actionCode,
|
||||
action: actionCode,
|
||||
prjctIdx,
|
||||
sid,
|
||||
meta: {
|
||||
entryType: getEntryType(h),
|
||||
action,
|
||||
actionCode,
|
||||
entryType: getEntryTypeCode(h),
|
||||
action: actionCode,
|
||||
pid: String(prjctIdx),
|
||||
sid: String(sid),
|
||||
remoteAddr: getHeader(h, "x-orig-ip") || getClientIp(req),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {NextRequest, NextResponse} from "next/server";
|
||||
import {RouteContext} from "@/types/common";
|
||||
import {createIntranetApi} from "@/lib/http-server";
|
||||
import {IntranetProjectSearchResponse} from "@/types/project";
|
||||
import {CallerTelNumInfo, IntranetProjectSearchResponse} from "@/types/project";
|
||||
import {errorToResponse} from "@kri/common/http";
|
||||
import {ItrntUserInfo} from "@/types/user";
|
||||
|
||||
@@ -28,6 +28,12 @@ export const GET = async (req: NextRequest, context: RouteContext) => {
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
if(action === "caller-tel-num"){
|
||||
const result = await itrntApi.get<CallerTelNumInfo[]>(`/telnum/caller`);
|
||||
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
return NextResponse.json({ message: "Not found" }, { status: 404 });
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
|
||||
@@ -11,6 +11,8 @@ import { useUploadListItemFileMutation } from '@/query/list'
|
||||
import { ListHeaderConst } from '@/const/listConst'
|
||||
import type { listHeader, ListSearchWithFullResult } from '@/types/list'
|
||||
import type { MessageSendChannel } from '@/types/message'
|
||||
import { type ResultCode, ResultCodeType } from '@/types/project'
|
||||
import { formatKst } from '@kri/common'
|
||||
import { isListFieldEditableForContact, isListFieldVisibleForContact } from '@/utils/listAccess'
|
||||
import { substituteSurveyUrl } from '@/lib/surveyUrl'
|
||||
import SurveyQrDialog from '@/components/dialog/SurveyQrDialog'
|
||||
@@ -30,6 +32,8 @@ export type ListContactInfoPanelProps = {
|
||||
listHeaders: listHeader[]
|
||||
detail?: ListSearchWithFullResult
|
||||
surveyUrl?: string
|
||||
callerTelNum?: string
|
||||
resultCodes: ResultCode[]
|
||||
formValues: Record<number, string>
|
||||
onFieldChange: (listHderId: number, value: string) => void
|
||||
onSaved?: () => void
|
||||
@@ -69,6 +73,8 @@ const ListContactInfoPanel = ({
|
||||
listHeaders,
|
||||
detail,
|
||||
surveyUrl,
|
||||
callerTelNum,
|
||||
resultCodes,
|
||||
formValues,
|
||||
onFieldChange,
|
||||
onSaved,
|
||||
@@ -88,7 +94,12 @@ const ListContactInfoPanel = ({
|
||||
.sort((a, b) => a.listHderOrder - b.listHderOrder)
|
||||
|
||||
const substitutedSurveyUrl = surveyUrl ? substituteSurveyUrl(surveyUrl, sid) : ''
|
||||
const hasSurveyResponse = detail?.surveyResult?.lastResultCd !== undefined
|
||||
const surveyResult = detail?.surveyResult
|
||||
const hasSurveyResponse = surveyResult?.lastResultCd !== undefined
|
||||
const surveyResultLabel = hasSurveyResponse
|
||||
? resultCodes.find((rc) => rc.resultCdTy === ResultCodeType.SURVEY && rc.resultCd === surveyResult?.lastResultCd)
|
||||
?.resultCdLbl ?? String(surveyResult?.lastResultCd)
|
||||
: ''
|
||||
|
||||
const handleStartSurvey = () => {
|
||||
if (!substitutedSurveyUrl) return
|
||||
@@ -102,7 +113,7 @@ const ListContactInfoPanel = ({
|
||||
|
||||
const handleCall = (telNum: string, listHderId: number) => {
|
||||
if (!telNum || !isCtiReady || isOnCall) return
|
||||
ctiClient.makeCall({ dialNumber: telNum, prjctIdx, sid: Number(sid), listHderId })
|
||||
ctiClient.makeCall({ dialNumber: telNum, prjctIdx, sid: Number(sid), listHderId, aniNumber: callerTelNum ?? '' })
|
||||
}
|
||||
|
||||
const handlePickFile = (listHderId: number) => {
|
||||
@@ -265,7 +276,16 @@ const ListContactInfoPanel = ({
|
||||
<QrCode className="h-4 w-4" />
|
||||
QR
|
||||
</Button>
|
||||
{!hasSurveyResponse && <span className="text-sm text-muted-foreground">[응답없음]</span>}
|
||||
{hasSurveyResponse ? (
|
||||
<span className="text-sm">
|
||||
[{surveyResultLabel}]{' '}
|
||||
<span className="text-muted-foreground">
|
||||
({formatKst(surveyResult?.lastResultDt ?? '', 'dateHourMin')})
|
||||
</span>
|
||||
</span>
|
||||
) : (
|
||||
<span className="text-sm text-muted-foreground">[응답없음]</span>
|
||||
)}
|
||||
</div>
|
||||
</FieldRow>
|
||||
) : null}
|
||||
|
||||
@@ -57,6 +57,21 @@ const getResultColumns = (resultCodeArray: ResultCode[]): DataTableColumn<ListTa
|
||||
);
|
||||
};
|
||||
|
||||
const formatSurveyResult = (result?: ListResultBase) => {
|
||||
const lastResultCd = result?.lastResultCd;
|
||||
if (lastResultCd === undefined) return "";
|
||||
|
||||
const label = getResultLabel(ResultCodeType.SURVEY, result);
|
||||
const dt = `(${formatKst(result?.lastResultDt ?? "", "dateHourMin")})`;
|
||||
|
||||
return (
|
||||
<div className="leading-tight">
|
||||
<div>{label}</div>
|
||||
<div>{dt}</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
const columns: DataTableColumn<ListTableRow>[] = [
|
||||
{
|
||||
@@ -90,7 +105,8 @@ const getResultColumns = (resultCodeArray: ResultCode[]): DataTableColumn<ListTa
|
||||
{
|
||||
id: "surveyStatus",
|
||||
header: "설문 진행 상태",
|
||||
accessorFn: (row) => getResultLabel(ResultCodeType.SURVEY, row.surveyResult as ListResultBase | undefined),
|
||||
cell: ({ row }) =>
|
||||
formatSurveyResult(row.original.surveyResult as ListResultBase | undefined),
|
||||
enableSorting: false,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -18,6 +18,7 @@ export type CtiMakeCallParams = {
|
||||
prjctIdx: number;
|
||||
sid: number;
|
||||
listHderId: number;
|
||||
aniNumber: string;
|
||||
};
|
||||
|
||||
export type CtiConnectionState = "idle" | "connecting" | "open" | "closed";
|
||||
@@ -260,7 +261,7 @@ export const ctiClient = {
|
||||
ZCommand: "MakeCall",
|
||||
AgentLoginID: currentAgentLoginId,
|
||||
DialNumber: params.dialNumber,
|
||||
ANINumber: currentLoginParams.aniNumber,
|
||||
ANINumber: params.aniNumber,
|
||||
});
|
||||
},
|
||||
hangup: requireAgent((agentLoginId) => {
|
||||
|
||||
@@ -4,7 +4,7 @@ import {keepPreviousData, useQuery} from "@tanstack/react-query";
|
||||
import {qk} from "@/query/key/keys";
|
||||
import {nextApi} from "@/lib/http-client";
|
||||
import {ItrntUserInfo} from "@/types/user";
|
||||
import {IntranetProjectSearchResponse, KonKiwiProjectInfo} from "@/types/project";
|
||||
import {CallerTelNumInfo, IntranetProjectSearchResponse, KonKiwiProjectInfo} from "@/types/project";
|
||||
|
||||
export function useIntranetProjectListQuery(keyword: string, enabled: boolean) {
|
||||
const kw = keyword.trim();
|
||||
@@ -34,4 +34,13 @@ export function useIntranetUsersQuery(opts?: {
|
||||
staleTime: 10 * 60_000,
|
||||
initialData: opts?.initialData,
|
||||
});
|
||||
}
|
||||
|
||||
export function useCallerTelNumListQuery(enabled: boolean) {
|
||||
return useQuery({
|
||||
queryKey: qk.callerTelNumList(),
|
||||
queryFn: () => nextApi.get<CallerTelNumInfo[]>("/intranet/caller-tel-num"),
|
||||
enabled,
|
||||
staleTime: 60_000,
|
||||
});
|
||||
}
|
||||
@@ -46,6 +46,7 @@ export const qk = {
|
||||
/********** 인트라넷 관련 **********/
|
||||
intranetProjectList: (keyword: string) => ["intranet", "project-list", keyword] as const,
|
||||
intranetUsers: () => ["intranet", "user-list"] as const,
|
||||
callerTelNumList: () => ["intranet", "caller-tel-num"] as const,
|
||||
/********** 인트라넷 관련 **********/
|
||||
|
||||
/********** 리스트 관련 **********/
|
||||
|
||||
@@ -83,6 +83,8 @@ export function useListDetailQuery(prjctIdx: number, sid: string, enabled: boole
|
||||
enabled,
|
||||
staleTime: 0,
|
||||
refetchOnMount: "always",
|
||||
// 조사 시작으로 새 창이 뜬 뒤 응답을 마치고 이 탭으로 돌아왔을 때 최신 상태(설문 응답 등)를 바로 보여주기 위함.
|
||||
refetchOnWindowFocus: true,
|
||||
meta: { ignoreGlobalLoading: true },
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import { ExternalActionCode } from "@/types/project";
|
||||
|
||||
export type ExternalEntryType = "redirect" | "api";
|
||||
export const EXTERNAL_ENTRY_TYPE_CODE = {
|
||||
redirect: 10,
|
||||
api: 20,
|
||||
} as const;
|
||||
|
||||
export type ExternalEntryType = keyof typeof EXTERNAL_ENTRY_TYPE_CODE;
|
||||
export type ExternalEntryTypeCode = (typeof EXTERNAL_ENTRY_TYPE_CODE)[ExternalEntryType];
|
||||
|
||||
export const EXTERNAL_ACTION_CODE_BY_SLUG = {
|
||||
start: ExternalActionCode.START,
|
||||
@@ -12,9 +18,8 @@ export const EXTERNAL_ACTION_CODE_BY_SLUG = {
|
||||
export type ExternalAction = keyof typeof EXTERNAL_ACTION_CODE_BY_SLUG;
|
||||
|
||||
export type ExternalEventMeta = {
|
||||
entryType: ExternalEntryType;
|
||||
action: ExternalAction;
|
||||
actionCode: ExternalActionCode;
|
||||
entryType: ExternalEntryTypeCode;
|
||||
action: ExternalActionCode;
|
||||
pid: string;
|
||||
sid: string;
|
||||
remoteAddr: string | null;
|
||||
@@ -28,7 +33,7 @@ export type ExternalEventMeta = {
|
||||
};
|
||||
|
||||
export type ExternalEventBody = {
|
||||
actionCode: ExternalActionCode;
|
||||
action: ExternalActionCode;
|
||||
prjctIdx: number;
|
||||
sid: number;
|
||||
meta: ExternalEventMeta;
|
||||
|
||||
@@ -35,6 +35,7 @@ export type ProjectInfo = {
|
||||
itrntPrjctCd: string;
|
||||
ownerDept: string;
|
||||
ownerFw: string;
|
||||
callerTelNum: string;
|
||||
surveyTy: SurveyType;
|
||||
surveyPrjctCd?: string;
|
||||
surveyUrl?: string;
|
||||
@@ -99,6 +100,12 @@ export type KonKiwiProjectInfo = {
|
||||
createDate:string;
|
||||
}
|
||||
|
||||
export type CallerTelNumInfo = {
|
||||
telNum: string;
|
||||
regDt: string;
|
||||
userCode: string;
|
||||
}
|
||||
|
||||
export type ResultCode = {
|
||||
resultCdUUID: string;
|
||||
prjctIdx:number;
|
||||
|
||||
22
src/utils/phone.ts
Normal file
22
src/utils/phone.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
// 특수/대표번호(15XX, 16XX, 18XX 등): 지역번호 없이 4자리-4자리
|
||||
const SPECIAL_NUMBER_PREFIX = /^(15|16|18)\d{2}/;
|
||||
|
||||
export const formatKoreanPhoneNumber = (value: string): string => {
|
||||
const digits = value.replace(/\D/g, "");
|
||||
|
||||
if (SPECIAL_NUMBER_PREFIX.test(digits) && digits.length === 8) {
|
||||
return `${digits.slice(0, 4)}-${digits.slice(4)}`;
|
||||
}
|
||||
|
||||
if (digits.startsWith("02")) {
|
||||
if (digits.length === 9) return `${digits.slice(0, 2)}-${digits.slice(2, 5)}-${digits.slice(5)}`;
|
||||
if (digits.length === 10) return `${digits.slice(0, 2)}-${digits.slice(2, 6)}-${digits.slice(6)}`;
|
||||
return value;
|
||||
}
|
||||
|
||||
// 010/011~019(휴대폰), 070(인터넷전화), 031~064(지역번호) 등 3자리 국번
|
||||
if (digits.length === 10) return `${digits.slice(0, 3)}-${digits.slice(3, 6)}-${digits.slice(6)}`;
|
||||
if (digits.length === 11) return `${digits.slice(0, 3)}-${digits.slice(3, 7)}-${digits.slice(7)}`;
|
||||
|
||||
return value;
|
||||
};
|
||||
Reference in New Issue
Block a user