@daeryun/dr_components 1.2.21 → 1.2.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/components/Daeryuntalk/ChatButton.jsx +1 -1
- package/dist/components/Daeryuntalk/ChatButton.tsx +1 -1
- package/dist/components/Daeryuntalk/index.jsx +1 -1
- package/dist/components/Daeryuntalk/index.tsx +2 -5
- package/dist/components/banner/TopBanner.jsx +62 -10
- package/dist/components/banner/TopBanner.module.css +8 -1
- package/dist/components/banner/TopBanner.tsx +79 -22
- package/dist/components/common/integrate/index.d.ts +1 -1
- package/dist/styles/globals.css +414 -410
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -13,6 +13,7 @@ import classNames from 'classnames';
|
|
|
13
13
|
import Link from 'next/link';
|
|
14
14
|
import useBrowser from '../hook/useBrowser';
|
|
15
15
|
import { SetterOrUpdater } from 'recoil';
|
|
16
|
+
import { usePathname, useRouter } from 'next/navigation';
|
|
16
17
|
|
|
17
18
|
//배너타입
|
|
18
19
|
interface IBannerTypes {
|
|
@@ -102,6 +103,8 @@ const TopBanner = ({ setBannerHeight }: { setBannerHeight?: SetterOrUpdater<numb
|
|
|
102
103
|
const ImagePath: string = process.env.NEXT_PUBLIC_S3_URL + '';
|
|
103
104
|
const { width } = useBrowser();
|
|
104
105
|
const bannerRef = useRef<HTMLDivElement>(null);
|
|
106
|
+
const router = useRouter();
|
|
107
|
+
const pathname = usePathname();
|
|
105
108
|
|
|
106
109
|
//팝업 리스트
|
|
107
110
|
const [popup, setPopup] = useState<IBannerTypes[]>([]);
|
|
@@ -121,30 +124,84 @@ const TopBanner = ({ setBannerHeight }: { setBannerHeight?: SetterOrUpdater<numb
|
|
|
121
124
|
gcTime: Infinity,
|
|
122
125
|
staleTime: Infinity
|
|
123
126
|
});
|
|
127
|
+
|
|
128
|
+
useEffect(() => {
|
|
129
|
+
if (typeof window === 'undefined') return; // SSR 보호 ●
|
|
130
|
+
|
|
131
|
+
const sourceData = popupData || [];
|
|
132
|
+
|
|
133
|
+
if (sourceData.length > 0) {
|
|
134
|
+
setPopup(filterBannerData(sourceData));
|
|
135
|
+
}
|
|
136
|
+
}, [router, pathname, popupData]);
|
|
137
|
+
|
|
138
|
+
const filterBannerData = (data: any[]) => {
|
|
139
|
+
const kstDateTime = DateTime.now().setZone('Asia/Seoul');
|
|
140
|
+
const nowDate = Number(kstDateTime.year + '' + zeroMaker(kstDateTime.month) + '' + zeroMaker(kstDateTime.day));
|
|
141
|
+
const nowTime = Number(zeroMaker(kstDateTime.hour) + zeroMaker(kstDateTime.minute));
|
|
142
|
+
const weekday = kstDateTime.weekdayShort + '';
|
|
143
|
+
const currentPath = pathname.split('?')[0].split('#')[0]; // 현재 경로 (쿼리/해시 제거)
|
|
144
|
+
|
|
145
|
+
const dateData = data.filter(
|
|
146
|
+
(item: any) =>
|
|
147
|
+
findDate(item, 'start') <= nowDate &&
|
|
148
|
+
findDate(item, 'end') >= nowDate &&
|
|
149
|
+
findDays(item, weekday) &&
|
|
150
|
+
findTime(item, nowTime)
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
return dateData.filter((item: IBannerTypes) => {
|
|
154
|
+
// localStorage로 닫힌 배너 제외
|
|
155
|
+
if (
|
|
156
|
+
localStorage.getItem(item.idx + '_CloseTopPop') &&
|
|
157
|
+
Number(localStorage.getItem(item.idx + '_CloseTopPop')) > new Date().getTime()
|
|
158
|
+
) {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// 현재 경로와 배너 링크 비교
|
|
163
|
+
// PC인 경우: pc_link 또는 p_link 확인
|
|
164
|
+
// 모바일인 경우: mobile_link 또는 p_link 확인
|
|
165
|
+
const bannerLink = width > 900 ? item.pc_link || item.p_link : item.mobile_link || item.p_link;
|
|
166
|
+
|
|
167
|
+
// 링크가 없으면 표시
|
|
168
|
+
if (!bannerLink) {
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// 배너 링크에서 경로 부분만 추출
|
|
173
|
+
// 전체 URL인 경우 (https://www.daeryunlaw.com/relief) 경로 부분만 추출
|
|
174
|
+
// 상대 경로인 경우 (/relief) 그대로 사용
|
|
175
|
+
let bannerPath = bannerLink.split('?')[0].split('#')[0]; // 쿼리/해시 제거
|
|
176
|
+
|
|
177
|
+
// http:// 또는 https://로 시작하는 전체 URL인 경우 경로 부분만 추출
|
|
178
|
+
if (bannerPath.startsWith('http://') || bannerPath.startsWith('https://')) {
|
|
179
|
+
try {
|
|
180
|
+
const url = new URL(bannerPath);
|
|
181
|
+
bannerPath = url.pathname;
|
|
182
|
+
} catch {
|
|
183
|
+
// URL 파싱 실패 시 그대로 사용
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// 경로가 /로 시작하지 않으면 /를 추가
|
|
188
|
+
if (bannerPath && !bannerPath.startsWith('/')) {
|
|
189
|
+
bannerPath = '/' + bannerPath;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// 경로 끝의 슬래시 제거하여 정규화 (예: /relief/ → /relief)
|
|
193
|
+
bannerPath = bannerPath.replace(/\/$/, '');
|
|
194
|
+
const normalizedCurrentPath = currentPath.replace(/\/$/, '');
|
|
195
|
+
|
|
196
|
+
// 정확히 일치하는 경우에만 배너를 표시하지 않음
|
|
197
|
+
// 예: 배너 링크가 /relief이고 현재 경로가 /relief일 때만 숨김
|
|
198
|
+
return normalizedCurrentPath !== bannerPath;
|
|
199
|
+
});
|
|
200
|
+
};
|
|
201
|
+
|
|
124
202
|
useEffect(() => {
|
|
125
203
|
if (popupData) {
|
|
126
|
-
|
|
127
|
-
const nowDate = Number(
|
|
128
|
-
kstDateTime.year + '' + zeroMaker(kstDateTime.month) + '' + zeroMaker(kstDateTime.day)
|
|
129
|
-
);
|
|
130
|
-
const nowTime = Number(zeroMaker(kstDateTime.hour) + zeroMaker(kstDateTime.minute));
|
|
131
|
-
const weekday = kstDateTime.weekdayShort + '';
|
|
132
|
-
const dateData = popupData.filter(
|
|
133
|
-
item =>
|
|
134
|
-
findDate(item, 'start') <= nowDate &&
|
|
135
|
-
findDate(item, 'end') >= nowDate &&
|
|
136
|
-
findDays(item, weekday) &&
|
|
137
|
-
findTime(item, nowTime)
|
|
138
|
-
);
|
|
139
|
-
setPopup(
|
|
140
|
-
dateData.filter(
|
|
141
|
-
item =>
|
|
142
|
-
!(
|
|
143
|
-
localStorage.getItem(item.idx + '_CloseTopPop') &&
|
|
144
|
-
Number(localStorage.getItem(item.idx + '_CloseTopPop')) > new Date().getTime()
|
|
145
|
-
)
|
|
146
|
-
)
|
|
147
|
-
);
|
|
204
|
+
setPopup(filterBannerData(popupData));
|
|
148
205
|
}
|
|
149
206
|
}, [popupData]);
|
|
150
207
|
|