Merge branch 'iipbs/wr/dev' into iipbs/dm/dev
This commit is contained in:
@@ -53,7 +53,9 @@ function DemandLoginModal({ open, onClose, onSuccess }: LoginModalProps) {
|
||||
|
||||
// ✅ 유효성/서버 에러 표시용
|
||||
const [errors, setErrors] = useState<Partial<Record<FieldKey, string>>>({});
|
||||
const [touched, setTouched] = useState<Partial<Record<FieldKey, boolean>>>({});
|
||||
const [touched, setTouched] = useState<Partial<Record<FieldKey, boolean>>>(
|
||||
{},
|
||||
);
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -99,7 +101,8 @@ function DemandLoginModal({ open, onClose, onSuccess }: LoginModalProps) {
|
||||
|
||||
if (!b) next.bizNo = "사업자등록번호를 입력해주세요.";
|
||||
else if (!isBizNoValid(b))
|
||||
next.bizNo = "사업자등록번호 형식이 올바르지 않습니다. (예: 123-45-67890)";
|
||||
next.bizNo =
|
||||
"사업자등록번호 형식이 올바르지 않습니다. (예: 123-45-67890)";
|
||||
|
||||
if (!noWorker && !w) next.workerNo = "종사자등록번호를 입력해주세요.";
|
||||
|
||||
@@ -115,7 +118,7 @@ function DemandLoginModal({ open, onClose, onSuccess }: LoginModalProps) {
|
||||
const markAllTouched = () =>
|
||||
setTouched({ bizNo: true, workerNo: true, pw: true });
|
||||
|
||||
const submit = async (e: React.FormEvent) => {
|
||||
const submit = async (e: React.SubmitEvent) => {
|
||||
e.preventDefault();
|
||||
markAllTouched();
|
||||
|
||||
@@ -138,7 +141,10 @@ function DemandLoginModal({ open, onClose, onSuccess }: LoginModalProps) {
|
||||
// --- 데모: 비밀번호가 "1234"면 성공 처리(원하면 제거) ---
|
||||
const serverOk = pw.trim() === "1234";
|
||||
if (!serverOk) {
|
||||
setErrors((p) => ({ ...p, pw: "잘못된 비밀번호입니다. (데모: 1234 입력 시 성공)" }));
|
||||
setErrors((p) => ({
|
||||
...p,
|
||||
pw: "잘못된 비밀번호입니다. (데모: 1234 입력 시 성공)",
|
||||
}));
|
||||
setTouched((p) => ({ ...p, pw: true }));
|
||||
return;
|
||||
}
|
||||
@@ -210,7 +216,9 @@ function DemandLoginModal({ open, onClose, onSuccess }: LoginModalProps) {
|
||||
validate();
|
||||
}}
|
||||
placeholder="사업자등록번호를 입력하세요. (예: 123-45-67890)"
|
||||
className={inputCls({ hasError: !!(touched.bizNo && errors.bizNo) })}
|
||||
className={inputCls({
|
||||
hasError: !!(touched.bizNo && errors.bizNo),
|
||||
})}
|
||||
/>
|
||||
{touched.bizNo && errors.bizNo && (
|
||||
<p className="mt-3 text-[14px] font-medium text-red-500">
|
||||
@@ -251,7 +259,8 @@ function DemandLoginModal({ open, onClose, onSuccess }: LoginModalProps) {
|
||||
placeholder="종사자등록번호를 입력하세요."
|
||||
className={inputCls({
|
||||
disabled: noWorker,
|
||||
hasError: !noWorker && !!(touched.workerNo && errors.workerNo),
|
||||
hasError:
|
||||
!noWorker && !!(touched.workerNo && errors.workerNo),
|
||||
})}
|
||||
/>
|
||||
|
||||
@@ -279,7 +288,9 @@ function DemandLoginModal({ open, onClose, onSuccess }: LoginModalProps) {
|
||||
validate();
|
||||
}}
|
||||
placeholder="비밀번호를 입력하세요."
|
||||
className={inputCls({ hasError: !!(touched.pw && errors.pw) })}
|
||||
className={inputCls({
|
||||
hasError: !!(touched.pw && errors.pw),
|
||||
})}
|
||||
/>
|
||||
{touched.pw && errors.pw && (
|
||||
<p className="mt-3 text-[14px] font-medium text-red-500">
|
||||
@@ -305,7 +316,9 @@ function DemandLoginModal({ open, onClose, onSuccess }: LoginModalProps) {
|
||||
{/* 비밀번호 초기화 요청 */}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => alert("TODO: 비밀번호 초기화 요청 화면/기능 연결")}
|
||||
onClick={() =>
|
||||
alert("TODO: 비밀번호 초기화 요청 화면/기능 연결")
|
||||
}
|
||||
className="mx-auto block text-[14px] text-[#767676] hover:text-gray-900"
|
||||
>
|
||||
비밀번호 초기화 요청
|
||||
@@ -439,7 +452,10 @@ export default function TopNav() {
|
||||
) : (
|
||||
<>
|
||||
<span className="text-base text-gray-700">
|
||||
<strong className="text-xl text-emerald-600">{userName}</strong>님 환영합니다.
|
||||
<strong className="text-xl text-emerald-600">
|
||||
{userName}
|
||||
</strong>
|
||||
님 환영합니다.
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
@@ -448,13 +464,13 @@ export default function TopNav() {
|
||||
>
|
||||
로그아웃
|
||||
<span aria-hidden>
|
||||
<Image
|
||||
src="/images/landing/icon_logout.png"
|
||||
alt="로그아웃 아이콘"
|
||||
width={24}
|
||||
height={24}
|
||||
className="h-6 w-6 object-contain"
|
||||
/>
|
||||
<Image
|
||||
src="/images/landing/icon_logout.png"
|
||||
alt="로그아웃 아이콘"
|
||||
width={24}
|
||||
height={24}
|
||||
className="h-6 w-6 object-contain"
|
||||
/>
|
||||
</span>
|
||||
</button>
|
||||
</>
|
||||
|
||||
@@ -7,7 +7,7 @@ import { useEffect, useId, useState } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useDmStore } from "@/app/store";
|
||||
import type { DemandCompType } from "@common/business_components/ui/sdmInsertForm/form";
|
||||
import { sha512 } from 'js-sha512';
|
||||
import { sha512 } from "js-sha512";
|
||||
|
||||
type LoginModalProps = {
|
||||
open: boolean;
|
||||
@@ -24,13 +24,19 @@ function isBizNoValid(v: string) {
|
||||
}
|
||||
|
||||
function inputCls(opts: { hasError?: boolean; disabled?: boolean }) {
|
||||
const base = "h-[48px] w-full rounded-[4px] border px-5 text-[18px] outline-none";
|
||||
const base =
|
||||
"h-[48px] w-full rounded-[4px] border px-5 text-[18px] outline-none";
|
||||
if (opts.disabled) return `${base} border-gray-200 bg-gray-50 text-gray-400`;
|
||||
if (opts.hasError) return `${base} border-red-500 ring-1 ring-red-400 focus:border-red-500`;
|
||||
if (opts.hasError)
|
||||
return `${base} border-red-500 ring-1 ring-red-400 focus:border-red-500`;
|
||||
return `${base} border-gray-300 focus:border-sky-400`;
|
||||
}
|
||||
|
||||
export default function LoginModal({ open, onClose, onSuccess }: LoginModalProps) {
|
||||
export default function LoginModal({
|
||||
open,
|
||||
onClose,
|
||||
onSuccess,
|
||||
}: LoginModalProps) {
|
||||
const titleId = useId();
|
||||
const router = useRouter();
|
||||
const { actionLogin } = useDmStore((state) => state);
|
||||
@@ -42,7 +48,9 @@ export default function LoginModal({ open, onClose, onSuccess }: LoginModalProps
|
||||
|
||||
// ✅ 유효성/서버 에러 표시용
|
||||
const [errors, setErrors] = useState<Partial<Record<FieldKey, string>>>({});
|
||||
const [touched, setTouched] = useState<Partial<Record<FieldKey, boolean>>>({});
|
||||
const [touched, setTouched] = useState<Partial<Record<FieldKey, boolean>>>(
|
||||
{},
|
||||
);
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
|
||||
const resetForm = () => {
|
||||
@@ -74,7 +82,8 @@ export default function LoginModal({ open, onClose, onSuccess }: LoginModalProps
|
||||
}, [open, onClose]);
|
||||
|
||||
useEffect(() => {
|
||||
if (noWorker) { // 종사업자번호 해당없음
|
||||
if (noWorker) {
|
||||
// 종사업자번호 해당없음
|
||||
setWorkerNo(""); // 종사업자번호
|
||||
setErrors((p) => {
|
||||
const nextErrors = { ...p };
|
||||
@@ -132,7 +141,7 @@ export default function LoginModal({ open, onClose, onSuccess }: LoginModalProps
|
||||
const markAllTouched = () =>
|
||||
setTouched({ bizNo: true, workerNo: true, pw: true });
|
||||
|
||||
const submit = async (e: React.FormEvent) => {
|
||||
const submit = async (e: React.SubmitEvent) => {
|
||||
e.preventDefault();
|
||||
markAllTouched();
|
||||
|
||||
@@ -160,8 +169,10 @@ export default function LoginModal({ open, onClose, onSuccess }: LoginModalProps
|
||||
};
|
||||
|
||||
const initPassword = () => {
|
||||
alert("관리자(031-0000-0000)에게 비밀번호 초기화 요청을 유선으로 하시기 바랍니다.");
|
||||
}
|
||||
alert(
|
||||
"관리자(031-0000-0000)에게 비밀번호 초기화 요청을 유선으로 하시기 바랍니다.",
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="fixed inset-0 z-[100]">
|
||||
@@ -222,7 +233,9 @@ export default function LoginModal({ open, onClose, onSuccess }: LoginModalProps
|
||||
validate();
|
||||
}}
|
||||
placeholder="사업자등록번호를 입력하세요. (예: 123-45-67890)"
|
||||
className={inputCls({ hasError: !!(touched.bizNo && errors.bizNo) })}
|
||||
className={inputCls({
|
||||
hasError: !!(touched.bizNo && errors.bizNo),
|
||||
})}
|
||||
/>
|
||||
{touched.bizNo && errors.bizNo && (
|
||||
<p className="mt-3 text-[14px] font-medium text-red-500">
|
||||
@@ -263,7 +276,8 @@ export default function LoginModal({ open, onClose, onSuccess }: LoginModalProps
|
||||
placeholder="종사자등록번호를 입력하세요."
|
||||
className={inputCls({
|
||||
disabled: noWorker,
|
||||
hasError: !noWorker && !!(touched.workerNo && errors.workerNo),
|
||||
hasError:
|
||||
!noWorker && !!(touched.workerNo && errors.workerNo),
|
||||
})}
|
||||
/>
|
||||
|
||||
@@ -291,7 +305,9 @@ export default function LoginModal({ open, onClose, onSuccess }: LoginModalProps
|
||||
validate();
|
||||
}}
|
||||
placeholder="비밀번호를 입력하세요."
|
||||
className={inputCls({ hasError: !!(touched.pw && errors.pw) })}
|
||||
className={inputCls({
|
||||
hasError: !!(touched.pw && errors.pw),
|
||||
})}
|
||||
/>
|
||||
{touched.pw && errors.pw && (
|
||||
<p className="mt-3 text-[14px] font-medium text-red-500">
|
||||
|
||||
Reference in New Issue
Block a user