@daeryun/dr_components 0.4.22 → 0.4.24

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.
@@ -14,6 +14,7 @@ import checkThirdPartyCookie from './_api/checkThirdPartyCookie';
14
14
  import { fetchAuthCallback } from './_api/fetchAuthCallback';
15
15
  import { deleteToken } from './_api/token';
16
16
  import { fetchUserData } from './_api/fetchUserData';
17
+ import createTokenAndFetchUser from './_api/createTokenAndFetchUser';
17
18
  const AppHeaderContainer = ({ children, serverUserInfo }) => {
18
19
  // userInfo 가 true 인 경우 확인 돌려야 함.
19
20
  const pathName = usePathname();
@@ -81,12 +82,3 @@ const AppHeaderContainer = ({ children, serverUserInfo }) => {
81
82
  return <Fragment>{childrenWithProps}</Fragment>;
82
83
  };
83
84
  export default AppHeaderContainer;
84
- const createTokenAndFetchUser = (jwt, cookies) => __awaiter(void 0, void 0, void 0, function* () {
85
- const createTokenResult = yield fetch(`${process.env.NEXT_PUBLIC_SERVICE_DOMAIN}/api/auth/token`, {
86
- body: JSON.stringify({ jwt }),
87
- method: 'POST',
88
- headers: Object.assign({ 'Content-Type': 'application/json' }, (cookies !== '' ? { Cookie: cookies } : {})),
89
- credentials: 'include'
90
- }).then(res => res.json());
91
- return createTokenResult.token;
92
- });
@@ -6,6 +6,7 @@ import checkThirdPartyCookie from './_api/checkThirdPartyCookie';
6
6
  import { fetchAuthCallback } from './_api/fetchAuthCallback';
7
7
  import { deleteToken } from './_api/token';
8
8
  import { fetchUserData } from './_api/fetchUserData';
9
+ import createTokenAndFetchUser from './_api/createTokenAndFetchUser';
9
10
 
10
11
  type props = {
11
12
  children: React.ReactNode;
@@ -81,17 +82,3 @@ const AppHeaderContainer = ({ children, serverUserInfo }: props) => {
81
82
  };
82
83
 
83
84
  export default AppHeaderContainer;
84
-
85
- const createTokenAndFetchUser = async (jwt: string, cookies?: string) => {
86
- const createTokenResult = await fetch(`${process.env.NEXT_PUBLIC_SERVICE_DOMAIN}/api/auth/token`, {
87
- body: JSON.stringify({ jwt }),
88
- method: 'POST',
89
- headers: {
90
- 'Content-Type': 'application/json',
91
- ...(cookies !== '' ? { Cookie: cookies } : {})
92
- },
93
- credentials: 'include'
94
- }).then(res => res.json());
95
-
96
- return createTokenResult.token;
97
- };
@@ -28,10 +28,12 @@ import { useQuery } from '@tanstack/react-query';
28
28
  import Loader from '../../../Loader/Loader';
29
29
  import OptionalCheckBox from './Sign/OptionalCheckBox';
30
30
  import { optionalTermAgree } from '../_api/optionalTermAgree';
31
+ import createToken from '../_api/createTokenAndFetchUser';
31
32
  const SignContainer = ({ layoutClassName = `mt-[47px] py-[128px] max-lg:mt-[40px] max-lg:py-[112px] max-sm:mt-[28px] max-sm:py-[100px]`, setUser }) => {
32
33
  var _a, _b;
33
34
  const session_key = process.env.NEXT_PUBLIC_USER_SESSION_STORAGE_KEY || 'loginUser';
34
35
  const [termCode, setTermCode] = useState('');
36
+ const [jwtToken, setJwtToken] = useState('');
35
37
  const [requiredTermItems, setRequiredTermItems] = useState([
36
38
  { title: '전체 동의', name: 'all', checked: false, isContent: false, isAll: true, termCode: '', contents: '' },
37
39
  {
@@ -168,6 +170,7 @@ const SignContainer = ({ layoutClassName = `mt-[47px] py-[128px] max-lg:mt-[40px
168
170
  const signCookie = () => __awaiter(void 0, void 0, void 0, function* () {
169
171
  const responseToken = yield getToken();
170
172
  if (responseToken) {
173
+ setJwtToken(responseToken);
171
174
  // setSignToken(responseToken);
172
175
  const decoded = jwtDecode(responseToken);
173
176
  setUserJwtObj({
@@ -459,8 +462,9 @@ const SignContainer = ({ layoutClassName = `mt-[47px] py-[128px] max-lg:mt-[40px
459
462
  };
460
463
  setUser && sessionStorage.setItem(session_key || '', JSON.stringify(userData));
461
464
  setUser && setUser(userData);
462
- // router.push(redirect);
463
- window.location.href = redirect;
465
+ yield createToken(jwtToken);
466
+ router.push(redirect);
467
+ // window.location.href = redirect;
464
468
  }
465
469
  else {
466
470
  yield deleteToken();
@@ -28,6 +28,7 @@ import Loader from '../../../Loader/Loader';
28
28
  import { ITermType } from '../_types/termType';
29
29
  import OptionalCheckBox from './Sign/OptionalCheckBox';
30
30
  import { optionalTermAgree } from '../_api/optionalTermAgree';
31
+ import createToken from '../_api/createTokenAndFetchUser';
31
32
 
32
33
  interface IUser {
33
34
  name: string;
@@ -80,6 +81,7 @@ const SignContainer = ({
80
81
  }: props) => {
81
82
  const session_key = process.env.NEXT_PUBLIC_USER_SESSION_STORAGE_KEY || 'loginUser';
82
83
  const [termCode, setTermCode] = useState<string>('');
84
+ const [jwtToken, setJwtToken] = useState<string>('');
83
85
 
84
86
  const [requiredTermItems, setRequiredTermItems] = useState<IRequiredCheckItem[]>([
85
87
  { title: '전체 동의', name: 'all', checked: false, isContent: false, isAll: true, termCode: '', contents: '' },
@@ -230,6 +232,7 @@ const SignContainer = ({
230
232
  const signCookie = async () => {
231
233
  const responseToken = await getToken();
232
234
  if (responseToken) {
235
+ setJwtToken(responseToken);
233
236
  // setSignToken(responseToken);
234
237
  const decoded: {
235
238
  idx: number;
@@ -571,8 +574,9 @@ const SignContainer = ({
571
574
  };
572
575
  setUser && sessionStorage.setItem(session_key || '', JSON.stringify(userData));
573
576
  setUser && setUser(userData);
574
- // router.push(redirect);
575
- window.location.href = redirect;
577
+ await createToken(jwtToken);
578
+ router.push(redirect);
579
+ // window.location.href = redirect;
576
580
  } else {
577
581
  await deleteToken();
578
582
  }
@@ -17,6 +17,7 @@ import LoginBreadCrumb from './LoginComp/LoginBreadCrumb';
17
17
  import WithdrawCheckBox from './LoginComp/Withdraw/WithdrawCheckBox';
18
18
  import Image from 'next/image';
19
19
  const Withdraw = ({ layoutClassName = `py-[128px] max-lg:py-[112px] max-sm:py-[100px] `, resetUser }) => {
20
+ const SESSION_KEY = process.env.NEXT_PUBLIC_USER_SESSION_STORAGE_KEY || 'loginUser';
20
21
  const router = useRouter();
21
22
  const imagePath = process.env.NEXT_PUBLIC_S3_URL + '';
22
23
  const [reasons, setReasons] = useState([
@@ -59,6 +60,7 @@ const Withdraw = ({ layoutClassName = `py-[128px] max-lg:py-[112px] max-sm:py-[1
59
60
  try {
60
61
  const result = yield withdraw({ bodyData: { reason } });
61
62
  if (result.result) {
63
+ resetUser && sessionStorage.removeItem(SESSION_KEY);
62
64
  resetUser && resetUser();
63
65
  yield deleteToken();
64
66
  // router.push('/');
@@ -18,6 +18,7 @@ type props = {
18
18
  resetUser?: () => void;
19
19
  };
20
20
  const Withdraw = ({ layoutClassName = `py-[128px] max-lg:py-[112px] max-sm:py-[100px] `, resetUser }: props) => {
21
+ const SESSION_KEY = process.env.NEXT_PUBLIC_USER_SESSION_STORAGE_KEY || 'loginUser';
21
22
  const router = useRouter();
22
23
  const imagePath: string = process.env.NEXT_PUBLIC_S3_URL + '';
23
24
  const [reasons, setReasons] = useState<IWithdraw[]>([
@@ -66,7 +67,9 @@ const Withdraw = ({ layoutClassName = `py-[128px] max-lg:py-[112px] max-sm:py-[1
66
67
  const reason = getSelectedReason();
67
68
  try {
68
69
  const result = await withdraw({ bodyData: { reason } });
70
+
69
71
  if (result.result) {
72
+ resetUser && sessionStorage.removeItem(SESSION_KEY);
70
73
  resetUser && resetUser();
71
74
  await deleteToken();
72
75
  // router.push('/');
@@ -0,0 +1,2 @@
1
+ declare const createToken: (jwt: string, cookies?: string) => Promise<any>;
2
+ export default createToken;
@@ -0,0 +1,19 @@
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
+ const createToken = (jwt, cookies) => __awaiter(void 0, void 0, void 0, function* () {
11
+ const createTokenResult = yield fetch(`${process.env.NEXT_PUBLIC_SERVICE_DOMAIN}/api/auth/token`, {
12
+ body: JSON.stringify({ jwt }),
13
+ method: 'POST',
14
+ headers: Object.assign({ 'Content-Type': 'application/json' }, (cookies !== '' ? { Cookie: cookies } : {})),
15
+ credentials: 'include'
16
+ }).then(res => res.json());
17
+ return createTokenResult.token;
18
+ });
19
+ export default createToken;
@@ -0,0 +1,14 @@
1
+ const createToken = async (jwt: string, cookies?: string) => {
2
+ const createTokenResult = await fetch(`${process.env.NEXT_PUBLIC_SERVICE_DOMAIN}/api/auth/token`, {
3
+ body: JSON.stringify({ jwt }),
4
+ method: 'POST',
5
+ headers: {
6
+ 'Content-Type': 'application/json',
7
+ ...(cookies !== '' ? { Cookie: cookies } : {})
8
+ },
9
+ credentials: 'include'
10
+ }).then(res => res.json());
11
+
12
+ return createTokenResult.token;
13
+ };
14
+ export default createToken;
@@ -11,7 +11,8 @@ import Fetch from '../_fetch/fetch';
11
11
  export const withdraw = (_a) => __awaiter(void 0, [_a], void 0, function* ({ bodyData }) {
12
12
  try {
13
13
  const res = yield Fetch('/api/lawfirm/app/user', {
14
- method: 'DELETE'
14
+ method: 'DELETE',
15
+ body: JSON.stringify(bodyData)
15
16
  });
16
17
  if (res.result) {
17
18
  yield fetch(`${process.env.NEXT_PUBLIC_SERVICE_DOMAIN}/api/auth/token`, {
@@ -3,7 +3,8 @@ import Fetch from '../_fetch/fetch';
3
3
  export const withdraw = async ({ bodyData }: { bodyData: { reason: string } }) => {
4
4
  try {
5
5
  const res = await Fetch('/api/lawfirm/app/user', {
6
- method: 'DELETE'
6
+ method: 'DELETE',
7
+ body: JSON.stringify(bodyData)
7
8
  });
8
9
  if (res.result) {
9
10
  await fetch(`${process.env.NEXT_PUBLIC_SERVICE_DOMAIN}/api/auth/token`, {