refactor: common/components 폴더에서 'SITE_ID' 환경변수 쿠키로 대체

This commit is contained in:
2025-06-30 13:39:38 +09:00
parent 622b74db54
commit 855f9b8675
3 changed files with 14 additions and 12 deletions
+5 -2
View File
@@ -1,14 +1,17 @@
import { Client } from "@common/network";
import { getConfig } from "@common/config";
import { getCookie } from "../lib";
const siteId = getCookie("site-id-key") ?? "";
const getClientInstance = () => {
const config = getConfig();
const { PROXY_HOST, SITE_ID } = config;
const { PROXY_HOST } = config;
const BASE_URL = `${PROXY_HOST}/server`;
return Client.getInstance({
baseURL: BASE_URL,
siteId: SITE_ID ?? "",
siteId,
});
};
@@ -1,11 +1,11 @@
import { useEffect, useState } from "react";
import { useQueryClient } from "@tanstack/react-query";
import { getConfig } from "@common/config";
import { getSiteInfo } from "../api/site";
import { getIpList } from "../api/ip";
import { ENDPOINT } from "../config";
import { getCookie } from "../lib";
const { SITE_ID } = getConfig();
const siteId = getCookie("site-id-key") ?? "";
const ClientIpGuard = ({
currentPath,
@@ -29,17 +29,17 @@ const ClientIpGuard = ({
useEffect(() => {
(async () => {
if (!SITE_ID || !clientIp) return;
if (!siteId || !clientIp) return;
const siteInfo = await queryClient.ensureQueryData({
queryKey: [ENDPOINT.CMS_SERVICE.SITES, SITE_ID],
queryFn: () => getSiteInfo(SITE_ID),
queryKey: [ENDPOINT.CMS_SERVICE.SITES, siteId],
queryFn: () => getSiteInfo(siteId),
});
if (siteInfo.siteKndCd === "O") return;
const { content: ipList } = await getIpList({
siteId: SITE_ID,
siteId,
prmYn: "Y",
});
@@ -3,7 +3,6 @@ import "./header.css";
import { useEffect, useCallback } from "react";
import { useQuery } from "@tanstack/react-query";
import { images } from "@common/assets";
import { getConfig } from "@common/config";
import { ENDPOINT } from "../../config";
import { setCookie, getCookie } from "../../lib";
import {
@@ -22,7 +21,7 @@ import {
import { Button } from "../button";
import { SidebarTrigger } from "../sidebar";
const { SITE_ID } = getConfig();
const siteId = getCookie("site-id-key") ?? "";
export function Header({ viewOnly }: { viewOnly?: boolean }) {
const { data: userInfo } = useQuery({
@@ -32,8 +31,8 @@ export function Header({ viewOnly }: { viewOnly?: boolean }) {
});
const { data: siteInfo } = useQuery({
queryKey: [ENDPOINT.CMS_SERVICE.SITES, SITE_ID],
queryFn: () => getSiteInfo(SITE_ID ?? ""),
queryKey: [ENDPOINT.CMS_SERVICE.SITES, siteId],
queryFn: () => getSiteInfo(siteId),
select: (data) => {
if (data.siteSkn) {
const siteSkin = data.siteSkn.toLowerCase();