Merge remote-tracking branch 'origin/iipbs/common/main' into iipbs/wr/gis
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@common/assets",
|
||||
"version": "0.0.0",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.mjs",
|
||||
|
||||
@@ -12,13 +12,14 @@
|
||||
--popover-foreground: #0a0a0a;
|
||||
--primary: #2094fa;
|
||||
--primary-foreground: #fafafa;
|
||||
--primary-transparent: rgba(32, 148, 250, 0.1);
|
||||
--secondary: #f5f5f5;
|
||||
--secondary-foreground: #0f1e33;
|
||||
--muted: #f5f5f5;
|
||||
--muted-foreground: #737373;
|
||||
--accent: #f5f5f5;
|
||||
--accent-foreground: #0f1e33;
|
||||
--destructive: #ff4141;
|
||||
--destructive: #ff6c64;
|
||||
--destructive-foreground: #fafafa;
|
||||
--border: #e5e5e5;
|
||||
--input: #e5e5e5;
|
||||
@@ -54,6 +55,7 @@
|
||||
--popover-foreground: #fafafa;
|
||||
--primary: #2094fa;
|
||||
--primary-foreground: #171717;
|
||||
--primary-transparent: rgba(32, 148, 250, 0.1);
|
||||
--secondary: #262626;
|
||||
--secondary-foreground: #fafafa;
|
||||
--muted: #262626;
|
||||
@@ -87,4 +89,13 @@
|
||||
--container: #0a0a0a;
|
||||
--title: #fff;
|
||||
}
|
||||
[data-theme="red"] {
|
||||
--primary: #ff6464;
|
||||
--destructive: #7388ec;
|
||||
--container: #f6f6f9;
|
||||
}
|
||||
[data-theme="green"] {
|
||||
--primary: #00b9b8;
|
||||
--container: #f2f2f3;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
"use client"
|
||||
import { Bar, BarChart, CartesianGrid, Legend, XAxis, YAxis } from "recharts";
|
||||
import {
|
||||
ChartContainer,
|
||||
ChartTooltip,
|
||||
type ChartConfig
|
||||
} from "./lib/chart";
|
||||
import type { CSSProperties } from "react";
|
||||
|
||||
const customStyles = {
|
||||
legendContainer: {
|
||||
display: "flex",
|
||||
justifyContent: "center",
|
||||
gap: "20px",
|
||||
fontSize: "9px",
|
||||
fontWeight : "bold",
|
||||
marginTop: "10px",
|
||||
} as CSSProperties,
|
||||
};
|
||||
|
||||
type BarChartProps = {
|
||||
chartConfig: ChartConfig | undefined;
|
||||
chartData: any[] | undefined;
|
||||
chartTitle: string;
|
||||
chartClassName?: string;
|
||||
graphSize?: number;
|
||||
yFieldText?: string;
|
||||
showLegend?: boolean;
|
||||
}
|
||||
|
||||
// 커스텀 툴팁
|
||||
const CustomTooltip = ({
|
||||
active,
|
||||
payload,
|
||||
label
|
||||
}: {
|
||||
active?: boolean;
|
||||
payload?: Array<{
|
||||
name: string;
|
||||
value: number;
|
||||
color: string;
|
||||
}>;
|
||||
label?: string;
|
||||
}) => {
|
||||
if (active && payload && payload.length) {
|
||||
return (
|
||||
<div className="w-[180px] rounded bg-white p-2.5 shadow-[0px_2px_10px_rgba(0,0,0,0.2)]">
|
||||
<p className="text-[12px] font-bold m-3">{label}</p>
|
||||
{payload.map((item, index) => (
|
||||
<div key={index} style={{ marginTop: "10px", display: "flex", alignItems: "center", gap: "8px" }}>
|
||||
{/* 색상 박스 추가 (범례 색상과 동일) */}
|
||||
<div style={{ width: "10px", height: "10px", backgroundColor: item.color, borderRadius: "50%" }}></div>
|
||||
<span className="text-[11px] font-bold">{` ${item.name} : ${item.value}`}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
// 커스텀 범례 (글씨 크기 키우기 + 스타일 추가)
|
||||
const CustomLegend = (props: any) => {
|
||||
const { payload } = props;
|
||||
return (
|
||||
<div style={customStyles.legendContainer}>
|
||||
{payload.map((entry: unknown, index: number) => (
|
||||
<div key={`legend-${index}`} className="flex items-center gap-2">
|
||||
<div className="w-[14px] h-[14px] ml-10" style={{ backgroundColor: (entry as {color: string}).color }}></div>
|
||||
<span className="text-[12px]">{(entry as {value: string}).value}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default function DoubleBarChart({chartConfig=undefined, chartData=[], chartTitle='차트', chartClassName='w-full h-full', graphSize=40, yFieldText='', showLegend=false} : BarChartProps) {
|
||||
const colors = ["#FF6B6B", "#4ECDC4", "#45B7D1", "#96CEB4", "#FFEEAD", "#D4A5A5"];
|
||||
const getMaxValue = (data: any[], keyPrefix: string) => {
|
||||
return Math.max(...data.map(item =>
|
||||
Object.keys(item)
|
||||
.filter(key => key.includes(keyPrefix))
|
||||
.map(key => item[key])
|
||||
).flat());
|
||||
};
|
||||
console.log(chartData);
|
||||
const barMaxValue = getMaxValue(chartData, 'barVal');
|
||||
return (
|
||||
<>
|
||||
{chartTitle && chartTitle !== "" && chartTitle !== "undefined" ? (
|
||||
<div className="text-left text-[13px] font-bold mt-[13px] mb-[10px]">
|
||||
{chartTitle}
|
||||
</div>): null}
|
||||
<div className="flex justify-center">
|
||||
<ChartContainer config={chartConfig ?? {}} className={chartClassName + " !w-[90%]"}>
|
||||
<BarChart accessibilityLayer data={chartData}>
|
||||
<CartesianGrid vertical={false} />
|
||||
<XAxis
|
||||
dataKey="label"
|
||||
tickLine={true}
|
||||
tickMargin={10}
|
||||
axisLine={true}
|
||||
fontSize={13}
|
||||
fontWeight={500}
|
||||
/>
|
||||
<YAxis
|
||||
tickLine={true}
|
||||
tickMargin={10}
|
||||
tickCount={6}
|
||||
axisLine={true}
|
||||
fontSize={12}
|
||||
fontWeight={500}
|
||||
domain={[0, Math.ceil(barMaxValue * 1)]}
|
||||
label={yFieldText ? { value: yFieldText, className:"text-[13px] font-bold", position: 'insideLeft', angle: -90, offset: 20 } : undefined}
|
||||
/>
|
||||
<ChartTooltip cursor={false} content={<CustomTooltip active={undefined} payload={undefined} label={undefined} />}/>
|
||||
{chartData && chartData.length > 0 && (
|
||||
Object.keys(chartData[0])
|
||||
.filter(key => key !== "label")
|
||||
.map((key, idx) => (
|
||||
<Bar
|
||||
dataKey={key}
|
||||
radius={5}
|
||||
key={key}
|
||||
stackId="a"
|
||||
barSize={graphSize}
|
||||
fill={colors[idx]}
|
||||
/>
|
||||
))
|
||||
)}
|
||||
{showLegend && <Legend content={CustomLegend}/>}
|
||||
</BarChart>
|
||||
</ChartContainer>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -1,27 +1,116 @@
|
||||
"use client"
|
||||
|
||||
import { Pie, PieChart } from "recharts";
|
||||
|
||||
import type { CSSProperties } from "react";
|
||||
import {
|
||||
Card,
|
||||
CardContent
|
||||
} from "./lib/card";
|
||||
import {
|
||||
ChartContainer,
|
||||
ChartTooltip,
|
||||
ChartTooltipContent,
|
||||
type ChartConfig
|
||||
} from "./lib/chart";
|
||||
import { ChartContainer, ChartTooltip } from "./lib/chart";
|
||||
|
||||
// eslint-disable-next-line react-refresh/only-export-components
|
||||
export default (props: { chartConfig: ChartConfig; chartData: never[] | undefined; chartTitle:string}) =>{
|
||||
type ChartDataItem = {
|
||||
label: string;
|
||||
val: number;
|
||||
};
|
||||
|
||||
type ChartConfigItem = {
|
||||
label: string;
|
||||
fill: string;
|
||||
};
|
||||
|
||||
type ChartConfig = {
|
||||
[key: string]: ChartConfigItem;
|
||||
};
|
||||
|
||||
type TooltipPayloadItem = {
|
||||
name: string;
|
||||
value: number;
|
||||
payload: {
|
||||
label: string;
|
||||
val: number;
|
||||
fill: string;
|
||||
};
|
||||
};
|
||||
|
||||
type LegendEntry = {
|
||||
value: string;
|
||||
fill: string;
|
||||
type?: string;
|
||||
payload: {
|
||||
label: string;
|
||||
val: number;
|
||||
fill: string;
|
||||
};
|
||||
};
|
||||
|
||||
type LegendProps = {
|
||||
payload?: LegendEntry[];
|
||||
};
|
||||
|
||||
/** 차트 기본 스타일 */
|
||||
const customStyles = {
|
||||
legendContainer: {
|
||||
display: "flex",
|
||||
justifyContent: "center",
|
||||
gap: "20px",
|
||||
fontSize: "9px",
|
||||
fontWeight: "bold",
|
||||
marginTop: "10px",
|
||||
} as CSSProperties,
|
||||
};
|
||||
|
||||
// 커스텀 툴팁
|
||||
const CustomTooltip = ({ active, payload, label }: {
|
||||
active?: boolean;
|
||||
payload?: TooltipPayloadItem[];
|
||||
label?: string
|
||||
}) => {
|
||||
if (active && payload && payload.length) {
|
||||
return (
|
||||
<div className="w-[180px] rounded bg-white p-2.5 shadow-[0px_2px_10px_rgba(0,0,0,0.2)]">
|
||||
<p className="text-[12px] font-bold m-3">{label}</p>
|
||||
{payload.map((item, index) => (
|
||||
<div key={index} style={{ marginTop: "10px", display: "flex", alignItems: "center", gap: "8px" }}>
|
||||
<div style={{ width: "10px", height: "10px", backgroundColor: item.payload.fill, borderRadius: "50%" }}></div>
|
||||
<span className="text-[11px] font-bold">{` ${item.name} : ${item.value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}`}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
// 커스텀 범례
|
||||
const CustomLegend = (props: LegendProps) => {
|
||||
const { payload } = props;
|
||||
if (!payload) return null;
|
||||
|
||||
return (
|
||||
<div style={customStyles.legendContainer}>
|
||||
{payload.map((entry: LegendEntry, index: number) => (
|
||||
<div key={`legend-${index}`} className="flex items-center gap-2">
|
||||
<div className="w-[14px] h-[14px] ml-10" style={{ backgroundColor: entry.fill }}></div>
|
||||
<span className="text-[12px]">{entry.value}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default function DoughnutChart(props: {
|
||||
chartConfig: ChartConfig;
|
||||
chartData: ChartDataItem[] | undefined;
|
||||
chartTitle: string
|
||||
}) {
|
||||
return (
|
||||
<Card className="flex flex-col">
|
||||
<CardContent className="flex-1 pb-0">
|
||||
{props.chartTitle && props.chartTitle !== "" && props.chartTitle !== "undefined" ? (
|
||||
<div style={{ textAlign: "left", fontSize: "13px", fontWeight: "bold", marginTop:"13px", marginBottom: "10px" }}>
|
||||
{props.chartTitle}
|
||||
</div>): null}
|
||||
{props.chartTitle && props.chartTitle !== "" && props.chartTitle !== "undefined" ? (
|
||||
<div style={{ textAlign: "left", fontSize: "13px", fontWeight: "bold", marginTop:"13px", marginBottom: "10px" }}>
|
||||
{props.chartTitle}
|
||||
</div>
|
||||
) : null}
|
||||
<div className="h-[calc(100%-42px)] justify-center">
|
||||
<ChartContainer
|
||||
config={props.chartConfig}
|
||||
@@ -30,18 +119,22 @@ export default (props: { chartConfig: ChartConfig; chartData: never[] | undefine
|
||||
<PieChart>
|
||||
<ChartTooltip
|
||||
cursor={false}
|
||||
content={<ChartTooltipContent hideLabel />}
|
||||
content={<CustomTooltip />}
|
||||
/>
|
||||
<Pie
|
||||
data={props.chartData}
|
||||
data={props.chartData?.map(item => ({
|
||||
...item,
|
||||
fill: props.chartConfig[item.label]?.fill || 'blue'
|
||||
}))}
|
||||
dataKey="val"
|
||||
nameKey="label"
|
||||
innerRadius={60}
|
||||
/>
|
||||
<CustomLegend />
|
||||
</PieChart>
|
||||
</ChartContainer>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -92,9 +92,6 @@ export default function LineBarchart({
|
||||
return <div>데이터가 없습니다.</div>;
|
||||
}
|
||||
|
||||
const barConfig = chartConfig?.barVal;
|
||||
const lineConfig = chartConfig?.lineVal;
|
||||
|
||||
// 데이터의 최대값 계산
|
||||
const getMaxValue = (data: any[], keyPrefix: string) => {
|
||||
return Math.max(...data.map(item =>
|
||||
|
||||
@@ -5,6 +5,7 @@ import DoughnutChart from './DoughnutChart';
|
||||
import { type ChartConfig } from './lib/chart';
|
||||
import LineChart from './LineChart';
|
||||
import LineBarchart from './LineBarChart';
|
||||
import DoubleBarChart from './DoubleBar';
|
||||
|
||||
/**차트 FORM */
|
||||
const CHART_FORM = {
|
||||
@@ -15,7 +16,9 @@ const CHART_FORM = {
|
||||
/**도넛 차트 형태*/
|
||||
DN :'daughnut',
|
||||
/**LINE,BAR차트 */
|
||||
LINEBAR : 'linebar'
|
||||
LINEBAR : 'linebar',
|
||||
/**더블바 차트 형태*/
|
||||
DOUBLEBAR : 'doublebar'
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -34,7 +37,7 @@ const CHART_FORM = {
|
||||
|
||||
type MainChartProps = {
|
||||
chartForm: string;
|
||||
chartConfig: any;
|
||||
chartConfig: ChartConfig;
|
||||
chartData: any;
|
||||
chartTitle: string;
|
||||
chartClassName?: string;
|
||||
@@ -47,23 +50,23 @@ type MainChartProps = {
|
||||
function MainChart(props: MainChartProps) {
|
||||
if( props.chartForm == CHART_FORM.BAR ){
|
||||
return (
|
||||
<BarChart chartConfig={props.chartConfig} chartData={props.chartData} chartTitle={props.chartTitle} chartClassName={props.chartClassName} graphSize={props.graphSize} yFieldText={props.yFieldText} showLegend={props.showLegend}>
|
||||
</BarChart>
|
||||
<BarChart chartConfig={props.chartConfig} chartData={props.chartData} chartTitle={props.chartTitle} chartClassName={props.chartClassName} graphSize={props.graphSize} yFieldText={props.yFieldText} showLegend={props.showLegend}/>
|
||||
);
|
||||
} else if( props.chartForm == CHART_FORM.LINE ){
|
||||
return (
|
||||
<LineChart chartConfig={props.chartConfig} chartData={props.chartData} chartTitle={props.chartTitle} chartClassName={props.chartClassName} graphSize={props.graphSize} yFieldText={props.yFieldText} showLegend={props.showLegend}>
|
||||
</LineChart>
|
||||
<LineChart chartConfig={props.chartConfig} chartData={props.chartData} chartTitle={props.chartTitle} chartClassName={props.chartClassName} graphSize={props.graphSize} yFieldText={props.yFieldText} showLegend={props.showLegend}/>
|
||||
);
|
||||
} else if( props.chartForm == CHART_FORM.DN ){
|
||||
return (
|
||||
<DoughnutChart chartConfig={props.chartConfig} chartData={props.chartData} chartTitle={props.chartTitle}>
|
||||
</DoughnutChart>
|
||||
<DoughnutChart chartConfig={props.chartConfig} chartData={props.chartData} chartTitle={props.chartTitle}/>
|
||||
);
|
||||
} else if (props.chartForm == CHART_FORM.LINEBAR){
|
||||
return (
|
||||
<LineBarchart chartConfig={props.chartConfig} chartData={props.chartData} chartTitle={props.chartTitle} chartClassName={props.chartClassName} graphSize={props.graphSize} yFieldText={props.yFieldText} yFieldText2={props.yFieldText2} showLegend={props.showLegend}>
|
||||
</LineBarchart>
|
||||
<LineBarchart chartConfig={props.chartConfig} chartData={props.chartData} chartTitle={props.chartTitle} chartClassName={props.chartClassName} graphSize={props.graphSize} yFieldText={props.yFieldText} yFieldText2={props.yFieldText2} showLegend={props.showLegend}/>
|
||||
);
|
||||
} else if (props.chartForm == CHART_FORM.DOUBLEBAR){
|
||||
return (
|
||||
<DoubleBarChart chartConfig={props.chartConfig} chartData={props.chartData} chartTitle={props.chartTitle} chartClassName={props.chartClassName} graphSize={props.graphSize} yFieldText={props.yFieldText} showLegend={props.showLegend}/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ const FormUi = React.forwardRef<HTMLDivElement, FormUiProps>(
|
||||
checked={isChecked}
|
||||
onCheckedChange={handleCheckboxChange}
|
||||
/>
|
||||
<label className="w-20 text-xl text-gray-600" htmlFor="check">해당없음</label>
|
||||
<label className="w-28 text-xl text-gray-600" htmlFor="check">해당없음</label>
|
||||
</div>
|
||||
</div>
|
||||
{children}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
export default function MainDiv(props: {children: React.ReactNode}) {
|
||||
return (
|
||||
<div className="h-auto bg-container">
|
||||
<div className="min-h-[89vh] bg-container">
|
||||
{props.children}
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { Search } from 'lucide-react';
|
||||
import './lib/css/gis.common.css';
|
||||
import React, { createContext, useContext, useEffect, useMemo, useRef, useState, useCallback } from 'react';
|
||||
import OlMap from 'ol/Map';
|
||||
import View from 'ol/View';
|
||||
import { defaults as defaultControls, OverviewMap } from 'ol/control';
|
||||
@@ -6,7 +8,9 @@ import { defaults } from 'ol/interaction';
|
||||
import * as olProj from 'ol/proj';
|
||||
import { register } from 'ol/proj/proj4';
|
||||
import proj4 from 'proj4';
|
||||
import React, { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import GisApp from './lib/gis.core';
|
||||
import GisContent from './GisContent';
|
||||
import GisTree from './GisTree';
|
||||
import GisLonLat from './GisLonLat';
|
||||
import GisMapToggle from './GisMapToggle';
|
||||
import GisSelect from './GisSelect';
|
||||
@@ -188,7 +192,6 @@ function Gis({
|
||||
//setEditLayerItems(prev => [...layerItems])
|
||||
}, [treeData]);
|
||||
|
||||
// 레이어 코드에서 편집 가능한 레이어만 추출
|
||||
const getLayerItems = (layerCode) => {
|
||||
const layerItems = Object.entries(layerCode)
|
||||
.filter(([key, obj], idx) => obj?.updtPsblYn === 'Y')
|
||||
|
||||
@@ -13,20 +13,20 @@ export default React.memo(function MapToggleBtn() {
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="mapbtn" style={{ zIndex: 101 }}>
|
||||
<button className="sprite_gis viewer" title="지도선택">지도 선택</button>
|
||||
<ul className="choice_map">
|
||||
<li className={activeMap.type === 'base' ? 'on' : ''}>
|
||||
<button className="map1" id="base" title="일반지도" onClick={() => handleSelect({ label: '일반', type: 'base' })}>
|
||||
<div>일반지도</div>
|
||||
</button>
|
||||
</li>
|
||||
<li className={activeMap.type === 'satellite' ? 'on' : ''}>
|
||||
<button className="map2" id="satelite" title="위성지도" onClick={() => handleSelect({ label: '위성', type: 'satellite' })}>
|
||||
<div>위성지도</div>
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div className="mapbtn">
|
||||
<button className="sprite_gis viewer" title="지도선택">지도 선택</button>
|
||||
<ul className="choice_map">
|
||||
<li className={activeMap.type === 'base' ? 'on' : ''}>
|
||||
<button className="map1" id="base" title="일반지도" onClick={() => handleSelect({ label: '일반', type: 'base' })}>
|
||||
<div>일반지도</div>
|
||||
</button>
|
||||
</li>
|
||||
<li className={activeMap.type === 'satellite' ? 'on' : ''}>
|
||||
<button className="map2" id="satelite" title="위성지도" onClick={() => handleSelect({ label: '위성', type: 'satellite' })}>
|
||||
<div>위성지도</div>
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
import React from 'react';
|
||||
|
||||
export default function GisSearch() {
|
||||
return (
|
||||
<div className="p-2">
|
||||
<p>범례 영역입니다 (향후 컴포넌트로 교체 가능)</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,81 +1,85 @@
|
||||
import React, { useState } from 'react';
|
||||
import { Tabs, TabsList, TabsTrigger } from '@common/components/ui/tabs';
|
||||
import GisTree from './GisTree';
|
||||
import GisSearch from './GisSearch';
|
||||
import { ChevronLeft, ChevronRight, Search } from 'lucide-react';
|
||||
import SearchModal from '@/map/SearchModal';
|
||||
// import React, { useState } from 'react';
|
||||
// import { Tabs, TabsList, TabsTrigger } from '@common/components/ui/tabs';
|
||||
// import GisTree from './GisTree';
|
||||
// import GisSearch from './GisSearch';
|
||||
// import { ChevronLeft, ChevronRight, Search } from 'lucide-react';
|
||||
// import SearchModal from '@/map/SearchModal';
|
||||
|
||||
|
||||
function GisTab({ visible, setVisible, isSearch, isSearchModalOpen, setIsSearchModalOpen }) {
|
||||
const [activeTab, setActiveTab] = useState('layers');
|
||||
// function GisTab({ visible, setVisible, isSearch, isSearchModalOpen, setIsSearchModalOpen, onFeatureSelect }) {
|
||||
// const [activeTab, setActiveTab] = useState('layers');
|
||||
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
className={`absolute top-0 left-0 w-[250px] h-[calc(100vh-10rem)] bg-white border-r border-gray-300 flex flex-col overflow-hidden transition-all duration-300 z-40
|
||||
${visible ? 'translate-x-0 opacity-100' : '-translate-x-full opacity-0 pointer-events-none'}`}
|
||||
>
|
||||
<Tabs value={activeTab} onValueChange={setActiveTab} className="flex-1 flex flex-col overflow-hidden">
|
||||
<TabsList className="flex-none mt-4 border-none rounded-none">
|
||||
<TabsTrigger value="layers" className="flex-1 h-10">레이어</TabsTrigger>
|
||||
{isSearch && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setIsSearchModalOpen(true)}
|
||||
className="h-10 w-10 flex items-center justify-center px-0"
|
||||
>
|
||||
<Search size={18} className="text-gray-700" />
|
||||
</button>
|
||||
// <TabsTrigger value="search" className="flex-1 h-10 flex items-center justify-center">
|
||||
// <Search size={18} />
|
||||
// </TabsTrigger>
|
||||
)}
|
||||
</TabsList>
|
||||
// return (
|
||||
// <>
|
||||
// <div
|
||||
// className={`absolute top-0 left-0 w-[250px] h-[calc(100vh-10rem)] bg-white border-r border-gray-300 flex flex-col overflow-hidden transition-all duration-300 z-40
|
||||
// ${visible ? 'translate-x-0 opacity-100' : '-translate-x-full opacity-0 pointer-events-none'}`}
|
||||
// >
|
||||
// <Tabs value={activeTab} onValueChange={setActiveTab} className="flex-1 flex flex-col overflow-hidden">
|
||||
// <TabsList className="flex-none mt-4 border-none rounded-none">
|
||||
// <TabsTrigger value="layers" className="flex-1 h-10">레이어</TabsTrigger>
|
||||
// {/* {isSearch && (
|
||||
// <button
|
||||
// type="button"
|
||||
// onClick={() => setIsSearchModalOpen(true)}
|
||||
// className="h-10 w-10 flex items-center justify-center px-0"
|
||||
// >
|
||||
// <Search size={18} className="text-gray-700" />
|
||||
// </button>
|
||||
// // <TabsTrigger value="search" className="flex-1 h-10 flex items-center justify-center">
|
||||
// // <Search size={18} />
|
||||
// // </TabsTrigger>
|
||||
// )} */}
|
||||
// </TabsList>
|
||||
|
||||
{/* GisTree는 항상 마운트되며, 탭 상태에 따라 보여주기만 함 */}
|
||||
<div
|
||||
className={`grow overflow-y-auto p-2 pt-0 border-none shadow-none ${activeTab === 'layers' ? 'block' : 'hidden'
|
||||
}`}
|
||||
>
|
||||
<GisTree />
|
||||
</div>
|
||||
// {/* GisTree는 항상 마운트되며, 탭 상태에 따라 보여주기만 함 */}
|
||||
// <div
|
||||
// className={`grow overflow-y-auto p-2 pt-0 border-none shadow-none ${activeTab === 'layers' ? 'block' : 'hidden'
|
||||
// }`}
|
||||
// >
|
||||
// <GisTree />
|
||||
// </div>
|
||||
|
||||
{/* GisSearch도 동일하게 처리 */}
|
||||
{/* {isSearch && (
|
||||
<div
|
||||
className={`grow overflow-y-auto p-2 pt-0 border-none shadow-none ${
|
||||
activeTab === 'search' ? 'block' : 'hidden'
|
||||
}`}
|
||||
>
|
||||
<GisSearch />
|
||||
</div>
|
||||
)} */}
|
||||
// {/* GisSearch도 동일하게 처리 */}
|
||||
// {/* {isSearch && (
|
||||
// <div
|
||||
// className={`grow overflow-y-auto p-2 pt-0 border-none shadow-none ${
|
||||
// activeTab === 'search' ? 'block' : 'hidden'
|
||||
// }`}
|
||||
// >
|
||||
// <GisSearch />
|
||||
// </div>
|
||||
// )} */}
|
||||
|
||||
|
||||
{/* 🔍 검색 모달 */}
|
||||
<SearchModal open={isSearchModalOpen} onOpenChange={setIsSearchModalOpen} />
|
||||
</Tabs>
|
||||
// {/* 🔍 검색 모달 */}
|
||||
// {/* <SearchModal
|
||||
// open={isSearchModalOpen}
|
||||
// onOpenChange={setIsSearchModalOpen}
|
||||
// onFeatureSelect={onFeatureSelect}
|
||||
// /> */}
|
||||
// </Tabs>
|
||||
|
||||
{/* 접기 버튼 */}
|
||||
<button
|
||||
onClick={() => setVisible(false)}
|
||||
className="absolute top-1/2 right-[-3px] transform -translate-y-1/2 z-50 bg-white border border-l border-gray-300 rounded-l-none rounded-r px-1 py-2 shadow-sm"
|
||||
>
|
||||
<ChevronLeft size={16} />
|
||||
</button>
|
||||
</div>
|
||||
// {/* 접기 버튼 */}
|
||||
// <button
|
||||
// onClick={() => setVisible(false)}
|
||||
// className="absolute top-1/2 right-[-3px] transform -translate-y-1/2 z-50 bg-white border border-l border-gray-300 rounded-l-none rounded-r px-1 py-2 shadow-sm"
|
||||
// >
|
||||
// <ChevronLeft size={16} />
|
||||
// </button>
|
||||
// </div>
|
||||
|
||||
{/* 열기 버튼 */}
|
||||
{!visible && (
|
||||
<button
|
||||
onClick={() => setVisible(true)}
|
||||
className="absolute top-1/2 left-[-3px] transform -translate-y-1/2 z-50 bg-white border border-r border-gray-300 rounded-r px-1 py-2 shadow-sm"
|
||||
>
|
||||
<ChevronRight size={16} />
|
||||
</button>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
// {/* 열기 버튼 */}
|
||||
// {!visible && (
|
||||
// <button
|
||||
// onClick={() => setVisible(true)}
|
||||
// className="absolute top-1/2 left-[-3px] transform -translate-y-1/2 z-50 bg-white border border-r border-gray-300 rounded-r px-1 py-2 shadow-sm"
|
||||
// >
|
||||
// <ChevronRight size={16} />
|
||||
// </button>
|
||||
// )}
|
||||
// </>
|
||||
// );
|
||||
// }
|
||||
|
||||
export default React.memo(GisTab);
|
||||
// export default React.memo(GisTab);
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import GisApp from './lib/gis.core';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { useGisContext } from './Gis';
|
||||
import { DndProvider } from "react-dnd";
|
||||
import {
|
||||
MultiBackend,
|
||||
Tree,
|
||||
getBackendOptions
|
||||
} from "@minoru/react-dnd-treeview";
|
||||
import { ChevronLeft, ChevronRight } from 'lucide-react';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { DndProvider } from "react-dnd";
|
||||
import { useGisContext } from './Gis';
|
||||
import GisApp from './lib/gis.core';
|
||||
|
||||
export default React.memo(function GisTree({ checkedNodes = [], setCheckedNodes = () => { }, visible, setVisible }) {
|
||||
const { gisCore, treeData } = useGisContext();
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import OLCesium from 'olcs/OLCesium';
|
||||
import olView from 'ol/View.js';
|
||||
import olSourceImageWMS from 'ol/source/ImageWMS.js';
|
||||
import olSourceOSM from 'ol/source/OSM.js';
|
||||
import olLayerImage from 'ol/layer/Image.js';
|
||||
import olLayerTile from 'ol/layer/Tile.js';
|
||||
import olMap from 'ol/Map.js';
|
||||
import { GLOBAL } from '../../js/consts/global';
|
||||
|
||||
const Google3DMap = () => {
|
||||
const mapRef = useRef(null);
|
||||
const [ol3d, setOl3d] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!mapRef.current) return;
|
||||
|
||||
const customProjSource = new olSourceImageWMS({
|
||||
attributions: '© <a href="http://www.geo.admin.ch/internet/geoportal/en/home.html">National parks / geo.admin.ch</a>',
|
||||
crossOrigin: 'anonymous',
|
||||
params: { LAYERS: 'ch.bafu.schutzgebiete-paerke_nationaler_bedeutung' },
|
||||
projection: 'EPSG:21781',
|
||||
url: 'https://wms.geo.admin.ch/',
|
||||
});
|
||||
|
||||
const { Cesium } = window;
|
||||
Cesium.Ion.defaultAccessToken = GLOBAL.CESIUM_ION_TOKEN;
|
||||
|
||||
const ol2d = new olMap({
|
||||
layers: [new olLayerTile({ source: new olSourceOSM() }), new olLayerImage({ source: customProjSource })],
|
||||
target: mapRef.current,
|
||||
view: new olView({
|
||||
center: [860434.6266531206, 6029479.0044273855],
|
||||
zoom: 6,
|
||||
}),
|
||||
});
|
||||
|
||||
const ol3dInstance = new OLCesium({
|
||||
map: ol2d,
|
||||
time: () => Cesium.JulianDate.now(),
|
||||
});
|
||||
|
||||
const scene = ol3dInstance.getCesiumScene();
|
||||
Cesium.createWorldTerrainAsync().then(tp => {
|
||||
scene.terrainProvider = tp;
|
||||
});
|
||||
|
||||
ol3dInstance.setEnabled(true);
|
||||
setOl3d(ol3dInstance);
|
||||
|
||||
return () => {
|
||||
ol3dInstance.setEnabled(false);
|
||||
ol2d.setTarget(null);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return <div ref={mapRef} style={{ width: '100%', height: '100vh' }} />;
|
||||
};
|
||||
|
||||
export default Google3DMap;
|
||||
@@ -9,6 +9,7 @@
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
right: 20px;
|
||||
z-index: 2;
|
||||
}
|
||||
.mapbtn h3 {
|
||||
overflow: hidden;
|
||||
@@ -304,7 +305,7 @@
|
||||
bottom: 40px;
|
||||
right: 200px;
|
||||
display: inline-block;
|
||||
z-index: 101;
|
||||
z-index: 2;
|
||||
list-style: none;
|
||||
}
|
||||
.map-scale-area li {
|
||||
@@ -1003,7 +1004,7 @@ table.board-table tbody th td {
|
||||
.gis-content .evl-legends{
|
||||
bottom: -20px !important;
|
||||
left: 1350px;
|
||||
z-index: 101;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -13,7 +13,12 @@ import { Fill, Stroke, Style } from 'ol/style';
|
||||
import CircleStyle from 'ol/style/Circle';
|
||||
import VectorLayer from 'ol/layer/Vector';
|
||||
import { Point } from 'ol/geom';
|
||||
import { boundingExtent } from 'ol/extent';
|
||||
import { getTopLeft } from 'ol/extent';
|
||||
import TileWMTS from 'ol/source/WMTS';
|
||||
import WMTSTileGrid from 'ol/tilegrid/WMTS';
|
||||
// import { get as getProjection } from 'ol/proj';
|
||||
import proj4 from 'proj4';
|
||||
import { register } from 'ol/proj/proj4';
|
||||
import olSourceImageWMS from 'ol/source/ImageWMS';
|
||||
import { GeoJSON } from 'ol/format';
|
||||
import GisOlEditLayer from './gis.edit';
|
||||
@@ -26,31 +31,34 @@ const GisApp = {};
|
||||
//레이어 정보
|
||||
GisApp.layerInfos = [];
|
||||
//기본정보
|
||||
GisApp.GEOSERVER_URL = 'http://rsone.iptime.org:10010/geoserver/hasudo/ows';
|
||||
GisApp.GEOSERVER_WMS_URL = 'http://rsone.iptime.org:10010/geoserver/hasudo/wms';
|
||||
// GisApp.GEOSERVER_URL = '/sn/geoserver/hasudo/ows';
|
||||
// GisApp.GEOSERVER_WMS_URL = '/sn/geoserver/hasudo/wms';
|
||||
// GisApp.GEOSERVER_URL = '/geoserver/hasudo/ows';
|
||||
// GisApp.SN_GEOSERVER_URL = '/sewerage-service/api/v1/map/geometry';
|
||||
// GisApp.GEOSERVER_WMS_URL = '/geoserver/hasudo/wms';
|
||||
//GisApp.GEOSERVER_URL = 'http://rsone.iptime.org:10010/geoserver/hasudo/ows';
|
||||
//GisApp.GEOSERVER_WMS_URL = 'http://rsone.iptime.org:10010/geoserver/hasudo/wms';
|
||||
GisApp.GEOSERVER_URL = '/geoserver/hasudo/ows';
|
||||
GisApp.SN_GEOSERVER_URL = '/sewerage-service/api/v1/map/geometry';
|
||||
GisApp.GEOSERVER_WMS_URL = '/geoserver/hasudo/wms';
|
||||
|
||||
//맵 정보
|
||||
GisApp.EMAP_URL = '/emap/';
|
||||
GisApp.EMAP_SATELLITE_URL = '/emap/satellite/';
|
||||
GisApp.VWORLD_URL = 'https://xdworld.vworld.kr/2d/Base/service/{z}/{x}/{y}.png';
|
||||
GisApp.VWORLD_SATELLITE_URL = 'https://xdworld.vworld.kr/2d/Satellite/service/{z}/{x}/{y}.jpeg';
|
||||
GisApp.GOOGLE_API_KEY = 'AIzaSyCf1sgeELFalfPuqlykRKBMj6X9u_DQH6M';
|
||||
GisApp.GOOGLE_ROADMAP_URL = `https://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}&key=${GisApp.GOOGLE_API_KEY}`;
|
||||
GisApp.GOOGLE_SATELLITE_URL = `https://mt1.google.com/vt/lyrs=s&x={x}&y={y}&z={z}&key=${GisApp.GOOGLE_API_KEY}`;
|
||||
GisApp.GOOGLE_HYBRID_URL = `https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}&key=${GisApp.GOOGLE_API_KEY}`;
|
||||
GisApp.GOOGLE_3D_URL = `https://tile.googleapis.com/v1/3dtiles/root.json?key=${GisApp.GOOGLE_API_KEY}`;
|
||||
|
||||
// TODO: NGII 정보
|
||||
GisApp.NGII_API_KEY = '04trYP9_xwLAfALjwZ-B8g'; // NGII에서 발급받은 API 키
|
||||
GisApp.NGII_WMTS_URL = `https://map.ngii.go.kr/openapi/Gettile.do?apikey=${GisApp.NGII_API_KEY}`;
|
||||
|
||||
GisApp.EMAP_URL = '/emap/';
|
||||
GisApp.EMAP_SATELLITE_URL = '/emap/satellite/';
|
||||
GisApp.VWORLD_URL = 'https://xdworld.vworld.kr/2d/Base/service/{z}/{x}/{y}.png';
|
||||
GisApp.VWORLD_SATELLITE_URL = 'https://xdworld.vworld.kr/2d/Satellite/service/{z}/{x}/{y}.jpeg';
|
||||
GisApp.OPENSTREET_URL = '//tile.openstreetmap.org/{z}/{x}/{y}.png';
|
||||
GisApp.BASE_MAP_TYPES = [];
|
||||
|
||||
GisApp.FROM_PROJ = 'EPSG:4326';
|
||||
GisApp.TO_PROJ = 'EPSG:3857';
|
||||
// GisApp.TO_PROJ = 'EPSG:3857';
|
||||
GisApp.TO_PROJ = 'EPSG:5179'; //ngii 좌표계
|
||||
GisApp.TO_DATA_PROJ = 'EPSG:4326';
|
||||
// GisApp.CONTEXT_LAYER_PATH = '/sn/images/map/layericon/';
|
||||
GisApp.CONTEXT_LAYER_PATH = '/images/map/layericon/';
|
||||
GisApp.layerCode = {};
|
||||
GisApp.hlLayerId = 'LightFeatureList';
|
||||
@@ -86,10 +94,11 @@ GisApp.core.prototype = {
|
||||
target: '',
|
||||
centerX: 37.2806094,
|
||||
centerY: 127.0032502,
|
||||
zoom: 11,
|
||||
minZoom: 5,
|
||||
maxZoom: 22,
|
||||
zoom: 12,
|
||||
minZoom: 6,
|
||||
maxZoom: 20,
|
||||
},
|
||||
|
||||
options: {
|
||||
/*1: { zoom: 16, minZoom: 10, maxZoom: 22, centerX: 35.3227711, centerY: 129.1836202, dataProj: 'EPSG:5186' },
|
||||
4: { zoom: 16, minZoom: 10, maxZoom: 22, centerX: 35.0140499, centerY: 126.7110757, dataProj: 'EPSG:5186' },
|
||||
@@ -113,11 +122,14 @@ GisApp.core.prototype = {
|
||||
GisApp.Module.core = this;
|
||||
GisApp.Module.layer = new GisOlLayer(this.defaults);
|
||||
GisApp.Module.edit = new GisOlEditLayer(this.defaults);
|
||||
|
||||
this.baseMiniMapLayers['base'] = this.getBaseMap('minimap-base');
|
||||
this.baseLayers['base'] = this.getBaseMap('base');
|
||||
this.baseLayers['satellite'] = this.getBaseMap('satellite');
|
||||
this.baseLayers['3d'] = this.getBaseMap('3d');
|
||||
// TODO: vworld layer 정보 (getNGIIbaseMap)활성화 하면 ngii base map으로 변경됨
|
||||
// this.baseMiniMapLayers['base'] = this.getBaseMap('minimap-base');
|
||||
// this.baseLayers['base'] = this.getBaseMap('base');
|
||||
// this.baseLayers['satellite'] = this.getBaseMap('satellite');
|
||||
// this.baseLayers['3d'] = this.getBaseMap('3d');
|
||||
this.baseLayers['base'] = this.getNGIIBaseMap('base','korean_map');
|
||||
this.baseLayers['satellite'] = this.getNGIIBaseMap('satellite','satellite_map');
|
||||
this.baseMiniMapLayers['base'] = this.getNGIIBaseMap('minimap-base','korean_map');
|
||||
},
|
||||
layerType: {
|
||||
point: 'POINT',
|
||||
@@ -130,6 +142,45 @@ GisApp.core.prototype = {
|
||||
this.setCenter(Number(this.defaults.centerX), Number(this.defaults.centerY));
|
||||
this.setZoom(15);
|
||||
},
|
||||
// NGII Base Map
|
||||
getNGIIBaseMap: function (_id, _layer) {
|
||||
// EPSG:5179 정의 및 등록이 필요함 (아래에 설명 추가)
|
||||
proj4.defs([['EPSG:5179','+proj=tmerc +lat_0=38 +lon_0=127.5 +k=0.9996 +x_0=1000000 +y_0=2000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs',],]);
|
||||
register(proj4);
|
||||
const projection = olProj.get('EPSG:5179');
|
||||
projection.setExtent([-200000.0, -28024123.62, 31824123.62, 4000000.0]);
|
||||
|
||||
// const resolutions = [2088.96, 1044.48, 522.24, 261.12, 130.56, 65.28, 32.64, 16.32, 8.16, 4.08, 2.04, 1.02, 0.51, 0.255];
|
||||
// const matrixIds = ["L05", "L06", "L07", "L08", "L09", "L10", "L11", "L12", "L13", "L14", "L15", "L16", "L17", "L18"];
|
||||
const resolutions = [1044.48, 522.24, 261.12, 130.56, 65.28, 32.64, 16.32, 8.16, 4.08, 2.04, 1.02, 0.51, 0.255];
|
||||
const matrixIds = ["L06", "L07", "L08", "L09", "L10", "L11", "L12", "L13", "L14", "L15", "L16", "L17", "L18"];
|
||||
|
||||
const wmtsSource = new TileWMTS({
|
||||
url: GisApp.NGII_WMTS_URL,
|
||||
layer: _layer,
|
||||
matrixSet: 'EPSG:5179',
|
||||
format: 'image/png',
|
||||
projection: projection,
|
||||
style: 'korean',
|
||||
tileGrid: new WMTSTileGrid({
|
||||
origin: getTopLeft(projection.getExtent()),
|
||||
resolutions: resolutions,
|
||||
matrixIds: matrixIds,
|
||||
tileSize: [256, 256]
|
||||
}),
|
||||
requestEncoding: 'KVP',
|
||||
crossOrigin: 'anonymous'
|
||||
});
|
||||
|
||||
let baseMap = new TileLayer({
|
||||
id: _id,
|
||||
visible: true,
|
||||
type: 'base',
|
||||
source: wmtsSource,
|
||||
zIndex: 0
|
||||
});
|
||||
return baseMap;
|
||||
},
|
||||
getBaseMap: function (_id) {
|
||||
let url = GisApp.VWORLD_URL;
|
||||
if (_id === 'satellite') {
|
||||
@@ -186,7 +237,7 @@ GisApp.core.prototype = {
|
||||
setCenter: function (x, y, transYn) {
|
||||
if (!x || !y) return;
|
||||
let view = this.map.getView();
|
||||
|
||||
|
||||
if (!transYn) {
|
||||
// 값이 없으면
|
||||
let center = olProj.transform([Number(y), Number(x)], GisApp.FROM_PROJ, GisApp.TO_PROJ);
|
||||
@@ -562,7 +613,7 @@ GisApp.core.prototype = {
|
||||
*/
|
||||
convertLayerInfosToLayerCode: function (array, key, parentName) {
|
||||
let initialValue = {};
|
||||
|
||||
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
let item = {};
|
||||
Object.assign(item, array[i]);
|
||||
|
||||
@@ -72,11 +72,18 @@ GisOlLayer.prototype = {
|
||||
* [사용]WFS 벡터 소스 반환
|
||||
*/
|
||||
getVectorSourceGeoserver: function (options) {
|
||||
const url = GisApp.GEOSERVER_URL;
|
||||
const toProj = GisApp.TO_PROJ;
|
||||
const lyrTyNm = options.lyrTyNm;
|
||||
let url = GisApp.GEOSERVER_URL;
|
||||
let toProj = GisApp.TO_PROJ;
|
||||
let lyrTyNm = options.lyrTyNm;
|
||||
let typename = this.storageNm + lyrTyNm;
|
||||
|
||||
if(options.lyrTyNm == "om_dt_untrt_swg_rain"){ //중점우수토실실
|
||||
url = GisApp.SN_GEOSERVER_URL;
|
||||
typename = lyrTyNm;
|
||||
}
|
||||
|
||||
const params = {};
|
||||
params['TYPENAME'] = this.storageNm + lyrTyNm;
|
||||
params['TYPENAME'] = typename;
|
||||
params['SERVICE'] = 'WFS';
|
||||
params['VERSION'] = '1.1.0';
|
||||
params['REQUEST'] = 'GetFeature';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import GisApp from './gis.core';
|
||||
import _ from 'lodash';
|
||||
import Style from 'ol/style/Style.js';
|
||||
import { click, mouseOnly, never } from 'ol/events/condition';
|
||||
import DragBox from 'ol/interaction/DragBox.js';
|
||||
@@ -11,7 +10,6 @@ import VectorSource from 'ol/source/Vector.js';
|
||||
import CircleStyle from 'ol/style/Circle.js';
|
||||
import Fill from 'ol/style/Fill.js';
|
||||
import Stroke from 'ol/style/Stroke.js';
|
||||
//import DOMPurify from 'dompurify';
|
||||
|
||||
const GisOlSelect = function (map, options) {
|
||||
GisApp.select = {};
|
||||
@@ -34,7 +32,7 @@ GisOlSelect.prototype = {
|
||||
selectFeatureFlag: false,
|
||||
initialize: function (map, options) {
|
||||
this.map = map;
|
||||
_.extend(this.defaults, options);
|
||||
Object.assign(this.defaults, options);
|
||||
this.setInteraction();
|
||||
this.pointerMoveEventHandler();
|
||||
},
|
||||
|
||||
@@ -8,8 +8,6 @@ import Text from 'ol/style/Text.js';
|
||||
import Point from 'ol/geom/Point.js';
|
||||
import RegularShape from 'ol/style/RegularShape.js';
|
||||
import Overlay from 'ol/Overlay';
|
||||
import _ from 'lodash';
|
||||
//import DOMPurify from 'dompurify';
|
||||
import { createPortal } from 'react-dom';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import React from 'react';
|
||||
@@ -90,13 +88,13 @@ GisOlStyle.prototype = {
|
||||
}
|
||||
|
||||
let baseResolution = 20;
|
||||
let minScale = 0.3;
|
||||
let minScale = 0.4;
|
||||
let maxScale = 1.5;
|
||||
let scale = baseResolution / resolution > maxScale ? maxScale : baseResolution / resolution;
|
||||
scale = Math.max(minScale, Math.min(maxScale, scale));
|
||||
image.setScale(scale);
|
||||
style.setImage(image);
|
||||
_.extend(style, options);
|
||||
Object.assign(style, options);
|
||||
return style;
|
||||
},
|
||||
line: function (layer, options, feature, resolution) {
|
||||
@@ -125,7 +123,7 @@ GisOlStyle.prototype = {
|
||||
color,
|
||||
});
|
||||
style.setFill(fill);
|
||||
_.extend(style, options);
|
||||
Object.assign(style, options);
|
||||
return style;
|
||||
},
|
||||
lineLabelPoligon: function (layer, options, feature, resolution) {
|
||||
@@ -152,7 +150,7 @@ GisOlStyle.prototype = {
|
||||
}
|
||||
style.setFill(fill);
|
||||
style.setStroke(stroke);
|
||||
_.extend(style, options);
|
||||
Object.assign(style, options);
|
||||
return style;
|
||||
},
|
||||
imagePoligon: function (layer, options, feature, resolution) {
|
||||
@@ -169,8 +167,7 @@ GisOlStyle.prototype = {
|
||||
image.setScale(1);
|
||||
style.setGeometry(retGeom);
|
||||
style.setImage(image);
|
||||
|
||||
_.extend(style, options);
|
||||
Object.assign(style, options);
|
||||
return style;
|
||||
},
|
||||
setOverlay: function (layer, feature, overlayHtml) {
|
||||
@@ -267,7 +264,7 @@ GisOlStyle.prototype = {
|
||||
style.setStroke(null);
|
||||
style.setFill(null);
|
||||
style.setText(text);
|
||||
_.extend(style, options);
|
||||
Object.assign(style, options);
|
||||
|
||||
return style;
|
||||
},
|
||||
|
||||
@@ -2,10 +2,43 @@
|
||||
import { SelectBox } from "../select";
|
||||
import { Input } from "@common/components";
|
||||
import { FormUi } from "../form_ui";
|
||||
import { useCallback, useState } from "react";
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import type { ControllerRenderProps, UseFormReturn } from "react-hook-form";
|
||||
import { SdmSearchForm } from "./sdmNameBox";
|
||||
import type { DemandCompType } from "../../../../../../apps/dm/app/store/sdmMng";
|
||||
import { set } from "date-fns";
|
||||
|
||||
// 수요처 정보
|
||||
export type DemandCompType = {
|
||||
index : number | '';
|
||||
dmdInfoPk : string | '';
|
||||
dmdInfoFk : string | '';
|
||||
bzmnNo : string | '';
|
||||
dmdCoNm : string | '';
|
||||
daddr : string | '';
|
||||
telno : string | '';
|
||||
rgtr : string | '';
|
||||
useUsgCd : string | '';
|
||||
ctpvCd : string | '';
|
||||
sggCd : string | '';
|
||||
dmdAplyPswd : string | '';
|
||||
wntUntprc : number | '';
|
||||
dmndTmng : Date | '';
|
||||
dmndQty : number | '';
|
||||
grssClfg : number | '';
|
||||
tn : number | '';
|
||||
combResdch : number | '';
|
||||
tph : number | '';
|
||||
trbt : number | '';
|
||||
ph : number | '';
|
||||
blgcOxygDmndQnt : number | '';
|
||||
clIonQnt : number | '';
|
||||
smll : number | '';
|
||||
cdtnv : number | '';
|
||||
crmty : number | '';
|
||||
rmrk : string | '';
|
||||
reqDt : string | '';
|
||||
}
|
||||
|
||||
|
||||
type SelectDataType = {
|
||||
text: string;
|
||||
@@ -32,16 +65,19 @@ interface SdmRegFormProps {
|
||||
dataList: DemandCompType[];
|
||||
rtnValue: (searchText: string, pageCnt: number) => void;
|
||||
setIsDuplicate: (value: boolean) => void;
|
||||
updateList?:DemandCompType
|
||||
}
|
||||
|
||||
type FieldComponent = (field: ControllerRenderProps<FormSchema, keyof FormSchema>) => JSX.Element;
|
||||
|
||||
export function SdmRegForm({ form, onCheckboxChange, selectSidoData, selectSigunData, dataList, rtnValue, setIsDuplicate }: SdmRegFormProps) {
|
||||
export function SdmRegForm({ form, onCheckboxChange, selectSidoData, selectSigunData, dataList, rtnValue, setIsDuplicate ,updateList}: SdmRegFormProps) {
|
||||
const [sidoValue, setSidoValue] = useState<string>('');
|
||||
const [sigunValue, setSigunValue] = useState<string>('');
|
||||
const [filteredSigunData, setFilteredSigunData] = useState<SelectDataType[]>([{ text: "전체", val: '0' }]);
|
||||
const [isBznmTotNoDisabled, setIsBznmTotNoDisabled] = useState(true);
|
||||
const [orgBznmNo, setOrgBznmNo] = useState<string>('');
|
||||
const [updateCoNm, setUpdateNm] = useState<string >('')
|
||||
|
||||
|
||||
const initializeSigunData = useCallback((sidoCd: string) => {
|
||||
if (sidoCd === '0') {
|
||||
@@ -62,6 +98,7 @@ export function SdmRegForm({ form, onCheckboxChange, selectSidoData, selectSigun
|
||||
type: string,
|
||||
field: ControllerRenderProps<FormSchema, keyof FormSchema> | undefined
|
||||
) => {
|
||||
if(!updateList?.dmdInfoPk)
|
||||
switch (type) {
|
||||
case "ctpvCd":
|
||||
initializeSigunData(val);
|
||||
@@ -77,7 +114,7 @@ export function SdmRegForm({ form, onCheckboxChange, selectSidoData, selectSigun
|
||||
form.setValue('bznmTotNo', '');
|
||||
break;
|
||||
}
|
||||
}, [initializeSigunData, form]);
|
||||
}, [initializeSigunData, form,updateList]);
|
||||
|
||||
const handleCheckboxChange = useCallback((checked: boolean) => {
|
||||
setIsBznmTotNoDisabled(checked);
|
||||
@@ -90,6 +127,7 @@ export function SdmRegForm({ form, onCheckboxChange, selectSidoData, selectSigun
|
||||
|
||||
const setRtnData = useCallback((item: DemandCompType) => {
|
||||
const rtnCompData = item;
|
||||
|
||||
form.setValue('dmdCoNm', rtnCompData?.dmdCoNm || '');
|
||||
form.setValue('dmdInfoPk', rtnCompData?.dmdInfoPk.substring(0,10) || '');
|
||||
form.setValue('bznmTotNo', rtnCompData?.dmdInfoPk.substring(10,14)==='0000' ? '' : rtnCompData?.dmdInfoPk.substring(10,14));
|
||||
@@ -124,26 +162,46 @@ export function SdmRegForm({ form, onCheckboxChange, selectSidoData, selectSigun
|
||||
form.setValue('dmdCoNm', text);
|
||||
}, [form]);
|
||||
|
||||
const bznNoChange = useCallback((e: React.ChangeEvent<HTMLInputElement>, noType: string) => {
|
||||
const bznNoChange = useCallback((e: React.ChangeEvent<HTMLInputElement>, noType: string, field?: ControllerRenderProps<FormSchema, keyof FormSchema>) => {
|
||||
const value = e.target.value;
|
||||
|
||||
|
||||
if(noType === 'dmdInfoPk') {
|
||||
if(orgBznmNo.substring(0,10) === value) {
|
||||
setIsDuplicate(true);
|
||||
} else {
|
||||
setIsDuplicate(false);
|
||||
}
|
||||
form.setValue('dmdInfoPk', value);
|
||||
field?.onChange(value);
|
||||
} else {
|
||||
if(orgBznmNo.substring(10,14) === value) {
|
||||
setIsDuplicate(true);
|
||||
} else {
|
||||
setIsDuplicate(false);
|
||||
}
|
||||
form.setValue('bznmTotNo', value);
|
||||
field?.onChange(value);
|
||||
}
|
||||
}, [orgBznmNo, setIsDuplicate]);
|
||||
|
||||
}, [form, orgBznmNo, setIsDuplicate]);
|
||||
|
||||
useEffect(() => {
|
||||
if(updateList?.dmdInfoPk){
|
||||
form.reset(updateList)
|
||||
if(updateList?.dmdInfoPk.slice(10,14) !== '0000') {
|
||||
handleCheckboxChange( false);
|
||||
form.setValue('bznmTotNo', updateList?.dmdInfoPk.slice(10,14));
|
||||
} else {
|
||||
handleCheckboxChange( true);
|
||||
}
|
||||
form.setValue('dmdInfoPk', updateList?.dmdInfoPk.slice(0,10));
|
||||
setUpdateNm(updateList?.dmdCoNm)
|
||||
// setSigunValue(updateList?.sggCd)
|
||||
}else{
|
||||
handleCheckboxChange( true);
|
||||
}
|
||||
}, [updateList,form]);
|
||||
|
||||
useEffect(() => {
|
||||
},[form.formState.errors])
|
||||
|
||||
const formFields: Array<{
|
||||
name: keyof FormSchema;
|
||||
@@ -154,28 +212,51 @@ export function SdmRegForm({ form, onCheckboxChange, selectSidoData, selectSigun
|
||||
name: "ctpvCd",
|
||||
label: "시도",
|
||||
component: (field) => (
|
||||
<SelectBox
|
||||
updateList?.dmdInfoPk ? (
|
||||
<Input
|
||||
placeholder="시도"
|
||||
type="text"
|
||||
className="!text-xl text-gray-600"
|
||||
onChange={(e) =>{field.onChange(e.target.value)} }
|
||||
value={ selectSidoData.find(item => item.val === field.value?.trim() )?.text??''}
|
||||
readOnly={!!updateList?.dmdInfoPk}
|
||||
/>
|
||||
) : (
|
||||
<SelectBox
|
||||
selectClass={undefined}
|
||||
label=""
|
||||
selectArray={selectSidoData}
|
||||
onSelectValue={(val) => onSelectValue(val.toString(), 'ctpvCd', field)}
|
||||
onSelectValue={(val) => onSelectValue(val.toString(), 'ctpvCd', field??'')}
|
||||
className=""
|
||||
value={sidoValue}
|
||||
/>
|
||||
)
|
||||
)
|
||||
},
|
||||
{
|
||||
name: "sggCd",
|
||||
label: "시군구",
|
||||
component: (field) => (
|
||||
updateList?.dmdInfoPk ? (
|
||||
<Input
|
||||
placeholder="시도"
|
||||
type="text"
|
||||
className="!text-xl text-gray-600"
|
||||
onChange={(e) =>{field.onChange(e.target.value)} }
|
||||
value={selectSigunData.find(item => item.val === field.value?.trim() )?.text??''}
|
||||
readOnly={!!updateList?.dmdInfoPk}
|
||||
/>
|
||||
) : (
|
||||
<SelectBox
|
||||
selectClass={undefined}
|
||||
selectClass={"!text-xl text-gray-600"}
|
||||
label=""
|
||||
selectArray={filteredSigunData}
|
||||
onSelectValue={(val) => onSelectValue(val.toString(), 'sggCd', field)}
|
||||
className=""
|
||||
value={sigunValue}
|
||||
/>
|
||||
|
||||
)
|
||||
)
|
||||
},
|
||||
{
|
||||
@@ -185,7 +266,7 @@ export function SdmRegForm({ form, onCheckboxChange, selectSidoData, selectSigun
|
||||
<SdmSearchForm
|
||||
rtnData={setRtnData}
|
||||
label="수요처명"
|
||||
initValue={''}
|
||||
initValue={updateCoNm}
|
||||
dataList={dataList}
|
||||
rtnValue={setRtnValue}
|
||||
rtnText={setRtnText}
|
||||
@@ -201,8 +282,9 @@ export function SdmRegForm({ form, onCheckboxChange, selectSidoData, selectSigun
|
||||
placeholder="사업자등록번호를 입력하세요"
|
||||
type="text"
|
||||
className="!text-xl text-gray-600"
|
||||
{...field}
|
||||
onChange={(e) => bznNoChange(e, 'dmdInfoPk')}
|
||||
onChange={(e) => bznNoChange(e, 'dmdInfoPk', field)}
|
||||
value={field.value}
|
||||
readOnly={!!updateList?.dmdInfoPk}
|
||||
/>
|
||||
)
|
||||
},
|
||||
@@ -220,8 +302,10 @@ export function SdmRegForm({ form, onCheckboxChange, selectSidoData, selectSigun
|
||||
type="text"
|
||||
className="!mt-5 !text-xl text-gray-600"
|
||||
disabled={isBznmTotNoDisabled}
|
||||
{...field}
|
||||
onChange={(e) => bznNoChange(e, 'bznmTotNo')}
|
||||
onChange={(e) => bznNoChange(e, 'bznmTotNo', field)}
|
||||
// {...field}
|
||||
value={ field.value}
|
||||
readOnly={!!updateList?.dmdInfoPk}
|
||||
/>
|
||||
</FormUi>
|
||||
)
|
||||
@@ -250,6 +334,7 @@ export function SdmRegForm({ form, onCheckboxChange, selectSidoData, selectSigun
|
||||
/>
|
||||
)
|
||||
},
|
||||
|
||||
{
|
||||
name: "dmdAplyPswd",
|
||||
label: "패스워드",
|
||||
@@ -262,11 +347,18 @@ export function SdmRegForm({ form, onCheckboxChange, selectSidoData, selectSigun
|
||||
/>
|
||||
)
|
||||
}
|
||||
];
|
||||
]
|
||||
|
||||
return (
|
||||
<>
|
||||
{formFields.map(({ name, label, component }) => (
|
||||
{formFields.filter((item)=>
|
||||
{if(updateList?.dmdInfoPk){
|
||||
return item.name !== 'dmdAplyPswd'
|
||||
}else{
|
||||
return item
|
||||
}
|
||||
})
|
||||
.map(({ name, label, component }) => (
|
||||
<FormField
|
||||
key={String(name)}
|
||||
control={form.control}
|
||||
|
||||
@@ -1,32 +1,14 @@
|
||||
"use client";
|
||||
|
||||
/* import { useDmStore } from "@/app/store"; */
|
||||
import { SdmRegForm } from "./form";
|
||||
import { SdmRegForm, type DemandCompType } from "./form";
|
||||
import { Button } from "@common/components/ui";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
/* import { useRouter } from "next/navigation"; */
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import { FormProvider, useForm, type SubmitHandler } from "react-hook-form";
|
||||
import { toast, Toaster } from "sonner";
|
||||
/* import { Toaster, toast } from "react-hot-toast"; */
|
||||
import * as z from "zod";
|
||||
import type { SelectDataType } from "../search_input_select";
|
||||
|
||||
|
||||
export type DemandCompType = {
|
||||
dmdInfoPk : string | '';
|
||||
bzmnNo : string | '';
|
||||
dmdCoNm : string | '';
|
||||
daddr : string | '';
|
||||
telno : string | '';
|
||||
rgtr : string | '';
|
||||
useUsgCd : string | '';
|
||||
ctpvCd : string | '';
|
||||
sggCd : string | '';
|
||||
dmdAplyPswd: string | '';
|
||||
}
|
||||
|
||||
|
||||
type thisProps = {
|
||||
selectSidoData: SelectDataType[];
|
||||
selectSigunData: SelectDataType[];
|
||||
@@ -34,9 +16,10 @@ type thisProps = {
|
||||
rtnValue: (searchText: string, pageCnt: number) => void;
|
||||
rtnInputData: (data: DemandCompType) => void;
|
||||
bodyClassNm?: string;
|
||||
updateList?:DemandCompType
|
||||
}
|
||||
|
||||
const createFormSchema = (isBznmTotNoDisabled: boolean, isDuplicate: boolean) => z.object({
|
||||
const createFormSchema = (isBznmTotNoDisabled: boolean, isDuplicate: boolean ,updateList?:DemandCompType) => z.object({
|
||||
ctpvCd: z.string().min(1, "시/도를 선택해주세요"),
|
||||
sggCd: z.string().min(1, "시/군/구를 선택해주세요"),
|
||||
dmdCoNm: z.string()
|
||||
@@ -57,19 +40,19 @@ const createFormSchema = (isBznmTotNoDisabled: boolean, isDuplicate: boolean) =>
|
||||
.max(40, "주소는 40자 이내로 입력해주세요"),
|
||||
telno: z.string()
|
||||
.min(8, "전화번호는 8자 이상 입력해주세요")
|
||||
.max(12, "전화번호는 12자 이내로 입력해주세요")
|
||||
.max(11, "전화번호는 11자 이내로 입력해주세요")
|
||||
.regex(/^[0-9-]+$/, "전화번호는 숫자와 하이픈(-)만 입력 가능합니다"),
|
||||
rgtr: z.string().optional(),
|
||||
dmdAplyPswd : z.string()
|
||||
.min(1, "패스워드를 입력해주세요")
|
||||
.min(8, "패스워드는 8자 이상 입력해주세요")
|
||||
.max(16, "패스워드는 16자 이내로 입력해주세요"),
|
||||
dmdAplyPswd : updateList?.dmdInfoPk // 업데이트일경우
|
||||
? z.string().optional() // 패스워드는 선택 사항이며 길이 제한 없음
|
||||
: z.string().optional()
|
||||
.refine((val) => !val || (val.length >= 8 && val.length <= 16), "패스워드는 8자 이상 16자 이내로 입력해주세요"),
|
||||
|
||||
});
|
||||
|
||||
type FormSchema = ReturnType<typeof createFormSchema>;
|
||||
export type FormData = z.infer<FormSchema>;
|
||||
type FormSchema = z.infer<ReturnType<typeof createFormSchema>>;
|
||||
|
||||
const defaultValues: FormData = {
|
||||
const defaultValues: FormSchema = {
|
||||
ctpvCd: '',
|
||||
sggCd: '',
|
||||
dmdCoNm: '',
|
||||
@@ -78,7 +61,7 @@ const defaultValues: FormData = {
|
||||
daddr: '',
|
||||
telno: '',
|
||||
rgtr: "3fa85f64-5717-4562-b3fc-2c963f66afa6",
|
||||
dmdAplyPswd : '',
|
||||
dmdAplyPswd: '',
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -117,15 +100,15 @@ const defaultValues: FormData = {
|
||||
}, [insertSdmData]);
|
||||
*/
|
||||
|
||||
export default function SdmInsertForm({selectSidoData, selectSigunData, dataList, rtnValue, rtnInputData,bodyClassNm}: thisProps) {
|
||||
export default function SdmInsertForm({selectSidoData, selectSigunData, dataList, rtnValue, rtnInputData,bodyClassNm, updateList}: thisProps) {
|
||||
/* const { insertSdmData } = useDmStore((state) => state);
|
||||
const router = useRouter(); */
|
||||
|
||||
const [isBznmTotNoDisabled, setIsBznmTotNoDisabled] = useState(true);
|
||||
const [isBznmTotNoDisabled, setIsBznmTotNoDisabled] = useState(false);
|
||||
const [isDuplicate, setIsDuplicate] = useState(false);
|
||||
const formSchema = createFormSchema(isBznmTotNoDisabled, isDuplicate);
|
||||
const formSchema = createFormSchema(isBznmTotNoDisabled, isDuplicate, updateList );
|
||||
|
||||
const form = useForm<z.infer<FormSchema>>({
|
||||
const form = useForm<FormSchema>({
|
||||
resolver: zodResolver(formSchema),
|
||||
defaultValues,
|
||||
mode: "onChange",
|
||||
@@ -136,7 +119,7 @@ export default function SdmInsertForm({selectSidoData, selectSigunData, dataList
|
||||
|
||||
// 체크박스 상태가 변경될 때마다 bznmTotNo 필드의 에러를 초기화
|
||||
useEffect(() => {
|
||||
if (isBznmTotNoDisabled) {
|
||||
if (isBznmTotNoDisabled===true) {
|
||||
form.clearErrors('bznmTotNo');
|
||||
form.setValue('bznmTotNo', '');
|
||||
}
|
||||
@@ -146,7 +129,7 @@ export default function SdmInsertForm({selectSidoData, selectSigunData, dataList
|
||||
rtnValue(searchText, pageCnt);
|
||||
}, [rtnValue]);
|
||||
|
||||
const onSubmit: SubmitHandler<z.infer<FormSchema>> = async (data) => {
|
||||
const onSubmit: SubmitHandler<FormSchema> = async (data) => {
|
||||
try {
|
||||
// form 에러 체크
|
||||
const formErrors = form.formState.errors;
|
||||
@@ -160,27 +143,18 @@ export default function SdmInsertForm({selectSidoData, selectSigunData, dataList
|
||||
const formData = {
|
||||
...data,
|
||||
dmdInfoPk,
|
||||
bzmnNo: data.dmdInfoPk,
|
||||
};
|
||||
|
||||
console.log(' formData ', formData)
|
||||
|
||||
console.log(formData);
|
||||
/* await insertSdmData(formData); */
|
||||
rtnInputData(formData as DemandCompType);
|
||||
|
||||
const queryParams = new URLSearchParams({
|
||||
dmdCoNm: data.dmdCoNm,
|
||||
ctpvCd: data.ctpvCd,
|
||||
sggCd: data.sggCd,
|
||||
dmdInfoPk,
|
||||
bznmTotNo: data.bznmTotNo || '',
|
||||
daddr: data.daddr,
|
||||
telno: data.telno,
|
||||
});
|
||||
|
||||
//router.push(`/pages/sdmMng/sdmInfoInsert?${queryParams.toString()}`);
|
||||
toast.success('수요처가 성공적으로 등록되었습니다.');
|
||||
} catch (error) {
|
||||
console.error('Error submitting form:', error);
|
||||
toast.error('수요처 등록에 실패했습니다.');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -203,6 +177,7 @@ export default function SdmInsertForm({selectSidoData, selectSigunData, dataList
|
||||
dataList={dataList}
|
||||
rtnValue={setRtnValue}
|
||||
setIsDuplicate={setIsDuplicate}
|
||||
updateList={updateList}
|
||||
/>
|
||||
<div className="flex justify-center pt-4">
|
||||
<Button
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import type { DemandCompType } from "../../../../../../apps/dm/app/store/sdmMng";
|
||||
import type { DemandCompType } from './form';
|
||||
|
||||
export type thisProps = {
|
||||
label: string | undefined;
|
||||
@@ -53,6 +53,12 @@ export const SdmSearchForm = ({label=undefined, initValue=undefined, rtnValue=()
|
||||
document.removeEventListener('mousedown', handleClickOutside);
|
||||
};
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if(initValue&& initValue?.length>0){
|
||||
setTextValue(initValue)
|
||||
}
|
||||
},[initValue])
|
||||
|
||||
return (
|
||||
<div ref={wrapperRef}>
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* @remarks
|
||||
* 이 버전은 SearchModal에서 사용하기 위해 `SelectContent`의 z-index를 `z-[101]`로 수정하였습니다.
|
||||
*/
|
||||
import { Label } from "@common/components";
|
||||
import React from "react";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "./lib/selectBox";
|
||||
|
||||
/** 차트 기본 스타일 */
|
||||
interface SelectBox1 {
|
||||
text:string,
|
||||
val:string|number
|
||||
}
|
||||
|
||||
const SelectBox2 = React.forwardRef<
|
||||
HTMLDivElement,
|
||||
React.HTMLAttributes<HTMLDivElement> & {
|
||||
label:string,
|
||||
selectClass:string|undefined,
|
||||
className:string,
|
||||
selectArray:SelectBox1[],
|
||||
onSelectValue:(val:string|number)=>void,
|
||||
value?: string|number
|
||||
}
|
||||
>(({ label, className, selectClass, selectArray, onSelectValue, value }, ref)=>{
|
||||
const placeHolder = selectArray?.[0]?.text ?? "";
|
||||
|
||||
return (
|
||||
<div className={className+" flex items-center flex-nowrap"} ref={ref}>
|
||||
{label && <Label className="inline-block w-auto whitespace-nowrap text-xl text-gray-600 mr-2">{label}</Label>}
|
||||
<Select onValueChange={onSelectValue} value={value !== undefined ? String(value) : undefined}>
|
||||
<SelectTrigger className={selectClass?selectClass:"flex-1 p-2 border rounded"}>
|
||||
<SelectValue placeholder={placeHolder} />
|
||||
</SelectTrigger>
|
||||
<SelectContent className="z-[101]">
|
||||
{selectArray.map((selectArray) => (
|
||||
<SelectItem key={selectArray.val} value={String(selectArray.val)}>{selectArray.text}</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
)
|
||||
})
|
||||
|
||||
export { SelectBox2 };
|
||||
@@ -0,0 +1,38 @@
|
||||
import { Tabs, TabsList, TabsTrigger } from '@common/components/ui';
|
||||
import React from 'react';
|
||||
|
||||
interface TabItem {
|
||||
value: string;
|
||||
label: string;
|
||||
onClick?: () => void;
|
||||
}
|
||||
|
||||
interface UITabProps extends React.HTMLAttributes<HTMLDivElement> {
|
||||
defaultValue?: string;
|
||||
tabList: TabItem[];
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
const UITab2 = React.forwardRef<
|
||||
HTMLDivElement,
|
||||
UITabProps
|
||||
>(({defaultValue, tabList, children}, ref)=>{
|
||||
return (
|
||||
<Tabs defaultValue={defaultValue || tabList[0]?.value} className={"w-full"}>
|
||||
<TabsList className="flex">
|
||||
{tabList.map((tab) => (
|
||||
<TabsTrigger
|
||||
key={tab.value}
|
||||
value={tab.value}
|
||||
onClick={tab.onClick}
|
||||
className="py-2 px-4 text-sm font-medium border-b-2 focus:outline-none data-[state=active]:border-blue-500 data-[state=active]:text-blue-600 data-[state=inactive]:border-transparent data-[state=inactive]:text-gray-500 hover:text-gray-700 hover:border-gray-300"
|
||||
>
|
||||
{tab.label}
|
||||
</TabsTrigger>
|
||||
))}
|
||||
</TabsList>
|
||||
{children}
|
||||
</Tabs>
|
||||
)
|
||||
})
|
||||
export { UITab2 };
|
||||
@@ -14,18 +14,32 @@ type UiTableProps = {
|
||||
className?: string;
|
||||
resetPageNo?: boolean;
|
||||
cur?: number;
|
||||
}
|
||||
height?: string; // ✅ 추가된 prop
|
||||
};
|
||||
|
||||
type UiHeadProps = {
|
||||
id: string;
|
||||
title: string;
|
||||
align?: string;
|
||||
}
|
||||
};
|
||||
|
||||
export function UiTable2({ tableData, headlist, pageSize, total, children, headName, cellClick, onPageChange, className = '', resetPageNo = false, cur }: UiTableProps) {
|
||||
export function UiTable2({
|
||||
tableData,
|
||||
headlist,
|
||||
pageSize,
|
||||
total,
|
||||
children,
|
||||
headName,
|
||||
cellClick,
|
||||
onPageChange,
|
||||
className = '',
|
||||
resetPageNo = false,
|
||||
cur,
|
||||
height = '45vh', // ✅ 기본값 설정
|
||||
}: UiTableProps) {
|
||||
const [idx, setIdx] = useState<number>(-1);
|
||||
|
||||
const [curState, setCurState] = useState<number>(cur ?? 1);
|
||||
|
||||
useEffect(() => {
|
||||
setCurState(cur ?? 1);
|
||||
}, [cur]);
|
||||
@@ -40,7 +54,7 @@ export function UiTable2({ tableData, headlist, pageSize, total, children, headN
|
||||
const handlePageChange = (page: number) => {
|
||||
setCurState(page);
|
||||
onPageChange(page);
|
||||
}
|
||||
};
|
||||
|
||||
const handleCellClick = (index: number, headId: string) => {
|
||||
if (cellClick) {
|
||||
@@ -50,59 +64,91 @@ export function UiTable2({ tableData, headlist, pageSize, total, children, headN
|
||||
};
|
||||
|
||||
const startIdx = (curState - 1) * pageSize;
|
||||
const endIdx = startIdx + pageSize;
|
||||
const pageData = tableData.slice(startIdx, endIdx);
|
||||
|
||||
return (
|
||||
<>
|
||||
{headName ? (
|
||||
{headName && (
|
||||
<div className="card-header">
|
||||
<h3 className="text-2xl font-medium text-label">{headName}</h3>
|
||||
<div className="flex w-full items-center justify-between">
|
||||
<h3 className="text-2xl font-medium text-label">{headName}</h3>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
<div className={`card !m-[1.2rem] !p-0r w-full relative ${className}`}>
|
||||
<div>
|
||||
)}
|
||||
|
||||
<div className={`card !m-[1.2rem] !p-0 relative ${className}`}>
|
||||
{/* ✅ 외부에서 조절 가능한 높이 적용 */}
|
||||
<div className="overflow-auto" style={{ height }}>
|
||||
<Table variant="secondary" className="w-full">
|
||||
{/* 스크롤 관련 div 제거 */}
|
||||
<TableHeader className="bg-white">
|
||||
{children ? (
|
||||
<>{children}</>
|
||||
) : (
|
||||
<TableRow>
|
||||
{headlist?.map((head) => (
|
||||
<TableHead key={head.id}
|
||||
{headlist.map((head) => (
|
||||
<TableHead
|
||||
key={head.id}
|
||||
className="min-w-[120px] max-w-[180px] w-[150px]
|
||||
text-center whitespace-nowrap overflow-hidden
|
||||
text-ellipsis bg-white">
|
||||
text-center whitespace-nowrap overflow-hidden
|
||||
text-ellipsis bg-white"
|
||||
>
|
||||
{head.title}
|
||||
</TableHead>
|
||||
))}
|
||||
</TableRow>
|
||||
)}
|
||||
</TableHeader>
|
||||
<TableBody className='text-center'>
|
||||
{pageData.map((el: { [key: string]: string | number | boolean | object }, index) => (
|
||||
<TableRow key={index + "row"}>
|
||||
{headlist?.map((head) => (
|
||||
<TableCell
|
||||
className={`${head.align === 'right' ? 'text-right' : head.align === 'center' ? 'text-center' : typeof el[head.id] === 'number' ? 'text-right' : 'text-center'} ${cellClick && idx === index ? '!font-[1000] cursor-pointer' :
|
||||
cellClick ? 'cursor-pointer' : ''
|
||||
}`}
|
||||
onClick={() => handleCellClick(startIdx + index, head.id)}
|
||||
key={head.id + index}
|
||||
>
|
||||
{typeof el[head.id] === 'number' ? String(el[head.id]).replace(/\B(?=(\d{3})+(?!\d))/g, ",") : String(el[head.id] ?? '')}
|
||||
</TableCell>
|
||||
))}
|
||||
|
||||
<TableBody className="text-center">
|
||||
{tableData.length > 0 ? (
|
||||
tableData.map((el, index) => (
|
||||
<TableRow key={index + "row"}>
|
||||
{headlist.map((head) => (
|
||||
<TableCell
|
||||
key={head.id + index}
|
||||
className={`
|
||||
${head.align === 'right'
|
||||
? 'text-right'
|
||||
: head.align === 'center'
|
||||
? 'text-center'
|
||||
: typeof el[head.id] === 'number'
|
||||
? 'text-right'
|
||||
: 'text-center'
|
||||
}
|
||||
${cellClick && idx === index ? '!font-[1000] cursor-pointer' :
|
||||
cellClick ? 'cursor-pointer' : ''}
|
||||
`}
|
||||
onClick={() => handleCellClick(startIdx + index, head.id)}
|
||||
>
|
||||
{typeof el[head.id] === 'number'
|
||||
? String(el[head.id]).replace(/\B(?=(\d{3})+(?!\d))/g, ",")
|
||||
: String(el[head.id] ?? '')}
|
||||
</TableCell>
|
||||
))}
|
||||
</TableRow>
|
||||
))
|
||||
) : (
|
||||
<TableRow>
|
||||
<TableCell colSpan={headlist.length} className="p-0">
|
||||
{/* ✅ 높이 보장 + 가운데 정렬용 div */}
|
||||
<div className="flex justify-center items-center text-gray-500" style={{ height: `calc(${height} - 70px)` }}>
|
||||
<span className="text-xl">🔍 검색 결과가 없습니다.</span>
|
||||
</div>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
)}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
{/* 페이지네이션을 sticky 하단에 고정 */}
|
||||
{total > 0 && (
|
||||
<div className="sticky left-0 right-0 bottom-0 bg-white z-20 border-t border-gray-200">
|
||||
<UiPageNations total={total} cur={curState} pageSize={pageSize} onPageChange={handlePageChange} />
|
||||
|
||||
{/* 페이지네이션 하단 고정 */}
|
||||
{ (
|
||||
<div className="sticky left-0 right-0 bottom-0 bg-white z-20 mt-5">
|
||||
<UiPageNations
|
||||
total={total}
|
||||
cur={curState}
|
||||
pageSize={pageSize}
|
||||
onPageChange={handlePageChange}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@common/components",
|
||||
"version": "0.0.0",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
@@ -40,6 +40,7 @@
|
||||
"@radix-ui/react-popover": "^1.1.6",
|
||||
"@radix-ui/react-progress": "^1.1.2",
|
||||
"@radix-ui/react-radio-group": "^1.2.2",
|
||||
"@radix-ui/react-scroll-area": "^1.2.3",
|
||||
"@radix-ui/react-select": "^2.1.6",
|
||||
"@radix-ui/react-separator": "^1.1.2",
|
||||
"@radix-ui/react-slider": "^1.2.3",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
export * from "./client";
|
||||
export * from "./menu";
|
||||
export * from "./popup";
|
||||
export * from "./site";
|
||||
export * from "./user";
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
import { getApiClient } from "./client";
|
||||
import { ENDPOINT } from "../config";
|
||||
|
||||
export interface PopupInfo {
|
||||
popupSn: number;
|
||||
popupTypeCd: string;
|
||||
popupTypeNm: string;
|
||||
contsTypeCd: string;
|
||||
contsTypeNm: string;
|
||||
popupTtl: string;
|
||||
popupCn: string;
|
||||
popupWdth: number;
|
||||
popupHgt: number;
|
||||
popupVtclPstn: number;
|
||||
popupHrzntltyPstn: number;
|
||||
popupEndUseYn: string;
|
||||
popupLnkgUrl: string;
|
||||
atflCd: string;
|
||||
useYn: string;
|
||||
regDt: string;
|
||||
mdfcnDt: string;
|
||||
rgTrNm: string;
|
||||
mdfrNm: string;
|
||||
}
|
||||
|
||||
interface SortConfig {
|
||||
empty: boolean;
|
||||
sorted: boolean;
|
||||
unsorted: boolean;
|
||||
}
|
||||
|
||||
interface PageableConfig {
|
||||
sort: SortConfig;
|
||||
offset: number;
|
||||
pageNumber: number;
|
||||
pageSize: number;
|
||||
paged: boolean;
|
||||
unpaged: boolean;
|
||||
}
|
||||
|
||||
interface PageableList<T> {
|
||||
content: T[];
|
||||
pageable: PageableConfig;
|
||||
sort: SortConfig;
|
||||
totalPages: number;
|
||||
totalElements: number;
|
||||
number: number;
|
||||
numberOfElements: number;
|
||||
size: number;
|
||||
first: boolean;
|
||||
last: boolean;
|
||||
empty: boolean;
|
||||
}
|
||||
|
||||
const client = getApiClient();
|
||||
|
||||
export const getPopupList = async () => {
|
||||
const response = await client.get<PageableList<PopupInfo>>(
|
||||
`${ENDPOINT.CMS_SERVICE.POPUPS}`,
|
||||
);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const getPopupInfo = async (popupSn: number) => {
|
||||
const response = await client.get<PopupInfo>(
|
||||
`${ENDPOINT.CMS_SERVICE.POPUPS}/${popupSn}`,
|
||||
);
|
||||
return response.data;
|
||||
};
|
||||
@@ -37,9 +37,9 @@ export interface IUser {
|
||||
|
||||
const client = getApiClient();
|
||||
|
||||
export const getUserInfo = async (userUniqId: string) => {
|
||||
export const getUserInfo = async () => {
|
||||
const response = await client.get<IUser>(
|
||||
`${ENDPOINT.USER_SERVICE.USERS}/${userUniqId}`,
|
||||
`${ENDPOINT.USER_SERVICE.USERS}/info/me`,
|
||||
);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
@@ -2,6 +2,7 @@ export const ENDPOINT = {
|
||||
CMS_SERVICE: {
|
||||
MENU_ROLES: "/cms-service/api/v1/menu-roles",
|
||||
SITES: "/cms-service/api/v1/sites",
|
||||
POPUPS: "/cms-service/api/v1/popups",
|
||||
},
|
||||
USER_SERVICE: {
|
||||
USERS: "/user-service/api/v1/users",
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
function PopupProvider({ children }: { children: React.ReactNode }) {
|
||||
return <>{children}</>;
|
||||
}
|
||||
|
||||
export { PopupProvider };
|
||||
@@ -2,11 +2,11 @@ import "./button-group.css";
|
||||
|
||||
import type { Meta, StoryObj } from "@storybook/react";
|
||||
|
||||
import { RadioGroup, RadioGroupItem } from "../radio-group";
|
||||
import { ButtonGroup, ButtonGroupItem } from "../button-group";
|
||||
|
||||
const meta: Meta<typeof RadioGroup> = {
|
||||
const meta: Meta<typeof ButtonGroup> = {
|
||||
title: "Elements/ButtonGroup",
|
||||
component: RadioGroup,
|
||||
component: ButtonGroup,
|
||||
parameters: {
|
||||
docs: {
|
||||
description: {
|
||||
@@ -19,49 +19,49 @@ ButtonGroup 컴포넌트는 RadioGroup 컴포넌트를 기반으로 버튼 모
|
||||
};
|
||||
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof RadioGroup>;
|
||||
type Story = StoryObj<typeof ButtonGroup>;
|
||||
|
||||
export const Default: Story = {
|
||||
render: () => (
|
||||
<RadioGroup defaultValue="comfortable" variant="button">
|
||||
<RadioGroupItem value="default">Default</RadioGroupItem>
|
||||
<RadioGroupItem value="comfortable">Comfortable</RadioGroupItem>
|
||||
<RadioGroupItem value="compact">Compact</RadioGroupItem>
|
||||
</RadioGroup>
|
||||
<ButtonGroup defaultValue="comfortable" variant="button">
|
||||
<ButtonGroupItem value="default">Default</ButtonGroupItem>
|
||||
<ButtonGroupItem value="comfortable">Comfortable</ButtonGroupItem>
|
||||
<ButtonGroupItem value="compact">Compact</ButtonGroupItem>
|
||||
</ButtonGroup>
|
||||
),
|
||||
};
|
||||
|
||||
export const Secondary: Story = {
|
||||
render: () => (
|
||||
<RadioGroup defaultValue="comfortable" variant="button" color="secondary">
|
||||
<RadioGroupItem value="default">Default</RadioGroupItem>
|
||||
<RadioGroupItem value="comfortable">Comfortable</RadioGroupItem>
|
||||
<RadioGroupItem value="compact">Compact</RadioGroupItem>
|
||||
</RadioGroup>
|
||||
<ButtonGroup defaultValue="comfortable" variant="button" color="secondary">
|
||||
<ButtonGroupItem value="default">Default</ButtonGroupItem>
|
||||
<ButtonGroupItem value="comfortable">Comfortable</ButtonGroupItem>
|
||||
<ButtonGroupItem value="compact">Compact</ButtonGroupItem>
|
||||
</ButtonGroup>
|
||||
),
|
||||
};
|
||||
|
||||
export const Rounded: Story = {
|
||||
render: () => (
|
||||
<RadioGroup defaultValue="comfortable" variant="button" shape="rounded">
|
||||
<RadioGroupItem value="default">Default</RadioGroupItem>
|
||||
<RadioGroupItem value="comfortable">Comfortable</RadioGroupItem>
|
||||
<RadioGroupItem value="compact">Compact</RadioGroupItem>
|
||||
</RadioGroup>
|
||||
<ButtonGroup defaultValue="comfortable" variant="button" shape="rounded">
|
||||
<ButtonGroupItem value="default">Default</ButtonGroupItem>
|
||||
<ButtonGroupItem value="comfortable">Comfortable</ButtonGroupItem>
|
||||
<ButtonGroupItem value="compact">Compact</ButtonGroupItem>
|
||||
</ButtonGroup>
|
||||
),
|
||||
};
|
||||
|
||||
export const SecondaryRounded: Story = {
|
||||
render: () => (
|
||||
<RadioGroup
|
||||
<ButtonGroup
|
||||
defaultValue="comfortable"
|
||||
variant="button"
|
||||
color="secondary"
|
||||
shape="rounded"
|
||||
>
|
||||
<RadioGroupItem value="default">Default</RadioGroupItem>
|
||||
<RadioGroupItem value="comfortable">Comfortable</RadioGroupItem>
|
||||
<RadioGroupItem value="compact">Compact</RadioGroupItem>
|
||||
</RadioGroup>
|
||||
<ButtonGroupItem value="default">Default</ButtonGroupItem>
|
||||
<ButtonGroupItem value="comfortable">Comfortable</ButtonGroupItem>
|
||||
<ButtonGroupItem value="compact">Compact</ButtonGroupItem>
|
||||
</ButtonGroup>
|
||||
),
|
||||
};
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import "./button-group.css";
|
||||
|
||||
import * as React from "react";
|
||||
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
|
||||
|
||||
const ButtonGroup = React.forwardRef<
|
||||
React.ElementRef<typeof RadioGroupPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root> & {
|
||||
variant?: "radio" | "button";
|
||||
color?: "primary" | "secondary";
|
||||
shape?: "square" | "rounded";
|
||||
}
|
||||
>(
|
||||
(
|
||||
{ variant = "radio", color = "primary", shape = "square", ...props },
|
||||
ref,
|
||||
) => {
|
||||
return (
|
||||
<RadioGroupPrimitive.Root
|
||||
{...props}
|
||||
ref={ref}
|
||||
data-variant={variant}
|
||||
data-color={color}
|
||||
data-shape={shape}
|
||||
/>
|
||||
);
|
||||
},
|
||||
);
|
||||
ButtonGroup.displayName = RadioGroupPrimitive.Root.displayName;
|
||||
|
||||
const ButtonGroupItem = React.forwardRef<
|
||||
React.ElementRef<typeof RadioGroupPrimitive.Item>,
|
||||
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>
|
||||
>(({ ...props }, ref) => {
|
||||
return <RadioGroupPrimitive.Item ref={ref} {...props} />;
|
||||
});
|
||||
ButtonGroupItem.displayName = RadioGroupPrimitive.Item.displayName;
|
||||
|
||||
export { ButtonGroup, ButtonGroupItem };
|
||||
@@ -2,36 +2,36 @@
|
||||
|
||||
@layer components {
|
||||
button[role="button"] {
|
||||
@apply text-[1.3rem];
|
||||
@apply text-[1.3rem] transition-opacity hover:opacity-90;
|
||||
}
|
||||
button[role="button"].primary {
|
||||
@apply bg-[rgba(32,148,250,1)] hover:bg-[rgba(32,148,250,0.9)];
|
||||
@apply bg-primary;
|
||||
}
|
||||
button[role="button"].green {
|
||||
@apply bg-[rgba(31,208,120,1)] hover:bg-[rgba(31,208,120,0.9)];
|
||||
@apply bg-[rgba(31,208,120,1)];
|
||||
}
|
||||
button[role="button"].sky {
|
||||
@apply bg-[rgba(50,154,203,1)] hover:bg-[rgba(50,154,203,0.9)];
|
||||
@apply bg-[rgba(50,154,203,1)];
|
||||
}
|
||||
button[role="button"].yellow {
|
||||
@apply bg-[rgba(243,201,0,1)] hover:bg-[rgba(243,201,0,0.9)];
|
||||
@apply bg-[rgba(243,201,0,1)];
|
||||
}
|
||||
button[role="button"].orange {
|
||||
@apply bg-[rgba(255,149,0,1)] hover:bg-[rgba(255,149,0,0.9)];
|
||||
@apply bg-[rgba(255,149,0,1)];
|
||||
}
|
||||
button[role="button"].emerald {
|
||||
@apply bg-[rgba(90,200,250,1)] hover:bg-[rgba(90,200,250,0.9)];
|
||||
@apply bg-[rgba(90,200,250,1)];
|
||||
}
|
||||
button[role="button"].white {
|
||||
@apply border border-border bg-[rgba(255,255,255,1)] text-[#666] hover:bg-[rgba(255,255,255,0.9)];
|
||||
@apply border border-border bg-[rgba(255,255,255,1)] text-[#666];
|
||||
}
|
||||
button[role="button"].red {
|
||||
@apply bg-[rgba(232,93,85,1)] hover:bg-[rgba(232,93,85,0.9)];
|
||||
@apply bg-destructive;
|
||||
}
|
||||
button[role="button"].gray {
|
||||
@apply bg-[rgba(153,153,153,1)] hover:bg-[rgba(153,153,153,0.9)];
|
||||
@apply bg-[rgba(153,153,153,1)];
|
||||
}
|
||||
button[role="button"].lightGray {
|
||||
@apply bg-[rgba(235,235,235,1)] text-[#929292] hover:bg-[rgba(235,235,235,0.9)];
|
||||
@apply bg-[rgba(235,235,235,1)] text-[#929292];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import type { HTMLAttributes } from "react";
|
||||
declare module "@tanstack/react-table" {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
interface ColumnMeta<TData extends RowData, TValue> {
|
||||
width?: number;
|
||||
align?: "left" | "center" | "right";
|
||||
rowSpan?: number;
|
||||
}
|
||||
@@ -41,22 +42,31 @@ function DataTable<T>({
|
||||
<Table className={cn("w-full", className)} variant={variant}>
|
||||
<THead table={table} />
|
||||
<tbody>
|
||||
{table.getRowModel().rows.map((row) => (
|
||||
<TableRow
|
||||
key={row.id}
|
||||
onClick={() => onRowClick?.(row.original)}
|
||||
className={cn(onRowClick && "cursor-pointer hover:bg-accent")}
|
||||
>
|
||||
{row.getVisibleCells().map((cell) => {
|
||||
const { meta } = cell.column.columnDef;
|
||||
return (
|
||||
<TableCell key={cell.id} align="center" {...meta}>
|
||||
{flexRender(cell.column.columnDef.cell, cell.getContext())}
|
||||
</TableCell>
|
||||
);
|
||||
})}
|
||||
</TableRow>
|
||||
))}
|
||||
{table.getRowModel().rows.map((row) => {
|
||||
const isSelectedRow = row.getIsSelected();
|
||||
return (
|
||||
<TableRow
|
||||
key={row.id}
|
||||
onClick={() => onRowClick?.(row.original)}
|
||||
className={cn(
|
||||
onRowClick && "cursor-pointer hover:bg-accent",
|
||||
isSelectedRow && "!bg-primary-transparent",
|
||||
)}
|
||||
>
|
||||
{row.getVisibleCells().map((cell) => {
|
||||
const { meta } = cell.column.columnDef;
|
||||
return (
|
||||
<TableCell key={cell.id} align="center" {...meta}>
|
||||
{flexRender(
|
||||
cell.column.columnDef.cell,
|
||||
cell.getContext(),
|
||||
)}
|
||||
</TableCell>
|
||||
);
|
||||
})}
|
||||
</TableRow>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</Table>
|
||||
{viewPagination && <Pagination table={table} />}
|
||||
@@ -90,7 +100,7 @@ function THead<T>({ table }: { table: TableInstance<T> }) {
|
||||
return (
|
||||
<TableHead
|
||||
key={header.id}
|
||||
className="sticky top-0"
|
||||
className="sticky top-0 z-10"
|
||||
colSpan={header.colSpan}
|
||||
rowSpan={rowSpan}
|
||||
{...meta}
|
||||
@@ -152,7 +162,7 @@ function Pagination<T>({ table }: { table: TableInstance<T> }) {
|
||||
key={pageNumber}
|
||||
variant="ghost"
|
||||
className={cn(
|
||||
"inline-block size-10 !bg-transparent p-0 text-foreground hover:!bg-accent",
|
||||
"inline-block h-10 min-w-10 !bg-transparent p-1 text-foreground hover:!bg-accent",
|
||||
currentPage === pageNumber &&
|
||||
"!bg-primary !font-bold !text-primary-foreground hover:!bg-primary",
|
||||
)}
|
||||
|
||||
@@ -9,21 +9,30 @@ import { Button } from "../button";
|
||||
import { Calendar } from "../calendar";
|
||||
import { Popover, PopoverContent, PopoverTrigger } from "../popover";
|
||||
|
||||
type DatePickerProps = DayPickerSingleProps;
|
||||
type DatePickerProps = {
|
||||
placeholder?: string;
|
||||
disabled?: boolean;
|
||||
} & DayPickerSingleProps;
|
||||
|
||||
export function DatePicker({ className, ...props }: DatePickerProps) {
|
||||
export function DatePicker({
|
||||
className,
|
||||
placeholder = "날짜 선택",
|
||||
disabled,
|
||||
...props
|
||||
}: DatePickerProps) {
|
||||
return (
|
||||
<Popover>
|
||||
<PopoverTrigger asChild>
|
||||
<Button
|
||||
variant="outline"
|
||||
className={cn("date-picker-trigger", className)}
|
||||
disabled={disabled}
|
||||
>
|
||||
<CalendarIcon className="!size-[1.6rem]" />
|
||||
{props.selected ? (
|
||||
format(props.selected, "yyyy-MM-dd")
|
||||
) : (
|
||||
<span>날짜 선택</span>
|
||||
<span>{placeholder}</span>
|
||||
)}
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { format } from "date-fns";
|
||||
import { CalendarIcon } from "lucide-react";
|
||||
import type { DateRange } from "react-day-picker";
|
||||
@@ -11,20 +11,38 @@ import { Calendar } from "../calendar";
|
||||
import { Popover, PopoverContent, PopoverTrigger } from "../popover";
|
||||
|
||||
type DateRangePickerProps = React.HTMLAttributes<HTMLDivElement> & {
|
||||
value?: DateRange;
|
||||
defaultValue?: DateRange;
|
||||
disabled?: boolean;
|
||||
handleDateChange?: (date: DateRange | undefined) => void;
|
||||
onValueChange?: (date: DateRange | undefined) => void;
|
||||
};
|
||||
|
||||
export function DateRangePicker({
|
||||
value,
|
||||
defaultValue,
|
||||
disabled,
|
||||
className,
|
||||
handleDateChange,
|
||||
children,
|
||||
onValueChange,
|
||||
}: DateRangePickerProps) {
|
||||
const [date, setDate] = useState<DateRange>();
|
||||
const [dateState, setDateState] = useState<DateRange | undefined>(
|
||||
defaultValue,
|
||||
);
|
||||
|
||||
const isControlled = value !== undefined;
|
||||
const dateValue = isControlled ? value : dateState;
|
||||
|
||||
useEffect(() => {
|
||||
if (isControlled) {
|
||||
setDateState(value);
|
||||
}
|
||||
}, [isControlled, value]);
|
||||
|
||||
const handleSelect = (date: DateRange | undefined) => {
|
||||
setDate(date);
|
||||
handleDateChange?.(date);
|
||||
if (!isControlled) {
|
||||
setDateState(date);
|
||||
}
|
||||
onValueChange?.(date);
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -36,19 +54,19 @@ export function DateRangePicker({
|
||||
variant="outline"
|
||||
className={cn(
|
||||
"h-[3.2rem] min-w-[12rem] justify-start border-input !bg-background px-4 py-2 text-left text-[1.3rem] font-normal text-muted-foreground hover:!bg-accent",
|
||||
!date && "text-muted-foreground",
|
||||
!dateValue && "text-muted-foreground",
|
||||
)}
|
||||
disabled={disabled}
|
||||
>
|
||||
<CalendarIcon className="!size-[1.6rem]" />
|
||||
{date?.from ? (
|
||||
date.to ? (
|
||||
{dateValue?.from ? (
|
||||
dateValue.to ? (
|
||||
<>
|
||||
{format(date.from, "yyyy-MM-dd")} ~{" "}
|
||||
{format(date.to, "yyyy-MM-dd")}
|
||||
{format(dateValue.from, "yyyy-MM-dd")} ~{" "}
|
||||
{format(dateValue.to, "yyyy-MM-dd")}
|
||||
</>
|
||||
) : (
|
||||
format(date.from, "yyyy-MM-dd")
|
||||
format(dateValue.from, "yyyy-MM-dd")
|
||||
)
|
||||
) : (
|
||||
<span>기간 선택</span>
|
||||
@@ -56,14 +74,17 @@ export function DateRangePicker({
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent className="w-auto p-0" align="start">
|
||||
<Calendar
|
||||
initialFocus
|
||||
mode="range"
|
||||
defaultMonth={date?.from}
|
||||
selected={date}
|
||||
onSelect={handleSelect}
|
||||
numberOfMonths={2}
|
||||
/>
|
||||
<div>
|
||||
{children}
|
||||
<Calendar
|
||||
initialFocus
|
||||
mode="range"
|
||||
defaultMonth={dateValue?.from}
|
||||
selected={dateValue}
|
||||
onSelect={handleSelect}
|
||||
numberOfMonths={2}
|
||||
/>
|
||||
</div>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
@tailwind components;
|
||||
|
||||
@layer components {
|
||||
[data-theme="blue"] {
|
||||
header {
|
||||
background: #00afe5;
|
||||
border: none;
|
||||
}
|
||||
header h1 span {
|
||||
color: #fff;
|
||||
}
|
||||
[data-trigger="dropdown"] {
|
||||
background: transparent !important;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
[data-theme="green"] {
|
||||
header {
|
||||
background: #008e8d;
|
||||
border: none;
|
||||
}
|
||||
header h1 span {
|
||||
color: #fff;
|
||||
}
|
||||
[data-trigger="dropdown"] {
|
||||
background: transparent !important;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,18 @@
|
||||
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 { getCookie, setCookie } from "../../lib";
|
||||
import { getSiteInfo, getUserInfo } from "../../api";
|
||||
import { setCookie, getCookie } from "../../lib";
|
||||
import {
|
||||
getPopupInfo,
|
||||
getPopupList,
|
||||
getSiteInfo,
|
||||
getUserInfo,
|
||||
type PopupInfo,
|
||||
} from "../../api";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuTrigger,
|
||||
@@ -12,14 +21,12 @@ import {
|
||||
} from "../dropdown-menu";
|
||||
import { Button } from "../button";
|
||||
|
||||
const { AUTH_USER_ID, SITE_ID } = getConfig();
|
||||
const { SITE_ID } = getConfig();
|
||||
|
||||
export function Header({ viewOnly }: { viewOnly?: boolean }) {
|
||||
const userUniqId = getCookie(AUTH_USER_ID ?? "") ?? "";
|
||||
|
||||
const { data: userInfo } = useQuery({
|
||||
queryKey: [ENDPOINT.USER_SERVICE.USERS],
|
||||
queryFn: () => getUserInfo(userUniqId),
|
||||
queryFn: () => getUserInfo(),
|
||||
enabled: !viewOnly,
|
||||
});
|
||||
|
||||
@@ -37,6 +44,51 @@ export function Header({ viewOnly }: { viewOnly?: boolean }) {
|
||||
enabled: !viewOnly,
|
||||
});
|
||||
|
||||
const { data: popupList } = useQuery({
|
||||
queryKey: [ENDPOINT.CMS_SERVICE.POPUPS],
|
||||
queryFn: () => getPopupList(),
|
||||
});
|
||||
|
||||
const openPopup = useCallback(async (popup: PopupInfo) => {
|
||||
try {
|
||||
const cookieName = `cs-popup-hide-for-day-${popup.popupSn}`;
|
||||
const hasCookie = getCookie(cookieName);
|
||||
if (hasCookie) return;
|
||||
|
||||
const response = await getPopupInfo(popup.popupSn);
|
||||
if (!response) return;
|
||||
|
||||
const width = response.popupWdth || 400;
|
||||
const height = response.popupHgt || 300;
|
||||
const left = (response.popupHrzntltyPstn || 0) + window.screenX;
|
||||
const top = (response.popupVtclPstn || 0) + window.screenY;
|
||||
|
||||
const popupWindow = window.open(
|
||||
`/view/popup/${popup.popupSn}`,
|
||||
"",
|
||||
`width=${width},height=${height},left=${left},top=${top},resizable=yes,scrollbars=yes,status=no,location=no,menubar=no`,
|
||||
);
|
||||
|
||||
if (popupWindow) {
|
||||
popupWindow.focus();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Failed to open popup ${popup.popupSn}:`, error);
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!popupList?.content.length) return;
|
||||
|
||||
const timer = setTimeout(() => {
|
||||
popupList.content.forEach((popup) => {
|
||||
openPopup(popup);
|
||||
});
|
||||
}, 500);
|
||||
|
||||
return () => clearTimeout(timer);
|
||||
}, [popupList, openPopup]);
|
||||
|
||||
return (
|
||||
<header className="sticky top-0 z-30 box-border flex h-[5rem] w-full items-center justify-between border-b border-solid border-border bg-background">
|
||||
<div className="flex items-center">
|
||||
@@ -52,7 +104,10 @@ export function Header({ viewOnly }: { viewOnly?: boolean }) {
|
||||
</div>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button className="group m-0 flex h-[3rem] items-center !bg-background px-4 py-0 text-label">
|
||||
<Button
|
||||
className="group m-0 flex h-[3rem] items-center !bg-background px-4 py-0 text-label"
|
||||
data-trigger="dropdown"
|
||||
>
|
||||
<i className="diveicon di-account-circle static translate-y-0.5 pr-2 text-3xl" />
|
||||
{userInfo?.userName}
|
||||
<i className="diveicon di-chevron-down static p-0 transition-transform group-data-[state=open]:rotate-180" />
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { cn } from "../../lib";
|
||||
import { Button } from "../button";
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
export * from "./accordion";
|
||||
export * from "./badge";
|
||||
export * from "./button";
|
||||
export * from "./button-group";
|
||||
export * from "./calendar";
|
||||
export * from "./carousel";
|
||||
export * from "./checkbox";
|
||||
@@ -19,6 +20,7 @@ export * from "./page-title";
|
||||
export * from "./popover";
|
||||
export * from "./progress";
|
||||
export * from "./radio-group";
|
||||
export * from "./scroll-area";
|
||||
export * from "./select";
|
||||
export * from "./slider";
|
||||
export * from "./skeleton";
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import type { QueryClient } from "@tanstack/react-query";
|
||||
import type { MenuItem } from "../../api";
|
||||
import { QueryProvider } from "../../provider/query-provider";
|
||||
import { PopupProvider } from "../../provider/popup-provider";
|
||||
import type { MenuItem } from "../../api";
|
||||
import { SidebarProvider } from "../sidebar";
|
||||
import { LNB } from "../lnb";
|
||||
import { Header } from "../header";
|
||||
import { Footer } from "./footer";
|
||||
import { SidebarProvider } from "../sidebar";
|
||||
import "./common.css";
|
||||
|
||||
export function BaseLayout({
|
||||
@@ -20,20 +21,25 @@ export function BaseLayout({
|
||||
}) {
|
||||
return (
|
||||
<QueryProvider queryClient={queryClient}>
|
||||
<SidebarProvider>
|
||||
<div className="flex-1">
|
||||
<Header />
|
||||
<div className="flex h-[calc(100vh-50px)]">
|
||||
<LNB currentPath={currentPath} handleMenuClick={handleMenuClick} />
|
||||
<div className="flex flex-1 flex-col">
|
||||
<div className="max-h-[calc(100%-50px)] flex-1 overflow-auto">
|
||||
{children}
|
||||
<PopupProvider>
|
||||
<SidebarProvider>
|
||||
<div className="flex-1">
|
||||
<Header />
|
||||
<div className="flex h-[calc(100vh-50px)]">
|
||||
<LNB
|
||||
currentPath={currentPath}
|
||||
handleMenuClick={handleMenuClick}
|
||||
/>
|
||||
<div className="flex flex-1 flex-col">
|
||||
<div className="max-h-[calc(100%-50px)] flex-1 overflow-auto">
|
||||
{children}
|
||||
</div>
|
||||
<Footer />
|
||||
</div>
|
||||
<Footer />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</SidebarProvider>
|
||||
</SidebarProvider>
|
||||
</PopupProvider>
|
||||
</QueryProvider>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -206,3 +206,21 @@
|
||||
color: #ffffff;
|
||||
background: #40a5ff;
|
||||
}
|
||||
|
||||
[data-theme="blue"] {
|
||||
footer {
|
||||
background: #6ec05d;
|
||||
}
|
||||
footer p {
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
[data-theme="green"] {
|
||||
footer {
|
||||
background: #24ec7d;
|
||||
}
|
||||
footer p {
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { ChevronRight } from "lucide-react";
|
||||
@@ -63,6 +65,7 @@ export function LNB({
|
||||
"h-auto py-4 text-[1.4rem] text-label transition-colors hover:bg-accent",
|
||||
isMatched && "bg-accent !text-primary",
|
||||
)}
|
||||
data-matched={isMatched}
|
||||
onClick={handleClick}
|
||||
>
|
||||
<i className={cn("diveicon ml-2", `di-${item.iconNm}`)} />
|
||||
@@ -94,19 +97,21 @@ export function LNB({
|
||||
<Collapsible open={isOpen} onOpenChange={handleOpenChange}>
|
||||
<SidebarMenuItem>
|
||||
<CollapsibleTrigger asChild>
|
||||
<div className="group flex items-center justify-between rounded-sm py-4 pr-2 hover:bg-accent">
|
||||
<SidebarMenuButton className="group/menu-button text-[1.4rem] group-data-[state=open]:bg-transparent">
|
||||
<i
|
||||
className={cn(
|
||||
"diveicon ml-2 text-label",
|
||||
`di-${item.iconNm}`,
|
||||
)}
|
||||
/>
|
||||
<span className="text-label group-hover/menu-button:text-foreground">
|
||||
{item.menuKornNm}
|
||||
</span>
|
||||
<div className="group">
|
||||
<SidebarMenuButton className="group/menu-button flex h-auto items-center justify-between py-4 pr-2 text-[1.4rem] group-data-[state=open]:bg-transparent">
|
||||
<div className="flex items-center gap-2">
|
||||
<i
|
||||
className={cn(
|
||||
"diveicon ml-2 text-label",
|
||||
`di-${item.iconNm}`,
|
||||
)}
|
||||
/>
|
||||
<span className="text-label group-hover/menu-button:text-foreground">
|
||||
{item.menuKornNm}
|
||||
</span>
|
||||
</div>
|
||||
<ChevronRight className="!size-6 text-label group-data-[state=open]:rotate-90" />
|
||||
</SidebarMenuButton>
|
||||
<ChevronRight className="size-6 text-label group-data-[state=open]:rotate-90" />
|
||||
</div>
|
||||
</CollapsibleTrigger>
|
||||
<CollapsibleContent>
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
"use client";
|
||||
|
||||
import * as React from "react";
|
||||
import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area";
|
||||
|
||||
import { cn } from "../../lib/utils";
|
||||
|
||||
const ScrollArea = React.forwardRef<
|
||||
React.ElementRef<typeof ScrollAreaPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root>
|
||||
>(({ className, children, ...props }, ref) => (
|
||||
<ScrollAreaPrimitive.Root
|
||||
ref={ref}
|
||||
className={cn("relative overflow-hidden", className)}
|
||||
{...props}
|
||||
>
|
||||
<ScrollAreaPrimitive.Viewport className="h-full w-full rounded-[inherit]">
|
||||
{children}
|
||||
</ScrollAreaPrimitive.Viewport>
|
||||
<ScrollBar />
|
||||
<ScrollAreaPrimitive.Corner />
|
||||
</ScrollAreaPrimitive.Root>
|
||||
));
|
||||
ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;
|
||||
|
||||
const ScrollBar = React.forwardRef<
|
||||
React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>,
|
||||
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>
|
||||
>(({ className, orientation = "vertical", ...props }, ref) => (
|
||||
<ScrollAreaPrimitive.ScrollAreaScrollbar
|
||||
ref={ref}
|
||||
orientation={orientation}
|
||||
className={cn(
|
||||
"flex touch-none select-none transition-colors",
|
||||
orientation === "vertical" &&
|
||||
"h-full w-2.5 border-l border-l-transparent p-[1px]",
|
||||
orientation === "horizontal" &&
|
||||
"h-2.5 flex-col border-t border-t-transparent p-[1px]",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<ScrollAreaPrimitive.ScrollAreaThumb className="relative flex-1 rounded-full bg-border" />
|
||||
</ScrollAreaPrimitive.ScrollAreaScrollbar>
|
||||
));
|
||||
ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;
|
||||
|
||||
export { ScrollArea, ScrollBar };
|
||||
@@ -1,3 +1,5 @@
|
||||
import "./sidebar.css";
|
||||
|
||||
import * as React from "react";
|
||||
import { Slot } from "@radix-ui/react-slot";
|
||||
import { type VariantProps, cva } from "class-variance-authority";
|
||||
@@ -248,6 +250,7 @@ const Sidebar = React.forwardRef<
|
||||
)}
|
||||
/>
|
||||
<div
|
||||
data-sidebar="sidebar-wrapper"
|
||||
className={cn(
|
||||
"fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] duration-200 ease-linear md:flex",
|
||||
side === "left"
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
@tailwind components;
|
||||
|
||||
@layer components {
|
||||
[data-theme="blue"] {
|
||||
[data-sidebar="sidebar-wrapper"] {
|
||||
background: none;
|
||||
background-image: linear-gradient(
|
||||
to bottom,
|
||||
#00afe5 0%,
|
||||
#48bfad 65%,
|
||||
#6ec05d 100%
|
||||
) !important;
|
||||
border: none;
|
||||
}
|
||||
[data-sidebar="sidebar"],
|
||||
[data-sidebar="content"] {
|
||||
background: transparent !important;
|
||||
}
|
||||
[data-sidebar="menu-item"] * {
|
||||
color: #fff !important;
|
||||
}
|
||||
[data-sidebar="menu-item"] *:hover {
|
||||
background: none !important;
|
||||
color: #fff !important;
|
||||
}
|
||||
[data-sidebar="menu-button"]:hover {
|
||||
background: rgba(0, 0, 0, 0.1) !important;
|
||||
}
|
||||
[data-sidebar="menu-button"][data-matched="true"] {
|
||||
background: rgba(0, 0, 0, 0.2) !important;
|
||||
}
|
||||
}
|
||||
|
||||
[data-theme="red"] {
|
||||
[data-sidebar="menu-button"][data-matched="true"] {
|
||||
@apply bg-primary !text-white;
|
||||
}
|
||||
}
|
||||
|
||||
[data-theme="green"] {
|
||||
[data-sidebar="sidebar-wrapper"] {
|
||||
background: none;
|
||||
background-image: linear-gradient(
|
||||
0.4turn,
|
||||
#008e8d 20%,
|
||||
#24ec7d 100%
|
||||
) !important;
|
||||
border: none;
|
||||
}
|
||||
[data-sidebar="sidebar"],
|
||||
[data-sidebar="content"] {
|
||||
background: transparent !important;
|
||||
}
|
||||
[data-sidebar="menu-item"] * {
|
||||
color: #fff !important;
|
||||
}
|
||||
[data-sidebar="menu-item"] *:hover {
|
||||
background: none !important;
|
||||
color: #fff !important;
|
||||
}
|
||||
[data-sidebar="menu-button"]:hover {
|
||||
background: rgba(0, 0, 0, 0.1) !important;
|
||||
}
|
||||
[data-sidebar="menu-button"][data-matched="true"] {
|
||||
background: rgba(0, 0, 0, 0.2) !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -47,4 +47,22 @@
|
||||
@apply text-[#fff];
|
||||
}
|
||||
}
|
||||
|
||||
[data-theme="red"] {
|
||||
.table-ui.default th {
|
||||
@apply bg-[#8d8d94];
|
||||
}
|
||||
.table-ui.secondary th {
|
||||
@apply bg-[#f6f6f9] text-[#808080];
|
||||
}
|
||||
}
|
||||
|
||||
[data-theme="green"] {
|
||||
.table-ui.default th {
|
||||
@apply bg-[#6bafae];
|
||||
}
|
||||
.table-ui.secondary th {
|
||||
@apply bg-[#ebf7f7] text-[#64908f];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ const Textarea = React.forwardRef<
|
||||
return (
|
||||
<textarea
|
||||
className={cn(
|
||||
"flex min-h-[6rem] w-full rounded-md border border-input bg-transparent p-3 text-base placeholder:text-placeholder focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
||||
"flex min-h-[6rem] w-full rounded-md border border-input bg-transparent p-3 text-base text-foreground placeholder:text-placeholder focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
||||
className,
|
||||
)}
|
||||
ref={ref}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@common/config",
|
||||
"version": "0.1.0",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./dist/index.js",
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
export * from "./initialize-config";
|
||||
export * from "./initializer";
|
||||
|
||||
@@ -13,22 +13,14 @@ const defaultConfig: EnvConfig = {
|
||||
PORT: "3000",
|
||||
PROXY_HOST: "",
|
||||
SERVER_API_URL: "",
|
||||
SITE_ID: "CS",
|
||||
SITE_ID: "",
|
||||
CLAIM_NAME: "Authorization",
|
||||
ACCESS_TOKEN: "access-token",
|
||||
REFRESH_TOKEN: "refresh-token",
|
||||
AUTH_USER_ID: "token-id",
|
||||
};
|
||||
|
||||
let isInitialized = false;
|
||||
let envConfig: EnvConfig = { ...defaultConfig };
|
||||
|
||||
export function initializeConfig(values: Partial<EnvConfig>): void {
|
||||
if (isInitialized) {
|
||||
console.warn("Configuration already initialized. Skipping.");
|
||||
return;
|
||||
}
|
||||
|
||||
export function generateEnvConfig(values: Partial<EnvConfig>): EnvConfig {
|
||||
const filteredValues = Object.entries(values).reduce((acc, [key, value]) => {
|
||||
if (value !== undefined && value !== null) {
|
||||
acc[key as keyof EnvConfig] = value;
|
||||
@@ -36,19 +28,44 @@ export function initializeConfig(values: Partial<EnvConfig>): void {
|
||||
return acc;
|
||||
}, {} as Partial<EnvConfig>);
|
||||
|
||||
if (filteredValues.PORT && !filteredValues.PROXY_HOST) {
|
||||
filteredValues.PROXY_HOST = `http://localhost:${filteredValues.PORT}`;
|
||||
if (!filteredValues.PROXY_HOST) {
|
||||
filteredValues.PROXY_HOST = `http://localhost:${filteredValues.PORT || defaultConfig.PORT}`;
|
||||
}
|
||||
|
||||
envConfig = { ...defaultConfig, ...filteredValues };
|
||||
isInitialized = true;
|
||||
return { ...defaultConfig, ...filteredValues };
|
||||
}
|
||||
|
||||
export function getNextConfig(): EnvConfig {
|
||||
const env: Partial<EnvConfig> = {
|
||||
PORT: process.env.NEXT_PUBLIC_PORT,
|
||||
PROXY_HOST: process.env.NEXT_PUBLIC_PROXY_HOST,
|
||||
SERVER_API_URL: process.env.NEXT_PUBLIC_SERVER_API_URL,
|
||||
SITE_ID: process.env.NEXT_PUBLIC_SITE_ID,
|
||||
CLAIM_NAME: process.env.NEXT_PUBLIC_CLAIM_NAME,
|
||||
ACCESS_TOKEN: process.env.NEXT_PUBLIC_ACCESS_TOKEN,
|
||||
REFRESH_TOKEN: process.env.NEXT_PUBLIC_REFRESH_TOKEN,
|
||||
AUTH_USER_ID: process.env.NEXT_PUBLIC_AUTH_USER_ID,
|
||||
};
|
||||
return generateEnvConfig(env);
|
||||
}
|
||||
|
||||
export function getViteConfig(): EnvConfig {
|
||||
const env: Partial<EnvConfig> = {
|
||||
PORT: import.meta.env.VITE_PORT,
|
||||
PROXY_HOST: import.meta.env.VITE_PROXY_HOST,
|
||||
SERVER_API_URL: import.meta.env.VITE_SERVER_API_URL,
|
||||
SITE_ID: import.meta.env.VITE_SITE_ID,
|
||||
CLAIM_NAME: import.meta.env.VITE_CLAIM_NAME,
|
||||
ACCESS_TOKEN: import.meta.env.VITE_ACCESS_TOKEN,
|
||||
REFRESH_TOKEN: import.meta.env.VITE_REFRESH_TOKEN,
|
||||
AUTH_USER_ID: import.meta.env.VITE_AUTH_USER_ID,
|
||||
};
|
||||
return generateEnvConfig(env);
|
||||
}
|
||||
|
||||
export function getConfig(): EnvConfig {
|
||||
if (!isInitialized) {
|
||||
console.warn(
|
||||
"Attempted to access config before initialization. Returning default values."
|
||||
);
|
||||
if (typeof import.meta?.env !== "undefined") {
|
||||
return getViteConfig();
|
||||
}
|
||||
return envConfig;
|
||||
return getNextConfig();
|
||||
}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
import { initializeConfig, type EnvConfig } from "./initialize-config";
|
||||
|
||||
export function initializeNextClientConfig(): void {
|
||||
if (typeof window === "undefined") {
|
||||
console.warn("initializeNextClientConfig called on the server. Skipping.");
|
||||
return;
|
||||
}
|
||||
|
||||
const env: Partial<EnvConfig> = {
|
||||
PORT: process.env.NEXT_PUBLIC_PORT,
|
||||
PROXY_HOST: process.env.NEXT_PUBLIC_PROXY_HOST,
|
||||
SERVER_API_URL: process.env.NEXT_PUBLIC_SERVER_API_URL,
|
||||
SITE_ID: process.env.NEXT_PUBLIC_SITE_ID,
|
||||
CLAIM_NAME: process.env.NEXT_PUBLIC_CLAIM_NAME,
|
||||
ACCESS_TOKEN: process.env.NEXT_PUBLIC_ACCESS_TOKEN,
|
||||
REFRESH_TOKEN: process.env.NEXT_PUBLIC_REFRESH_TOKEN,
|
||||
AUTH_USER_ID: process.env.NEXT_PUBLIC_AUTH_USER_ID,
|
||||
};
|
||||
initializeConfig(env);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@common/network",
|
||||
"version": "0.0.0",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"main": "./index.ts",
|
||||
"types": "./index.ts",
|
||||
|
||||
Reference in New Issue
Block a user