refactor: provider 레이어 변경 & 누락된 public api 수정
This commit is contained in:
@@ -5,7 +5,7 @@ import {
|
|||||||
REFRESH_TOKEN,
|
REFRESH_TOKEN,
|
||||||
SERVER_API_URL,
|
SERVER_API_URL,
|
||||||
SITE_ID,
|
SITE_ID,
|
||||||
} from "@/shared/config/env";
|
} from "@/shared/config";
|
||||||
import { cookies } from "next/headers";
|
import { cookies } from "next/headers";
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ const nextConfig: NextConfig = {
|
|||||||
"import.meta.env.VITE_AUTH_USER_ID": JSON.stringify(
|
"import.meta.env.VITE_AUTH_USER_ID": JSON.stringify(
|
||||||
process.env.NEXT_PUBLIC_AUTH_USER_ID,
|
process.env.NEXT_PUBLIC_AUTH_USER_ID,
|
||||||
),
|
),
|
||||||
"process.env.SITE_ID": JSON.stringify(process.env.NEXT_PUBLIC_SITE_ID),
|
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import "./styles/base.css";
|
import "./styles/base.css";
|
||||||
import "./styles/components.css";
|
import "./styles/components.css";
|
||||||
import { AppProvider } from "@/shared/provider";
|
import { AppProvider } from "./providers";
|
||||||
|
|
||||||
const App = ({ children }: Readonly<{ children: React.ReactNode }>) => {
|
const App = ({ children }: Readonly<{ children: React.ReactNode }>) => {
|
||||||
return (
|
return (
|
||||||
|
|||||||
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { ConfirmProvider } from "@frontend-opensource/use-react-hooks";
|
import { ConfirmProvider } from "@frontend-opensource/use-react-hooks";
|
||||||
import { AuthProvider } from "./auth-provider";
|
import { AuthProvider } from "@/entities/auth";
|
||||||
import { CookieProvider } from "./cookie-provider";
|
import { CookieProvider } from "@/shared/lib";
|
||||||
import { QueryProvider } from "./query-provider";
|
import { QueryProvider } from "./query-provider";
|
||||||
|
|
||||||
const AppProvider = ({ children }: Readonly<{ children: React.ReactNode }>) => {
|
const AppProvider = ({ children }: Readonly<{ children: React.ReactNode }>) => {
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export { AppProvider } from "./app-provider";
|
||||||
+7
-2
@@ -1,6 +1,11 @@
|
|||||||
import { AxiosError } from "axios";
|
import { AxiosError } from "axios";
|
||||||
import { ENDPOINT, JWT_EXPIRATION_TIME } from "@/shared/config/api";
|
import {
|
||||||
import { ACCESS_TOKEN, AUTH_USER_ID, CLAIM_NAME } from "@/shared/config/env";
|
ENDPOINT,
|
||||||
|
JWT_EXPIRATION_TIME,
|
||||||
|
ACCESS_TOKEN,
|
||||||
|
AUTH_USER_ID,
|
||||||
|
CLAIM_NAME,
|
||||||
|
} from "@/shared/config";
|
||||||
import type { LoginService, ILogin } from "../model/login-interface";
|
import type { LoginService, ILogin } from "../model/login-interface";
|
||||||
import { tokenManager } from "../lib/token-manager";
|
import { tokenManager } from "../lib/token-manager";
|
||||||
|
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
export { LoginApi } from "./api/login-service";
|
||||||
|
export { AuthProvider } from "./lib/auth-provider";
|
||||||
+5
-14
@@ -2,12 +2,11 @@
|
|||||||
|
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import { createContext, useContext, useState } from "react";
|
import { createContext, useState } from "react";
|
||||||
import { client } from "../api/client";
|
import { client } from "@/shared/api";
|
||||||
import { ENDPOINT } from "../config/api";
|
import { ENDPOINT, AUTH_USER_ID } from "@/shared/config";
|
||||||
import { AUTH_USER_ID } from "../config/env";
|
import { getCookie } from "@/shared/lib";
|
||||||
import { getCookie } from "../lib/cookie";
|
import { LoginApi } from "../api/login-service";
|
||||||
import { LoginApi } from "@/entities/auth/login";
|
|
||||||
|
|
||||||
interface IUserInfo {
|
interface IUserInfo {
|
||||||
regDt: string;
|
regDt: string;
|
||||||
@@ -91,11 +90,3 @@ export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
|
|||||||
</AuthContext.Provider>
|
</AuthContext.Provider>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useAuth = (): AuthContextType => {
|
|
||||||
const context = useContext(AuthContext);
|
|
||||||
if (!context) {
|
|
||||||
throw new Error("useAuth must be used within an AuthProvider");
|
|
||||||
}
|
|
||||||
return context;
|
|
||||||
};
|
|
||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
import { AUTH_USER_ID, CLAIM_NAME } from "@/shared/config/env";
|
import { AUTH_USER_ID, CLAIM_NAME } from "@/shared/config";
|
||||||
import { getCookie, setCookie, removeCookie } from "@/shared/lib/cookie";
|
import { getCookie, setCookie, removeCookie } from "@/shared/lib";
|
||||||
|
|
||||||
export class TokenManager {
|
export class TokenManager {
|
||||||
private static instance: TokenManager;
|
private static instance: TokenManager;
|
||||||
@@ -1 +0,0 @@
|
|||||||
export { LoginApi } from "./api/login-service";
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { client } from "@/shared/api/client";
|
import { client } from "@/shared/api";
|
||||||
import { ENDPOINT } from "@/shared/config/api";
|
import { ENDPOINT } from "@/shared/config";
|
||||||
import type { CodeService, ICode } from "../model/code-interface";
|
import type { CodeService, ICode } from "../model/code-interface";
|
||||||
|
|
||||||
export class CodeApiService implements CodeService {
|
export class CodeApiService implements CodeService {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
SelectTrigger,
|
SelectTrigger,
|
||||||
SelectValue,
|
SelectValue,
|
||||||
} from "@common/components";
|
} from "@common/components";
|
||||||
import { ENDPOINT } from "@/shared/config/api";
|
import { ENDPOINT } from "@/shared/config";
|
||||||
import { CodeApi } from "../api/code-service";
|
import { CodeApi } from "../api/code-service";
|
||||||
|
|
||||||
type CodeSelectProps = {
|
type CodeSelectProps = {
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
export { SiteApi } from "./api/site-service";
|
|
||||||
export * from "./model/site-interface";
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
import { client } from "@/shared/api/client";
|
|
||||||
import { ENDPOINT } from "@/shared/config/api";
|
|
||||||
import type { IUser, IUserInfo, UserService } from "../model/user-interface";
|
|
||||||
|
|
||||||
export class UsersApiService implements UserService {
|
|
||||||
public async userInfo(payload: IUser): Promise<IUserInfo> {
|
|
||||||
const response = await client.get<IUserInfo>(
|
|
||||||
`${ENDPOINT.USER_SERVICE.USERS}/${payload.userUniqId}`,
|
|
||||||
);
|
|
||||||
|
|
||||||
return response.data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const UserApi = new UsersApiService();
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
export { useUser } from "./lib/use-user";
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
import { useQuery } from "@tanstack/react-query";
|
|
||||||
import { ENDPOINT } from "@/shared/config/api";
|
|
||||||
import { AUTH_USER_ID } from "@/shared/config/env";
|
|
||||||
import { useCookie } from "@/shared/provider";
|
|
||||||
import { UserApi } from "../api/user-service";
|
|
||||||
|
|
||||||
const useUser = () => {
|
|
||||||
const { getCookie } = useCookie();
|
|
||||||
const { data } = useQuery({
|
|
||||||
queryKey: [ENDPOINT.USER_SERVICE.USERS],
|
|
||||||
queryFn: () =>
|
|
||||||
UserApi.userInfo({
|
|
||||||
userUniqId: getCookie(AUTH_USER_ID) ?? "",
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
|
|
||||||
return { userInfo: data };
|
|
||||||
};
|
|
||||||
|
|
||||||
export { useUser };
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
export interface IUser {
|
|
||||||
userUniqId: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IUserInfo {
|
|
||||||
regDt: string;
|
|
||||||
mdfcnDt: string;
|
|
||||||
rgtr: string;
|
|
||||||
mdfr: string;
|
|
||||||
userUnqId: string;
|
|
||||||
userId: string;
|
|
||||||
userName: string;
|
|
||||||
email: string;
|
|
||||||
encryptedPassword: string;
|
|
||||||
refreshToken: string;
|
|
||||||
userStateCode: string;
|
|
||||||
lastLoginDate: string;
|
|
||||||
loginFailCount: number;
|
|
||||||
pswdHnt: string;
|
|
||||||
pswdAns: string;
|
|
||||||
mphn: string;
|
|
||||||
telno: string;
|
|
||||||
zip: string;
|
|
||||||
addr: string;
|
|
||||||
daddr: string;
|
|
||||||
laeSeCd: string;
|
|
||||||
ogdpSeCd: string;
|
|
||||||
aprvYn: string;
|
|
||||||
autzrId: string;
|
|
||||||
expryYmd: string;
|
|
||||||
lastPswdChgDt: string;
|
|
||||||
googleId: string;
|
|
||||||
kakaoId: string;
|
|
||||||
naverId: string;
|
|
||||||
isSocialUser: boolean;
|
|
||||||
hasPassword: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface UserService {
|
|
||||||
userInfo: (payload: IUser) => Promise<IUserInfo>;
|
|
||||||
}
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import { images } from "@common/assets";
|
import { images } from "@common/assets";
|
||||||
import { LoginApi } from "@/entities/auth/login";
|
import { LoginApi } from "@/entities/auth";
|
||||||
import "./login.css";
|
import "./login.css";
|
||||||
|
|
||||||
function LoginPage() {
|
function LoginPage() {
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
import { client } from "@/shared/api/client";
|
import { client } from "@/shared/api";
|
||||||
import { ENDPOINT } from "@/shared/config/api";
|
import { ENDPOINT } from "@/shared/config";
|
||||||
import {
|
import {
|
||||||
siteFormSchema,
|
siteFormSchema,
|
||||||
type ISiteInfo,
|
type ISiteInfo,
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { createColumnHelper } from "@tanstack/react-table";
|
import { createColumnHelper } from "@tanstack/react-table";
|
||||||
import type { ISite } from "@/entities/site/model/site-interface";
|
import type { ISite } from "./site-interface";
|
||||||
|
|
||||||
const columnHelper = createColumnHelper<ISite>();
|
const columnHelper = createColumnHelper<ISite>();
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ import { useRouter } from "next/navigation";
|
|||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { useMutation } from "@tanstack/react-query";
|
import { useMutation } from "@tanstack/react-query";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { SiteApi, siteFormSchema, type SiteFormData } from "@/entities/site";
|
import { SiteApi } from "../api/site-service";
|
||||||
|
import { siteFormSchema, type SiteFormData } from "../model/site-interface";
|
||||||
import { SitePageLayout } from "./layout";
|
import { SitePageLayout } from "./layout";
|
||||||
import { SiteForm } from "./site-form";
|
import { SiteForm } from "./site-form";
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -5,13 +5,13 @@ import { useRouter } from "next/navigation";
|
|||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
|
import { ENDPOINT } from "@/shared/config";
|
||||||
|
import { SiteApi } from "../api/site-service";
|
||||||
import {
|
import {
|
||||||
SiteApi,
|
|
||||||
siteFormSchema,
|
siteFormSchema,
|
||||||
type ISiteDetail,
|
type ISiteDetail,
|
||||||
type SiteFormData,
|
type SiteFormData,
|
||||||
} from "@/entities/site";
|
} from "../model/site-interface";
|
||||||
import { ENDPOINT } from "@/shared/config/api";
|
|
||||||
import { SitePageLayout } from "./layout";
|
import { SitePageLayout } from "./layout";
|
||||||
import { SiteForm } from "./site-form";
|
import { SiteForm } from "./site-form";
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import {
|
|||||||
TableRow,
|
TableRow,
|
||||||
} from "@common/components";
|
} from "@common/components";
|
||||||
import { CodeSelect } from "@/entities/code";
|
import { CodeSelect } from "@/entities/code";
|
||||||
import { type ISiteDetail, type SiteFormData } from "@/entities/site";
|
|
||||||
import {
|
import {
|
||||||
FormItem,
|
FormItem,
|
||||||
FormControl,
|
FormControl,
|
||||||
@@ -27,6 +26,7 @@ import {
|
|||||||
Form,
|
Form,
|
||||||
FormMessage,
|
FormMessage,
|
||||||
} from "@/shared/ui/form";
|
} from "@/shared/ui/form";
|
||||||
|
import { type ISiteDetail, type SiteFormData } from "../model/site-interface";
|
||||||
import { IPManagementDialog } from "./ip-management-dialog";
|
import { IPManagementDialog } from "./ip-management-dialog";
|
||||||
import {
|
import {
|
||||||
DomainManagementDialog,
|
DomainManagementDialog,
|
||||||
@@ -37,7 +37,7 @@ type SiteFormProps = {
|
|||||||
form: UseFormReturn<SiteFormData>;
|
form: UseFormReturn<SiteFormData>;
|
||||||
siteId?: string;
|
siteId?: string;
|
||||||
handleSave: (data: SiteFormData) => void;
|
handleSave: (data: SiteFormData) => void;
|
||||||
handleDelete: () => void;
|
handleDelete?: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
function SiteForm({ form, siteId, handleSave, handleDelete }: SiteFormProps) {
|
function SiteForm({ form, siteId, handleSave, handleDelete }: SiteFormProps) {
|
||||||
@@ -65,7 +65,7 @@ function SiteForm({ form, siteId, handleSave, handleDelete }: SiteFormProps) {
|
|||||||
|
|
||||||
const onDelete = async () => {
|
const onDelete = async () => {
|
||||||
if (await confirm("정말 삭제하시겠습니까?")) {
|
if (await confirm("정말 삭제하시겠습니까?")) {
|
||||||
handleDelete();
|
handleDelete?.();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -2,15 +2,15 @@
|
|||||||
|
|
||||||
import "@common/assets/styles/grid.css";
|
import "@common/assets/styles/grid.css";
|
||||||
|
|
||||||
import { type ISite, type ISiteParams } from "@/entities/site";
|
import { useRouter } from "next/router";
|
||||||
import { SiteApi } from "@/entities/site/api/site-service";
|
import { useEffect, useState } from "react";
|
||||||
import { ENDPOINT } from "@/shared/config/api";
|
|
||||||
import { Button, DataTable, Input } from "@common/components";
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import { getCoreRowModel, useReactTable } from "@tanstack/react-table";
|
import { getCoreRowModel, useReactTable } from "@tanstack/react-table";
|
||||||
import { useRouter } from "next/router";
|
import { Button, DataTable, Input } from "@common/components";
|
||||||
import { useState } from "react";
|
import { ENDPOINT } from "@/shared/config/api";
|
||||||
|
import { SiteApi } from "../api/site-service";
|
||||||
import { columns } from "../model/table-columns";
|
import { columns } from "../model/table-columns";
|
||||||
|
import { type ISite, type ISiteParams } from "../model/site-interface";
|
||||||
import { SitePageLayout } from "./layout";
|
import { SitePageLayout } from "./layout";
|
||||||
|
|
||||||
function SitePage() {
|
function SitePage() {
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
export { client } from "./client";
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
export * from "./api";
|
||||||
|
export * from "./env";
|
||||||
+2
-10
@@ -1,7 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { createContext, useContext } from "react";
|
import { createContext } from "react";
|
||||||
import { getCookie, setCookie, removeCookie } from "../lib/cookie";
|
import { getCookie, setCookie, removeCookie } from "./cookie";
|
||||||
|
|
||||||
export interface CookieContextType {
|
export interface CookieContextType {
|
||||||
getCookie: (name: string) => string | undefined;
|
getCookie: (name: string) => string | undefined;
|
||||||
@@ -28,11 +28,3 @@ export function CookieProvider({ children }: { children: React.ReactNode }) {
|
|||||||
</CookieContext.Provider>
|
</CookieContext.Provider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useCookie(): CookieContextType {
|
|
||||||
const context = useContext(CookieContext);
|
|
||||||
if (!context) {
|
|
||||||
throw new Error("useCookie must be used within a CookieProvider");
|
|
||||||
}
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
export { CookieProvider } from "./cookie-provider";
|
||||||
|
export { getCookie, setCookie, removeCookie } from "./cookie";
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
export { AppProvider } from "./app-provider";
|
|
||||||
export { useAuth } from "./auth-provider";
|
|
||||||
export { useCookie } from "./cookie-provider";
|
|
||||||
Reference in New Issue
Block a user