diff --git a/apps/dm_new/app/(with-layout)/apply/dmdco/page.tsx b/apps/dm_new/app/(with-layout)/apply/dmdco/page.tsx index 2bbfa6694..c150ee1f7 100644 --- a/apps/dm_new/app/(with-layout)/apply/dmdco/page.tsx +++ b/apps/dm_new/app/(with-layout)/apply/dmdco/page.tsx @@ -1,55 +1,26 @@ -// app/apply/dmdco/page.tsx "use client"; -import { useMemo, useState } from "react"; +import { useEffect, useMemo, useState, type ReactNode } from "react"; import SubPageHeader from "@/components/SubPageHeader"; +import { useDmStore } from "@/app/store"; +import { fetchType, getFetch, postFetch, putFetch } from "@/components/ui/api"; +import { getCookie } from "@common/components/lib"; type Option = { value: string; label: string }; -type SidoValue = "" | "seoul" | "busan" | "daegu" | "incheon" | "gyeonggi"; -const SIDO: { value: SidoValue; label: string }[] = [ - { value: "", label: "선택" }, - { value: "seoul", label: "서울특별시" }, - { value: "busan", label: "부산광역시" }, - { value: "daegu", label: "대구광역시" }, - { value: "incheon", label: "인천광역시" }, - { value: "gyeonggi", label: "경기도" }, -]; - -const SIGUNGU_MAP: Record = { - "": [{ value: "", label: "선택" }], - seoul: [ - { value: "", label: "선택" }, - { value: "gangnam", label: "강남구" }, - { value: "yeongdeungpo", label: "영등포구" }, - { value: "mapo", label: "마포구" }, - ], - busan: [ - { value: "", label: "선택" }, - { value: "haeundae", label: "해운대구" }, - { value: "suyeong", label: "수영구" }, - ], - daegu: [ - { value: "", label: "선택" }, - { value: "suseong", label: "수성구" }, - { value: "dalseo", label: "달서구" }, - ], - incheon: [ - { value: "", label: "선택" }, - { value: "namdong", label: "남동구" }, - { value: "yeonsu", label: "연수구" }, - ], - gyeonggi: [ - { value: "", label: "선택" }, - { value: "bundang", label: "성남시 분당구" }, - { value: "suji", label: "용인시 수지구" }, - { value: "ilsandong", label: "고양시 일산동구" }, - ], +type SessionUser = { + dmdInfoId?: string; + dmdCoNm?: string; + daddr?: string; + telno?: string; + ctpvCd?: string; + sggCd?: string; + rgtr?: string; + [key: string]: unknown; }; -/* --------------------------- - * register/page.tsx 스타일과 맞춘 공통 UI (FormRow/Divider) - * -------------------------- */ +const TOKEN_ID_COOKIE = "token-id"; +const FALLBACK_UUID = "c475824c-0e82-4a06-a282-2b55a20df265"; function Divider() { return
; @@ -60,13 +31,12 @@ function FormRow({ required, children, }: { - label: React.ReactNode; + label: ReactNode; required?: boolean; - children: React.ReactNode; + children: ReactNode; }) { return (
- {/* 라벨(좌측) */}
{label} @@ -74,10 +44,7 @@ function FormRow({
- {/* 입력(우측) */} -
- {children} -
+
{children}
); } @@ -114,21 +81,21 @@ function TextInput({ ); } -function SelectBox({ +function SelectBox({ value, onChange, options, className = "", }: { - value: T; - onChange: (v: T) => void; - options: { value: T; label: string }[]; + value: string; + onChange: (v: string) => void; + options: Option[]; className?: string; }) { return ( { - setBizNo(e.target.value); + setBizNo(e.target.value.replace(/\D/g, "").slice(0, 10)); setErrors((p) => ({ ...p, bizNo: undefined })); }} onBlur={() => { @@ -257,7 +242,7 @@ export default function LoginModal({ open, onClose, onSuccess }: LoginModalProps { - setWorkerNo(e.target.value); + setWorkerNo(e.target.value.replace(/\D/g, "").slice(0, 4)); setErrors((p) => ({ ...p, workerNo: undefined })); }} onBlur={() => { @@ -315,7 +300,6 @@ export default function LoginModal({ open, onClose, onSuccess }: LoginModalProps ? "bg-sky-300 cursor-not-allowed" : "bg-sky-500 hover:bg-sky-600 active:bg-sky-700", ].join(" ")} - onClick={handleLogin} > {submitting ? "로그인 중..." : "로그인"} diff --git a/apps/dm_new/components/TopNav.tsx b/apps/dm_new/components/TopNav.tsx index 02f60fe5a..c663d1955 100644 --- a/apps/dm_new/components/TopNav.tsx +++ b/apps/dm_new/components/TopNav.tsx @@ -5,8 +5,8 @@ import { usePathname, useRouter } from "next/navigation"; import { useEffect, useMemo, useState } from "react"; import LoginModal from "@/components/LoginModal"; import { fetchAnonymousMenu, isMenuActive, type MenuItem } from "@/app/store/common"; +import { useDmStore } from "@/app/store"; -// const REGISTER_HREF = "/reuse/apply/place"; const LS_TOKEN_KEY = "reuse_accessToken"; const LS_USER_KEY = "reuse_userName"; @@ -21,6 +21,7 @@ export default function TopNav() { const router = useRouter(); const pathname = usePathname(); + const { actionLogout } = useDmStore((state) => state); const [loginOpen, setLoginOpen] = useState(false); const [userName, setUserName] = useState(null); const [topMenus, setTopMenus] = useState([]); @@ -68,11 +69,12 @@ export default function TopNav() { const openLogin = () => setLoginOpen(true); - const logout = () => { + const logout = async () => { localStorage.removeItem(LS_TOKEN_KEY); localStorage.removeItem(LS_USER_KEY); setUserName(null); - router.refresh(); + await actionLogout(); + router.push("/main"); }; return ( diff --git a/apps/dm_new/eslint.config.mjs b/apps/dm_new/eslint.config.mjs index f477f55e1..f5e14ab2c 100644 --- a/apps/dm_new/eslint.config.mjs +++ b/apps/dm_new/eslint.config.mjs @@ -12,6 +12,15 @@ const compat = new FlatCompat({ const eslintConfig = [ ...compat.extends("next/core-web-vitals", "next/typescript"), + { + files: ["**/*.{ts,tsx,mts,cts}"], + languageOptions: { + parserOptions: { + tsconfigRootDir: __dirname, + project: ["./tsconfig.json"], + }, + }, + }, {rules:{ // other rules.. "@typescript-eslint/no-explicit-any": "off",