@daeryun/dr_components 1.2.24 → 1.2.26

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.
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- import React, { useEffect } from 'react';
3
+ import React, { useEffect, useState } from 'react';
4
4
  import { usePathname, useRouter, useSearchParams } from 'next/navigation';
5
5
  import Image from 'next/image';
6
6
  import PageWrapper from '../../../Layout/PageWrapper';
@@ -8,11 +8,15 @@ import { setCookie } from '../../../../lib';
8
8
  import LoginBreadCrumb from './LoginBreadCrumb';
9
9
  import { ILoginInfo } from '../_types/login';
10
10
  import { fetchUserData } from '../_api/fetchUserData';
11
+ import checkThirdPartyCookie from '../_api/checkThirdPartyCookie';
12
+ import { checkLogoutLog } from '../_api/checkLogoutLog';
13
+ import { fetchAuthCallback } from '../_api/fetchAuthCallback';
11
14
 
12
15
  interface props {
13
16
  layoutClassName?: string; // 높이 및 마진값 조절
14
17
  state: string;
15
18
  isTestLogin?: boolean;
19
+ isCheckRecentLogin?: boolean;
16
20
  }
17
21
 
18
22
  const LoginContainer = ({
@@ -24,7 +28,8 @@ const LoginContainer = ({
24
28
  ' max-lg:mt-[112px] ' +
25
29
  ' max-sm:mt-[100px] ',
26
30
  state,
27
- isTestLogin = false
31
+ isTestLogin = false,
32
+ isCheckRecentLogin = false // 배포중 에러방지를 위해 조건부 추가
28
33
  }: props) => {
29
34
  const router = useRouter();
30
35
  const searchParam = useSearchParams();
@@ -39,31 +44,65 @@ const LoginContainer = ({
39
44
  a.click();
40
45
  };
41
46
 
47
+ const [recentLoginProvider, setRecentLoginProvider] = useState<'kakao' | 'google' | 'naver' | 'apple' | string>('');
48
+
42
49
  const userCheck = async (): Promise<boolean> => {
43
50
  const result: ILoginInfo = await fetchUserData();
44
51
  return result.isLogin;
45
52
  };
46
53
 
47
54
  useEffect(() => {
48
- const start = Date.now(); // 시작 시각 기록
55
+ if (!isCheckRecentLogin) {
56
+ return;
57
+ }
58
+ const checkLogoutLogAction = async () => {
59
+ const isCookie = await checkThirdPartyCookie();
60
+ if (!isCookie) {
61
+ // 쿠키 차단 브라우저에서는 프론트 처리
62
+ const result = await checkLogoutLog();
63
+ if (result?.result) {
64
+ setRecentLoginProvider(result?.data?.provider || '');
65
+ }
66
+ }
67
+ // 쿠키 허용 브라우저에서는 서버에 요청에서 provider 조회
68
+ else {
69
+ const result = await fetchAuthCallback();
70
+ if (result?.result && result?.provider) {
71
+ setRecentLoginProvider(result?.provider || '');
72
+ }
73
+ }
74
+ };
75
+ checkLogoutLogAction();
76
+ }, []);
77
+
78
+ useEffect(() => {
79
+ let attemptCount = 0; // 시도 횟수
80
+ const maxAttempts = 3; // 최대 4번
81
+ const intervalTime = 3000; // 3초
49
82
 
50
83
  const interval = setInterval(async () => {
84
+ attemptCount++;
85
+
51
86
  try {
52
87
  const result = await userCheck();
88
+
53
89
  if (result) {
54
90
  const redirect = searchParam.get('redirect');
55
91
  const normalized = redirect ? (redirect.startsWith('/') ? redirect : `/${redirect}`) : '/';
56
- window.location.href = normalized;
57
- }
58
92
 
59
- // 20초가 지나면 interval 정리
60
- if (Date.now() - start > 15_000) {
61
93
  clearInterval(interval);
94
+ window.location.href = normalized;
95
+ return;
62
96
  }
63
97
  } catch (err) {
64
98
  console.error('userCheck 실패:', err);
65
99
  }
66
- }, 1000); // 1초마다 실행
100
+
101
+ // 최대 시도 횟수 도달 → 중단
102
+ if (attemptCount >= maxAttempts) {
103
+ clearInterval(interval);
104
+ }
105
+ }, intervalTime);
67
106
 
68
107
  return () => clearInterval(interval);
69
108
  }, [searchParam]);
@@ -191,6 +230,18 @@ const LoginContainer = ({
191
230
  }
192
231
  style={{ color: item.textColor, backgroundColor: item.bgColor }}
193
232
  >
233
+ {recentLoginProvider === item.identityProvider && (
234
+ <div
235
+ className={
236
+ ' absolute flex items-center justify-center bg-grayScale1 text-grayScale8 ' +
237
+ ' max-sm:label_large2_mo max-sm:-top-[10px] max-sm:right-[0px] max-sm:h-[22px] max-sm:rounded-[4px] max-sm:px-[6px] ' +
238
+ ' max-lg:label_large2_tb max-lg:-top-[10px] max-lg:right-[10px] max-lg:h-[31px] max-lg:rounded-[8px] max-lg:px-[10px] ' +
239
+ ' label_large2 -top-[12px] right-[14px] h-[37px] rounded-[12px] px-[14px] '
240
+ }
241
+ >
242
+ <p className={`!leading-none`}>최근 로그인</p>
243
+ </div>
244
+ )}
194
245
  <span className={`${item.positionClass} absolute ${item.iconClassName}`}>
195
246
  <Image
196
247
  src={`${imagePath}/common-login/${item.identityProvider}.svg`}
@@ -0,0 +1,3 @@
1
+ export declare const checkLogoutLog: () => Promise<any>;
2
+ export declare const createLogoutLog: () => Promise<any>;
3
+ export declare const deleteLogoutLog: () => Promise<any>;
@@ -0,0 +1,56 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ export const checkLogoutLog = () => __awaiter(void 0, void 0, void 0, function* () {
11
+ try {
12
+ const result = yield fetch(`${process.env.NEXT_PUBLIC_SERVICE_DOMAIN}/api/auth/get-auth/logout-log`, {
13
+ method: 'GET',
14
+ headers: {
15
+ 'Content-Type': 'application/json'
16
+ },
17
+ credentials: 'include'
18
+ }).then(obj => obj.json());
19
+ return result;
20
+ }
21
+ catch (e) {
22
+ return '';
23
+ }
24
+ });
25
+ // 브라우저 쿠키 차단시 쿠키 생성
26
+ export const createLogoutLog = () => __awaiter(void 0, void 0, void 0, function* () {
27
+ try {
28
+ const result = yield fetch(`${process.env.NEXT_PUBLIC_SERVICE_DOMAIN}/api/auth/get-auth/logout-log`, {
29
+ method: 'POST',
30
+ headers: {
31
+ 'Content-Type': 'application/json'
32
+ },
33
+ credentials: 'include'
34
+ }).then(obj => obj.json());
35
+ return result;
36
+ }
37
+ catch (e) {
38
+ return '';
39
+ }
40
+ });
41
+ // 브라우저 쿠키 차단시 쿠키 삭제
42
+ export const deleteLogoutLog = () => __awaiter(void 0, void 0, void 0, function* () {
43
+ try {
44
+ const result = yield fetch(`${process.env.NEXT_PUBLIC_SERVICE_DOMAIN}/api/auth/get-auth/logout-log`, {
45
+ method: 'DELETE',
46
+ headers: {
47
+ 'Content-Type': 'application/json'
48
+ },
49
+ credentials: 'include'
50
+ }).then(obj => obj.json());
51
+ return result;
52
+ }
53
+ catch (e) {
54
+ return '';
55
+ }
56
+ });
@@ -0,0 +1,49 @@
1
+
2
+
3
+ export const checkLogoutLog = async () => {
4
+ try {
5
+ const result = await fetch(`${process.env.NEXT_PUBLIC_SERVICE_DOMAIN}/api/auth/get-auth/logout-log`, {
6
+ method: 'GET',
7
+ headers: {
8
+ 'Content-Type': 'application/json'
9
+ },
10
+ credentials: 'include'
11
+ }).then(obj => obj.json());
12
+
13
+ return result;
14
+ } catch (e) {
15
+ return '';
16
+ }
17
+ };
18
+
19
+ // 브라우저 쿠키 차단시 쿠키 생성
20
+ export const createLogoutLog = async () => {
21
+ try {
22
+ const result = await fetch(`${process.env.NEXT_PUBLIC_SERVICE_DOMAIN}/api/auth/get-auth/logout-log`, {
23
+ method: 'POST',
24
+ headers: {
25
+ 'Content-Type': 'application/json'
26
+ },
27
+ credentials: 'include'
28
+ }).then(obj => obj.json());
29
+ return result;
30
+ } catch (e) {
31
+ return '';
32
+ }
33
+ }
34
+
35
+ // 브라우저 쿠키 차단시 쿠키 삭제
36
+ export const deleteLogoutLog = async () => {
37
+ try {
38
+ const result = await fetch(`${process.env.NEXT_PUBLIC_SERVICE_DOMAIN}/api/auth/get-auth/logout-log`, {
39
+ method: 'DELETE',
40
+ headers: {
41
+ 'Content-Type': 'application/json'
42
+ },
43
+ credentials: 'include'
44
+ }).then(obj => obj.json());
45
+ return result;
46
+ } catch (e) {
47
+ return '';
48
+ }
49
+ };
@@ -7,18 +7,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
+ import Fetch from "../_fetch/fetch";
10
11
  const logout = () => __awaiter(void 0, void 0, void 0, function* () {
11
12
  const SESSION_KEY = process.env.NEXT_PUBLIC_USER_SESSION_STORAGE_KEY || 'loginUser';
12
13
  try {
13
- // const res = await Fetch('/api/lawfirm/app/auth/logout', {
14
- // method: 'POST'
15
- // });
16
- const res = yield fetch(`${process.env.NEXT_PUBLIC_LAWFIRM_API}/api/app/auth/logout`, {
14
+ const res = yield Fetch(`/api/lawfirm/app/auth/logout`, {
17
15
  method: 'POST',
18
- headers: { 'Content-Type': 'application/json' },
19
- cache: 'no-cache',
20
16
  credentials: 'include'
21
- }).then(res => res.json());
17
+ });
18
+ // const res = await fetch(`${process.env.NEXT_PUBLIC_LAWFIRM_API}/api/app/auth/logout`, {
19
+ // method: 'POST',
20
+ // headers: { 'Content-Type': 'application/json' },
21
+ // cache: 'no-cache',
22
+ // credentials: 'include'
23
+ // }).then((res) => res.json())
22
24
  if (res.result) {
23
25
  const result = yield fetch(`${process.env.NEXT_PUBLIC_SERVICE_DOMAIN}/api/auth/token`, {
24
26
  method: 'DELETE',
@@ -1,15 +1,18 @@
1
+ import Fetch from "../_fetch/fetch";
2
+
1
3
  const logout = async () => {
2
4
  const SESSION_KEY = process.env.NEXT_PUBLIC_USER_SESSION_STORAGE_KEY || 'loginUser';
3
5
  try {
4
- // const res = await Fetch('/api/lawfirm/app/auth/logout', {
5
- // method: 'POST'
6
- // });
7
- const res = await fetch(`${process.env.NEXT_PUBLIC_LAWFIRM_API}/api/app/auth/logout`, {
6
+ const res = await Fetch(`/api/lawfirm/app/auth/logout`, {
8
7
  method: 'POST',
9
- headers: { 'Content-Type': 'application/json' },
10
- cache: 'no-cache',
11
8
  credentials: 'include'
12
- }).then(res => res.json());
9
+ })
10
+ // const res = await fetch(`${process.env.NEXT_PUBLIC_LAWFIRM_API}/api/app/auth/logout`, {
11
+ // method: 'POST',
12
+ // headers: { 'Content-Type': 'application/json' },
13
+ // cache: 'no-cache',
14
+ // credentials: 'include'
15
+ // }).then((res) => res.json())
13
16
  if (res.result) {
14
17
  const result = await fetch(`${process.env.NEXT_PUBLIC_SERVICE_DOMAIN}/api/auth/token`, {
15
18
  method: 'DELETE',
@@ -8,9 +8,28 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ import { createLogoutLog } from '../_api/checkLogoutLog';
12
+ import checkThirdPartyCookie from '../_api/checkThirdPartyCookie';
11
13
  // 로펌용
12
- import { deleteToken } from '../_api/token';
14
+ import { deleteToken, getToken } from '../_api/token';
13
15
  const Fetch = (url_1, ...args_1) => __awaiter(void 0, [url_1, ...args_1], void 0, function* (url, options = {}) {
16
+ if (url === '/api/lawfirm/app/auth/logout') {
17
+ const result = yield getToken();
18
+ const isCookie = yield checkThirdPartyCookie();
19
+ // console.log('isCookie', isCookie);
20
+ if (!isCookie) {
21
+ yield createLogoutLog();
22
+ // console.log('res', res);
23
+ }
24
+ const res = yield fetch(`${process.env.NEXT_PUBLIC_LAWFIRM_API}/api/app/auth/logout`, {
25
+ method: 'POST',
26
+ headers: { 'Content-Type': 'application/json', 'Authorization': `${result || ''}` },
27
+ cache: 'no-cache',
28
+ credentials: 'include'
29
+ }).then((res) => res.json());
30
+ // console.log('res', res);
31
+ return res;
32
+ }
14
33
  options = Object.assign(Object.assign({}, options), { credentials: 'include' });
15
34
  options.headers = Object.assign(Object.assign({}, options.headers), { Accept: 'application/json;charset=UTF-8' });
16
35
  if ((options === null || options === void 0 ? void 0 : options.method) === 'POST' && options.type !== 'form') {
@@ -1,9 +1,31 @@
1
1
  'use client';
2
+ import { createLogoutLog } from '../_api/checkLogoutLog';
3
+ import checkThirdPartyCookie from '../_api/checkThirdPartyCookie';
2
4
  // 로펌용
3
5
 
4
- import { deleteToken } from '../_api/token';
6
+ import { deleteToken, getToken } from '../_api/token';
5
7
 
6
8
  const Fetch = async (url: string, options: any = {}) => {
9
+
10
+ if (url ==='/api/lawfirm/app/auth/logout') {
11
+ const result = await getToken();
12
+ const isCookie = await checkThirdPartyCookie();
13
+ // console.log('isCookie', isCookie);
14
+ if(!isCookie){
15
+ await createLogoutLog();
16
+ // console.log('res', res);
17
+ }
18
+
19
+ const res = await fetch(`${process.env.NEXT_PUBLIC_LAWFIRM_API}/api/app/auth/logout`, {
20
+ method: 'POST',
21
+ headers: { 'Content-Type': 'application/json', 'Authorization': `${result ||''}` },
22
+ cache: 'no-cache',
23
+ credentials: 'include'
24
+ }).then((res) => res.json())
25
+ // console.log('res', res);
26
+
27
+ return res;
28
+ }
7
29
  options = {
8
30
  ...options,
9
31
  credentials: 'include'
@@ -874,6 +874,10 @@ html {
874
874
  top: -10px;
875
875
  }
876
876
 
877
+ .-top-\[12px\] {
878
+ top: -12px;
879
+ }
880
+
877
881
  .-top-\[1px\] {
878
882
  top: -1px;
879
883
  }
@@ -1106,6 +1110,10 @@ html {
1106
1110
  right: 120px;
1107
1111
  }
1108
1112
 
1113
+ .right-\[14px\] {
1114
+ right: 14px;
1115
+ }
1116
+
1109
1117
  .right-\[15px\] {
1110
1118
  right: 15px;
1111
1119
  }
@@ -2701,6 +2709,10 @@ html {
2701
2709
  height: 36px;
2702
2710
  }
2703
2711
 
2712
+ .h-\[37px\] {
2713
+ height: 37px;
2714
+ }
2715
+
2704
2716
  .h-\[383px\] {
2705
2717
  height: 383px;
2706
2718
  }
@@ -13880,6 +13892,10 @@ body {
13880
13892
  left: -20px;
13881
13893
  }
13882
13894
 
13895
+ .max-lg\:-top-\[10px\] {
13896
+ top: -10px;
13897
+ }
13898
+
13883
13899
  .max-lg\:bottom-0 {
13884
13900
  bottom: 0px;
13885
13901
  }
@@ -14283,6 +14299,10 @@ body {
14283
14299
  height: 30px;
14284
14300
  }
14285
14301
 
14302
+ .max-lg\:h-\[31px\] {
14303
+ height: 31px;
14304
+ }
14305
+
14286
14306
  .max-lg\:h-\[32px\] {
14287
14307
  height: 32px;
14288
14308
  }
@@ -17279,6 +17299,10 @@ body {
17279
17299
  top: 20px !important;
17280
17300
  }
17281
17301
 
17302
+ .max-sm\:-top-\[10px\] {
17303
+ top: -10px;
17304
+ }
17305
+
17282
17306
  .max-sm\:bottom-\[0px\] {
17283
17307
  bottom: 0px;
17284
17308
  }
@@ -17640,6 +17664,10 @@ body {
17640
17664
  height: 224px;
17641
17665
  }
17642
17666
 
17667
+ .max-sm\:h-\[22px\] {
17668
+ height: 22px;
17669
+ }
17670
+
17643
17671
  .max-sm\:h-\[24px\] {
17644
17672
  height: 24px;
17645
17673
  }
@@ -18191,6 +18219,11 @@ body {
18191
18219
  padding-right: 20px;
18192
18220
  }
18193
18221
 
18222
+ .max-sm\:px-\[6px\] {
18223
+ padding-left: 6px;
18224
+ padding-right: 6px;
18225
+ }
18226
+
18194
18227
  .max-sm\:py-1 {
18195
18228
  padding-top: 0.25rem;
18196
18229
  padding-bottom: 0.25rem;