Revert "Merge branch 'iipbs/sn/ii' into iipbs/sn/main"

This reverts commit 63012618a2, reversing
changes made to 6573981505.
This commit is contained in:
swcho
2025-07-09 11:30:12 +09:00
parent 63012618a2
commit 2aa202ace3
20 changed files with 240 additions and 574 deletions
@@ -75,7 +75,7 @@ const CustomLegend = (props: any) => {
};
export default function Chart({chartConfig=undefined, chartData=[], chartTitle='차트', chartClassName='w-full h-full', graphSize=40, yFieldText='', showLegend=false} : BarChartProps) {
const colors = ["#FF6B6B", "#4ECDC4", "#45B7D1", "#FED16A", "#FFEEAD", "#D4A5A5"];
const colors = ["#FF6B6B", "#4ECDC4", "#45B7D1", "#96CEB4", "#FFEEAD", "#D4A5A5"];
const getMaxValue = (data: any[], keyPrefix: string) => {
return Math.max(...data.map(item =>
Object.keys(item)
@@ -1,5 +1,4 @@
import React from 'react';
import { FormField } from "../form";
import { FormField } from "../form";
import { SelectBox } from "../select";
import { Input } from "@common/components";
import { FormUi } from "../form_ui";
@@ -56,7 +55,6 @@ interface FormSchema {
bznmTotNo?: string;
rgtr?: string;
dmdAplyPswd?: string;
dmdAplyPswdConfirm?: string;
}
interface SdmRegFormProps {
@@ -87,25 +85,10 @@ export function SdmRegForm({ form, onCheckboxChange, selectSidoData, selectSigun
const formatter = new AsYouType("KR");
const formatted = formatter.input(input);
return formatted
};
// 저장할 값 처리: 숫자만 추출
const digitsOnly = input.replace(/\D/g, "");
// 사업자등록번호 포맷팅 함수 (3-2-5 형식)
const formatBusinessNumber = (value: string) => {
// 숫자만 추출
const digitsOnly = value.replace(/\D/g, "");
// 10자리까지만 처리
const limitedDigits = digitsOnly.slice(0, 10);
// 3-2-5 형식으로 포맷팅
if (limitedDigits.length <= 3) {
return limitedDigits;
} else if (limitedDigits.length <= 5) {
return `${limitedDigits.slice(0, 3)}-${limitedDigits.slice(3)}`;
} else {
return `${limitedDigits.slice(0, 3)}-${limitedDigits.slice(3, 5)}-${limitedDigits.slice(5)}`;
}
return formatted
};
@@ -196,15 +179,12 @@ export function SdmRegForm({ form, onCheckboxChange, selectSidoData, selectSigun
const value = e.target.value;
if(noType === 'dmdInfoPk') {
// 숫자만 추출하여 저장 (포맷팅 제거)
const digitsOnly = value.replace(/\D/g, "");
if(orgBznmNo.substring(0,10) === digitsOnly) {
if(orgBznmNo.substring(0,10) === value) {
setIsDuplicate(true);
} else {
setIsDuplicate(false);
}
field?.onChange(digitsOnly);
field?.onChange(value);
} else {
if(orgBznmNo.substring(10,14) === value) {
setIsDuplicate(true);
@@ -316,7 +296,7 @@ export function SdmRegForm({ form, onCheckboxChange, selectSidoData, selectSigun
type="text"
className="!text-xl text-gray-600"
onChange={(e) => bznNoChange(e, 'dmdInfoPk', field)}
value={formatBusinessNumber(field.value || '')}
value={field.value}
readOnly={!!updateList?.dmdInfoPk}
/>
)
@@ -388,60 +368,32 @@ export function SdmRegForm({ form, onCheckboxChange, selectSidoData, selectSigun
{...field}
/>
)
},
{
name: "dmdAplyPswdConfirm",
label: "패스워드확인",
component: (field) => (
<Input
placeholder="패스워드를 입력하세요"
type="password"
className="!text-xl text-gray-600"
{...field}
/>
)
}
]
return (
<>
{formFields
.filter(({ name }) => !(updateList?.dmdInfoPk && (name === "dmdAplyPswd" || name === "dmdAplyPswdConfirm")))
.map(({ name, label, component }) => {
const error = form.formState.errors[name];
const inputId = `${name}-input`;
const errorId = `${name}-error`;
const isRequired = ["ctpvCd", "sggCd", "dmdCoNm", "dmdInfoPk", "daddr", "telno", "dmdAplyPswd", "dmdAplyPswdConfirm"].includes(name);
return (
<FormField
key={String(name)}
control={form.control}
name={name}
render={({ field }) => (
<div className="mb-4">
<label htmlFor={inputId} className="block text-gray-800 font-medium">
{label}
{isRequired && <span className="text-red-500 ml-1">*</span>}
</label>
{React.cloneElement(component(field), {
id: inputId,
"aria-required": isRequired,
"aria-invalid": !!error,
"aria-describedby": error ? errorId : undefined
})}
{error?.message && (
<p id={errorId} role="alert" className="text-red-500 text-sm mt-1">
{error.message}
</p>
)}
</div>
)}
/>
);
})}
{formFields.filter((item)=>
{if(updateList?.dmdInfoPk){
return item.name !== 'dmdAplyPswd'
}else{
return item
}
})
.map(({ name, label, component }) => (
<FormField
key={String(name)}
control={form.control}
name={name}
render={({ field }) => (
name === 'bznmTotNo' ? component(field) : (
<FormUi label={label}>
{component(field)}
</FormUi>
)
)}
/>
))}
</>
);
}
@@ -47,17 +47,7 @@ const createFormSchema = (isBznmTotNoDisabled: boolean, isDuplicate: boolean ,up
? z.string().optional() // 패스워드는 선택 사항이며 길이 제한 없음
: z.string().optional()
.refine((val) => !val || (val.length >= 8 && val.length <= 16), "패스워드는 8자 이상 16자 이내로 입력해주세요"),
dmdAplyPswdConfirm: z.string()
.min(1, "패스워드확인을 입력해주세요"),
}).refine((data) => {
// 패스워드 확인 검증
if (data.dmdAplyPswd && data.dmdAplyPswdConfirm) {
return data.dmdAplyPswd === data.dmdAplyPswdConfirm;
}
return true;
}, {
message: "패스워드가 일치하지 않습니다",
path: ["dmdAplyPswdConfirm"], // 에러를 패스워드 확인 필드에 표시
});
type FormSchema = z.infer<ReturnType<typeof createFormSchema>>;
@@ -72,7 +62,6 @@ const defaultValues: FormSchema = {
telno: '',
rgtr: '',
dmdAplyPswd: '',
dmdAplyPswdConfirm: '',
};
/**
@@ -160,7 +149,7 @@ export default function SdmInsertForm({selectSidoData, selectSigunData, dataList
console.log(' formData ', formData)
/* await insertSdmData(formData); */
rtnInputData(formData as unknown as DemandCompType);
rtnInputData(formData as DemandCompType);
//router.push(`/pages/sdmMng/sdmInfoInsert?${queryParams.toString()}`);
@@ -1,14 +1,14 @@
import React, { useCallback, useEffect, useRef, useState } from "react";
import type { DemandCompType } from "./form";
import React, { useCallback, useEffect, useRef, useState } from 'react';
import type { DemandCompType } from './form';
export type thisProps = {
label: string | undefined;
initValue: string | undefined;
dataList: DemandCompType[];
rtnValue: (searchText: string, pageCnt: number) => void;
rtnData: (item: DemandCompType) => void;
rtnText: (text: string) => void;
};
dataList : DemandCompType[];
rtnValue : (searchText: string, pageCnt: number) => void;
rtnData : (item: DemandCompType) => void;
rtnText : (text: string) => void;
}
/**
* 수요처 검색 컴포넌트
@@ -18,110 +18,88 @@ export type thisProps = {
* @param dataList 검색할 때 넘기는 데이터 리스트
* @param rtnData 검색 결과 반환 함수
*/
export const SdmSearchForm = ({
label = undefined,
initValue = undefined,
rtnValue = () => {},
dataList = [],
rtnData = () => {},
rtnText = () => {},
}: thisProps) => {
export const SdmSearchForm = ({label=undefined, initValue=undefined, rtnValue=()=>{}, dataList=[], rtnData=()=>{}, rtnText=()=>{} } :thisProps) => {
const [isOpen, setIsOpen] = useState(false);
const [textValue, setTextValue] = useState(initValue || "");
const [textValue, setTextValue] = useState(initValue || '');
const wrapperRef = useRef<HTMLDivElement>(null);
const handleInputChange = useCallback(
(e: React.ChangeEvent<HTMLInputElement>) => {
const value = e.target.value;
setTextValue(value);
rtnValue(value, 10);
rtnText(value);
if (value) {
setIsOpen(true);
} else {
setIsOpen(false);
}
},
[rtnValue, rtnText],
);
const handleSuggestionClick = useCallback(
(item: DemandCompType) => {
setTextValue(item.dmdCoNm);
rtnData(item);
const handleInputChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
const value = e.target.value;
setTextValue(value);
rtnValue(value, 10);
rtnText(value);
if (value) {
setIsOpen(true);
} else {
setIsOpen(false);
},
[rtnData],
);
}
}, [rtnValue, rtnText]);
const handleSuggestionClick = useCallback((item: DemandCompType) => {
setTextValue(item.dmdCoNm);
rtnData(item);
setIsOpen(false);
}, [rtnData]);
useEffect(() => {
const handleClickOutside = (event: MouseEvent) => {
if (
wrapperRef.current &&
!wrapperRef.current.contains(event.target as Node)
) {
if (wrapperRef.current && !wrapperRef.current.contains(event.target as Node)) {
setIsOpen(false);
}
};
document.addEventListener("mousedown", handleClickOutside);
document.addEventListener('mousedown', handleClickOutside);
return () => {
document.removeEventListener("mousedown", handleClickOutside);
document.removeEventListener('mousedown', handleClickOutside);
};
}, []);
useEffect(() => {
if (initValue && initValue?.length > 0) {
setTextValue(initValue);
if(initValue&& initValue?.length>0){
setTextValue(initValue)
}
}, [initValue]);
},[initValue])
return (
<div className="relative" ref={wrapperRef}>
<div ref={wrapperRef}>
<input
type="text"
value={textValue}
onChange={handleInputChange}
/* onFocus={() => setIsOpen(true)} */
className="h-[3.2rem] w-full rounded-md border border-gray-300 pl-3 !text-xl text-gray-600 focus:outline-none focus:ring-2 focus:ring-blue-500"
className="w-full h-[3.2rem] !text-xl pl-3 text-gray-600 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
placeholder={`${label}을(를) 입력하세요`}
/>
{isOpen && (
<div className="absolute top-full left-0 z-50 mb-2 max-h-72 w-full overflow-auto rounded-md border border-gray-300 bg-white shadow-lg">
<div className=" z-1 w-full mt-2 bg-white border border-gray-300 rounded-md shadow-lg h-90 overflow-auto">
<div className="max-h-72">
{dataList && dataList.length > 0 ? (
dataList.map((item: DemandCompType, index: number) => (
<div
key={index}
className="w-full cursor-pointer overflow-auto px-5 py-3 text-left !text-xl hover:bg-gray-100"
onClick={() => handleSuggestionClick(item)}
role="button"
tabIndex={0}
onKeyDown={(e) => {
if (e.key === "Enter" || e.key === " ") {
handleSuggestionClick(item);
}
}}
>
{item.dmdInfoPk.substring(10, 14) !== "0000" ? (
<>
<span className="text-gray-500">사업자번호 : </span>{" "}
{item.dmdInfoPk.substring(0, 10)}&nbsp;
<span className="text-gray-500">
종사업자번호 :{" "}
</span>{" "}
{item.dmdInfoPk.substring(10, 14)}&nbsp;
</>
) : (
<>
<span className="text-gray-500">사업자번호 : </span>{" "}
{item.dmdInfoPk.substring(0, 10)}&nbsp;
</>
)}
<span className="float-right">{item.dmdCoNm}</span>
</div>
))
) : (
<div className="w-full cursor-pointer overflow-auto px-5 py-3 !text-xl hover:bg-gray-100">
{dataList && dataList.length > 0 ? dataList.map((item : DemandCompType, index : number) => (
<div
key={index}
className="!text-xl w-full text-left px-5 py-3 hover:bg-gray-100 cursor-pointer overflow-auto"
onClick={() => handleSuggestionClick(item)}
role="button"
tabIndex={0}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
handleSuggestionClick(item);
}
}}
>
{item.dmdInfoPk.substring(10,14) !== '0000' ? (
<>
<span className="text-gray-500">사업자번호 : </span> {item.dmdInfoPk.substring(0,10)}&nbsp;
<span className="text-gray-500">종사업자번호 : </span> {item.dmdInfoPk.substring(10,14)}&nbsp;
</>
) : (
<>
<span className="text-gray-500">사업자번호 : </span> {item.dmdInfoPk.substring(0,10)}&nbsp;
</>
)}
<span className="float-right">{item.dmdCoNm}</span>
</div>
)) : (
<div className="!text-xl w-full px-5 py-3 hover:bg-gray-100 cursor-pointer overflow-auto">
검색 결과가 없습니다.
</div>
)}
@@ -129,5 +107,5 @@ export const SdmSearchForm = ({
</div>
)}
</div>
);
};
)
}
@@ -199,7 +199,7 @@ function SearchFormLeft({ isShowPart = false, children, selectSidoData = [], sel
setRtnSidoText(selectedSido?.text || '');
}
initializeSigunData(val);
onSelectValue('0', 'sigun');
onSelectValue(selectSigunData[0]?.val || '0', 'sigun');
break;
case 'sigun':
if (setRtnSigunValue) {
@@ -49,12 +49,6 @@ export function UiTable({ tableData, headlist, pageSize, total, headName, childr
}
}, [resetSelection]);
// 테이블 데이터가 변경될 때마다 선택된 행 초기화하는 useEffect 추가
useEffect(() => {
// 새로운 데이터가 로드되면 선택 상태 초기화
setIdx(-1);
}, [tableData]);
const handlePageChange = (page: number) => {
setCur(page);
onPageChange(page);
@@ -89,7 +83,7 @@ export function UiTable({ tableData, headlist, pageSize, total, headName, childr
?
<TableCell
className={`${head.align === 'right' ? 'text-right' : head.align === 'center' ? 'text-center' : 'text-center'} ${cellClick && idx === index ? '!font-[1000] cursor-pointer' :
cellClick ? 'cursor-pointer' : ''
cellClick ? 'cursor-pointer' : ''
} !font-bold`}
onClick={() => handleCellClick(index, head.id)}
key={`cell-${head.id}-${index}`}
@@ -103,7 +97,7 @@ export function UiTable({ tableData, headlist, pageSize, total, headName, childr
:
<TableCell
className={`${head.align === 'right' ? 'text-right' : head.align === 'center' ? 'text-center' : 'text-center'} ${cellClick && idx === index ? '!font-[1000] cursor-pointer' :
cellClick ? 'cursor-pointer' : ''
cellClick ? 'cursor-pointer' : ''
}`}
onClick={() => handleCellClick(index, head.id)}
key={`cell-${head.id}-${index}`}
@@ -40,8 +40,7 @@ export default function UiPageNations(commonPageNationsProps: CommonPageNationsP
<PaginationItem>
<PaginationPrevious
href="#"
onClick={(e) => {
e.preventDefault();
onClick={() => {
if (startPage > 1) handlePageChange(startPage - 1);
}}
/>
@@ -54,9 +53,7 @@ export default function UiPageNations(commonPageNationsProps: CommonPageNationsP
<PaginationLink
href="#"
isActive={pageNum === pageProps.cur}
onClick={(e) => {
e.preventDefault();
handlePageChange(pageNum)}}
onClick={() => handlePageChange(pageNum)}
>
{pageNum}
</PaginationLink>
@@ -68,8 +65,7 @@ export default function UiPageNations(commonPageNationsProps: CommonPageNationsP
<PaginationItem>
<PaginationNext
href="#"
onClick={(e) => {
e.preventDefault();
onClick={() => {
if (endPage < totalPages) handlePageChange(endPage + 1);
}}
/>
@@ -13,14 +13,12 @@ type DatePickerProps = {
placeholder?: string;
disabled?: boolean;
selected?: Date;
zIndex?: number; // z-index prop 추가
} & React.ComponentProps<typeof DayPicker>;
export function DatePicker({
className,
placeholder = "날짜 선택",
disabled,
zIndex, // zIndex prop 받기
...props
}: DatePickerProps) {
return (
@@ -39,10 +37,7 @@ export function DatePicker({
)}
</Button>
</PopoverTrigger>
<PopoverContent
className="w-auto p-0"
style={{ zIndex: zIndex || 'auto' }}
>
<PopoverContent className="w-auto p-0">
<Calendar classNames={{ cell: "rounded-md" }} {...props} />
</PopoverContent>
</Popover>