From 96448b642785afd83dbc00a3ab58fc6ec7593fd6 Mon Sep 17 00:00:00 2001 From: jyha00 Date: Thu, 31 Jul 2025 17:50:05 +0900 Subject: [PATCH] =?UTF-8?q?=EC=88=98=EC=9A=94=EC=B2=98=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8=20=EC=8B=9C=20=EB=B9=84=EB=B0=80=EB=B2=88?= =?UTF-8?q?=ED=98=B8=20=EC=B4=88=EA=B8=B0=ED=99=94=20=EC=9A=94=EC=B2=AD=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/ui/sdmLoginForm/component.tsx | 147 ++++++++++-------- 1 file changed, 84 insertions(+), 63 deletions(-) diff --git a/apps/dm/components/ui/sdmLoginForm/component.tsx b/apps/dm/components/ui/sdmLoginForm/component.tsx index dd764844b..6f4e2c959 100644 --- a/apps/dm/components/ui/sdmLoginForm/component.tsx +++ b/apps/dm/components/ui/sdmLoginForm/component.tsx @@ -4,8 +4,9 @@ import type { DemandCompType } from "@common/business_components/ui/sdmInsertFor import { Button, Input } from "@common/components"; import { zodResolver } from "@hookform/resolvers/zod"; import { sha512 } from 'js-sha512'; -import { useEffect, useState, useMemo } from "react"; +import { useEffect, useMemo, useState } from "react"; import { FormProvider, useForm, type ControllerRenderProps } from "react-hook-form"; +import toast from "react-hot-toast"; import * as z from "zod"; export function SdmLoginForm() { @@ -15,10 +16,10 @@ export function SdmLoginForm() { 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; @@ -28,18 +29,18 @@ export function SdmLoginForm() { return `${limitedDigits.slice(0, 3)}-${limitedDigits.slice(3, 5)}-${limitedDigits.slice(5)}`; } }; - + // 스키마를 useMemo로 최적화 const sdmLoginFormSchema = useMemo(() => z.object({ dmdInfoId: z.string() .min(1, "사업자등록번호를 입력해주세요") .regex(/^\d{10}$/, "사업자등록번호는 10자리 숫자만 입력 가능합니다"), - bznmTotNo: isBznmTotNoDisabled + bznmTotNo: isBznmTotNoDisabled ? z.string().optional() : z.string().length(4, "종사업자등록번호는 4자리 숫자만 입력 가능합니다"), password: z.string() .min(1, "비밀번호를 입력해주세요") - .min(8, "비밀번호는 8자 이상 입력해주세요") + .min(8, "비밀번호는 8자 이상 입력해주세요") .max(16, "비밀번호는 16자 이내로 입력해주세요"), rgtr: z.string().optional(), dmdAplyPswd: z.string().optional(), @@ -47,7 +48,7 @@ export function SdmLoginForm() { type FormData = z.infer; type FieldComponent = (field: ControllerRenderProps) => JSX.Element; - + const formSchema = sdmLoginFormSchema; useEffect(() => { @@ -72,6 +73,23 @@ export function SdmLoginForm() { setIsBznmTotNoDisabled(checked); }; + const initPassword = () => { + toast( + () => ( +
+
+ 관리자(031-0000-0000)에게 비밀번호 초기화 요청을 유선으로 하시기 바랍니다. +
+
+ ), + { + id: "pwd-reset", + duration: 5000, + position: "top-center", + } + ); + } + const handleLogin = () => { const data = form.getValues(); const passwordStr = sha512.hex(data.password) @@ -82,61 +100,61 @@ export function SdmLoginForm() { } actionLogin(param as unknown as DemandCompType); }; - + const formFields: Array<{ name: keyof FormData; label: string; component: FieldComponent | undefined; }> = [ - { - name: "dmdInfoId", - label: "사업자등록번호", - component: (field) => ( - { - const dmdId = e.target.value.replace(/\D/g, "").slice(0, 10); - field.onChange(dmdId); - }} - /> - ) - }, - { - name: "bznmTotNo", - label: BZNM_TOT_NO || "종사업자등록번호", - component: (field) => ( - - ( + { + const dmdId = e.target.value.replace(/\D/g, "").slice(0, 10); + field.onChange(dmdId); + }} + /> + ) + }, + { + name: "bznmTotNo", + label: BZNM_TOT_NO || "종사업자등록번호", + component: (field) => ( + + + + ) + }, + { + name: "password", + label: "비밀번호", + component: (field) => ( + - - ) - }, - { - name: "password", - label: "비밀번호", - component: (field) => ( - - ) - } - ]; + ) + } + ]; return ( <> @@ -148,11 +166,11 @@ export function SdmLoginForm() { control={form.control} name={name} render={({ field }) => ( - label==='종사업자등록번호' ? - <> + label === '종사업자등록번호' ? + <> {component && component(field)} - : + : {component && component(field)} )} @@ -160,12 +178,15 @@ export function SdmLoginForm() { ))}
- +
+ +
비밀번호 초기화 요청
+