@daeryun/dr_components 0.3.68 → 0.3.70

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.
@@ -3,10 +3,10 @@ import Image from 'next/image';
3
3
  const RequiredCheckBox = ({ title, isContent, name, setModal, checked, index, isAll = false, handleButton }) => {
4
4
  const imagePath = process.env.NEXT_PUBLIC_S3_URL + '';
5
5
  return (<div className={'flex w-full flex-row justify-between '}>
6
- <button onClick={handleButton} type={'button'} name={name} data-idx={index} className={' flex w-[calc(100%-34px)] flex-row items-center gap-[20px] ' +
6
+ <button onClick={handleButton} type={'button'} name={name} data-idx={index} className={' flex w-[calc(100%-34px)] flex-row items-center gap-[20px] ' +
7
7
  ' max-lg:w-[calc(100%-31px)] max-lg:gap-[12px] ' +
8
8
  ' max-sm:w-[calc(100%-24px)] max-sm:gap-[10px] '}>
9
- {checked ? (<span className={' flex items-center justify-center ' +
9
+ {checked ? (<span className={' flex items-center justify-center ' +
10
10
  ' h-[24px] w-[24px] rounded-[28px] ' +
11
11
  ' max-lg:h-[20px] max-lg:w-[20px] ' +
12
12
  ' max-sm:h-[16px] max-sm:w-[16px] '}>
@@ -14,19 +14,19 @@ const RequiredCheckBox = ({ title, isContent, name, setModal, checked, index, is
14
14
  </span>) : (<span className={' h-[24px] w-[24px] rounded-[28px] border-[1px] border-solid border-[#B9B9B9] ' +
15
15
  ' max-lg:h-[20px] max-lg:w-[20px] ' +
16
16
  ' max-sm:h-[16px] max-sm:w-[16px] '}></span>)}
17
- <span className={' text-black ' +
17
+ <span className={' text-black ' +
18
18
  ` ${isAll ? ' body_medium1 ' : ' body_medium2 '} ` +
19
19
  ` ${isAll ? ' max-lg:body_medium1_tb ' : ' max-lg:body_medium2_tb '} ` +
20
20
  ` ${isAll ? ' max-sm:body_medium1_mo ' : ' max-sm:body_medium2_mo '} `}>
21
21
  {title}
22
22
  </span>
23
- </button>
24
- {isContent ? (<button type={'button'} onClick={setModal} className={' underline-[#606060] text-[#606060] underline underline-offset-2 ' +
23
+ </button>
24
+ {isContent ? (<button type={'button'} onClick={setModal} className={' underline-[#606060] text-[#606060] underline underline-offset-2 ' +
25
25
  ' body_small2 ' +
26
26
  ' max-lg:body_small2_tb ' +
27
27
  ' max-sm:body_small2_mo '}>
28
- 보기
29
- </button>) : (<></>)}
30
- </div>);
28
+ 보기
29
+ </button>) : (<></>)}
30
+ </div>);
31
31
  };
32
32
  export default RequiredCheckBox;
@@ -2,93 +2,93 @@ import React from 'react';
2
2
  import Image from 'next/image';
3
3
 
4
4
  const RequiredCheckBox = ({
5
- title,
6
- isContent,
7
- name,
8
- setModal,
9
- checked,
10
- index,
11
- isAll = false,
12
- handleButton
13
- }: {
14
- title: string;
15
- isContent: boolean;
16
- name: string;
17
- setModal: () => void;
18
- index: number;
19
- checked: boolean;
20
- isAll?: boolean;
21
- handleButton: (e: React.FormEvent<HTMLButtonElement>) => void;
5
+ title,
6
+ isContent,
7
+ name,
8
+ setModal,
9
+ checked,
10
+ index,
11
+ isAll = false,
12
+ handleButton
13
+ }: {
14
+ title: string;
15
+ isContent: boolean;
16
+ name: string;
17
+ setModal: () => void;
18
+ index: number;
19
+ checked: boolean;
20
+ isAll?: boolean;
21
+ handleButton: (e: React.FormEvent<HTMLButtonElement>) => void;
22
22
  }) => {
23
- const imagePath: string = process.env.NEXT_PUBLIC_S3_URL + '';
24
- return (
25
- <div className={'flex w-full flex-row justify-between '}>
26
- <button
27
- onClick={handleButton}
28
- type={'button'}
29
- name={name}
30
- data-idx={index}
31
- className={
32
- ' flex w-[calc(100%-34px)] flex-row items-center gap-[20px] ' +
33
- ' max-lg:w-[calc(100%-31px)] max-lg:gap-[12px] ' +
34
- ' max-sm:w-[calc(100%-24px)] max-sm:gap-[10px] '
35
- }
36
- >
37
- {checked ? (
38
- <span
39
- className={
40
- ' flex items-center justify-center ' +
41
- ' h-[24px] w-[24px] rounded-[28px] ' +
42
- ' max-lg:h-[20px] max-lg:w-[20px] ' +
43
- ' max-sm:h-[16px] max-sm:w-[16px] '
44
- }
45
- >
23
+ const imagePath: string = process.env.NEXT_PUBLIC_S3_URL + '';
24
+ return (
25
+ <div className={'flex w-full flex-row justify-between '}>
26
+ <button
27
+ onClick={handleButton}
28
+ type={'button'}
29
+ name={name}
30
+ data-idx={index}
31
+ className={
32
+ ' flex w-[calc(100%-34px)] flex-row items-center gap-[20px] ' +
33
+ ' max-lg:w-[calc(100%-31px)] max-lg:gap-[12px] ' +
34
+ ' max-sm:w-[calc(100%-24px)] max-sm:gap-[10px] '
35
+ }
36
+ >
37
+ {checked ? (
38
+ <span
39
+ className={
40
+ ' flex items-center justify-center ' +
41
+ ' h-[24px] w-[24px] rounded-[28px] ' +
42
+ ' max-lg:h-[20px] max-lg:w-[20px] ' +
43
+ ' max-sm:h-[16px] max-sm:w-[16px] '
44
+ }
45
+ >
46
46
  <Image
47
- src={`${imagePath}/common-login/check box.svg`}
48
- alt={'check box'}
49
- height={100}
50
- width={100}
51
- className={`h-full w-full`}
47
+ src={`${imagePath}/common-login/check box.svg`}
48
+ alt={'check box'}
49
+ height={100}
50
+ width={100}
51
+ className={`h-full w-full`}
52
52
  />
53
53
  </span>
54
- ) : (
55
- <span
56
- className={
57
- ' h-[24px] w-[24px] rounded-[28px] border-[1px] border-solid border-[#B9B9B9] ' +
58
- ' max-lg:h-[20px] max-lg:w-[20px] ' +
59
- ' max-sm:h-[16px] max-sm:w-[16px] '
60
- }
61
- ></span>
62
- )}
63
- <span
64
- className={
65
- ' text-black ' +
66
- ` ${isAll ? ' body_medium1 ' : ' body_medium2 '} ` +
67
- ` ${isAll ? ' max-lg:body_medium1_tb ' : ' max-lg:body_medium2_tb '} ` +
68
- ` ${isAll ? ' max-sm:body_medium1_mo ' : ' max-sm:body_medium2_mo '} `
69
- }
70
- >
54
+ ) : (
55
+ <span
56
+ className={
57
+ ' h-[24px] w-[24px] rounded-[28px] border-[1px] border-solid border-[#B9B9B9] ' +
58
+ ' max-lg:h-[20px] max-lg:w-[20px] ' +
59
+ ' max-sm:h-[16px] max-sm:w-[16px] '
60
+ }
61
+ ></span>
62
+ )}
63
+ <span
64
+ className={
65
+ ' text-black ' +
66
+ ` ${isAll ? ' body_medium1 ' : ' body_medium2 '} ` +
67
+ ` ${isAll ? ' max-lg:body_medium1_tb ' : ' max-lg:body_medium2_tb '} ` +
68
+ ` ${isAll ? ' max-sm:body_medium1_mo ' : ' max-sm:body_medium2_mo '} `
69
+ }
70
+ >
71
71
  {title}
72
72
  </span>
73
- </button>
74
- {isContent ? (
75
- <button
76
- type={'button'}
77
- onClick={setModal}
78
- className={
79
- ' underline-[#606060] text-[#606060] underline underline-offset-2 ' +
80
- ' body_small2 ' +
81
- ' max-lg:body_small2_tb ' +
82
- ' max-sm:body_small2_mo '
83
- }
84
- >
85
- 보기
86
- </button>
87
- ) : (
88
- <></>
89
- )}
90
- </div>
91
- );
73
+ </button>
74
+ {isContent ? (
75
+ <button
76
+ type={'button'}
77
+ onClick={setModal}
78
+ className={
79
+ ' underline-[#606060] text-[#606060] underline underline-offset-2 ' +
80
+ ' body_small2 ' +
81
+ ' max-lg:body_small2_tb ' +
82
+ ' max-sm:body_small2_mo '
83
+ }
84
+ >
85
+ 보기
86
+ </button>
87
+ ) : (
88
+ <></>
89
+ )}
90
+ </div>
91
+ );
92
92
  };
93
93
 
94
94
  export default RequiredCheckBox;
@@ -1,19 +1,5 @@
1
1
  import React from 'react';
2
2
  import { ILoginInfo } from '../_types/login';
3
- export interface IOptionalCheckItem {
4
- title: string;
5
- checked: boolean;
6
- name: string;
7
- isContent: boolean;
8
- cautionTitle: string;
9
- alarmTypeList: IOptionalCheckAlarm[];
10
- }
11
- export interface IOptionalCheckAlarm {
12
- title: string;
13
- checked: boolean;
14
- name: string;
15
- value: number;
16
- }
17
3
  type props = {
18
4
  layoutClassName?: string;
19
5
  setUser: (user: ILoginInfo) => void;
@@ -15,19 +15,63 @@ import { deleteToken, getToken } from '../_api/token';
15
15
  import { jwtDecode } from 'jwt-decode';
16
16
  import { sendNumber } from '../_api/sendNumber';
17
17
  import { confirmNumber } from '../_api/confirmNumber';
18
- import { optionalTermAgree } from '../_api/optionalTermAgree';
19
18
  import { completeUserSign } from '../_api/completeUser';
20
19
  import PageWrapper from '../../../Layout/PageWrapper';
21
20
  import LoginBreadCrumb from './LoginBreadCrumb';
22
21
  import ConfirmModal from './Modal/ConfirmModal';
23
22
  import TermModal from './Modal/TermModal';
24
- import OptionalCheckBox from './Sign/OptionalCheckBox';
25
23
  import RequiredCheckBox from './Sign/RequiredCheckBox';
26
24
  import LButton from './LButton';
27
25
  import LInput from './Linput';
28
26
  import Image from 'next/image';
27
+ import { useQuery } from '@tanstack/react-query';
28
+ import Loader from '../../../Loader/Loader';
29
29
  const SignContainer = ({ layoutClassName = `mt-[47px] py-[128px] max-lg:mt-[40px] max-lg:py-[112px] max-sm:mt-[28px] max-sm:py-[100px]`, setUser }) => {
30
30
  const session_key = process.env.NEXT_PUBLIC_USER_SESSION_STORAGE_KEY || 'loginUser';
31
+ const [termCode, setTermCode] = useState('');
32
+ const [requiredTermItems, setRequiredTermItems] = useState([
33
+ { title: '전체 동의', name: 'all', checked: false, isContent: false, isAll: true, termCode: '' },
34
+ { title: '만 14세 이상 동의 (필수)', name: 'required', checked: false, isContent: false, termCode: '' },
35
+ { title: '서비스 이용약관 동의 (필수)', name: 'required', checked: false, isContent: true, termCode: '' },
36
+ { title: '개인정보 수집·이용 동의 (필수)', name: 'required', checked: false, isContent: true, termCode: '' },
37
+ { title: '개인정보 제3자 제공 동의 (필수)', name: 'required', checked: false, isContent: true, termCode: '' }
38
+ ]);
39
+ const { data: termList, status: termListStatus } = useQuery({
40
+ queryKey: ['term', 'list'],
41
+ queryFn: () => {
42
+ return fetch(`${process.env.NEXT_PUBLIC_SERVICE_DOMAIN}/api/terms/latest`, {
43
+ method: 'GET'
44
+ })
45
+ .then(obj => obj.json())
46
+ .then(obj => obj.list);
47
+ }
48
+ });
49
+ const { data: termObj, status: termObjStatus } = useQuery({
50
+ queryKey: ['term', termCode],
51
+ queryFn: () => {
52
+ return fetch(`${process.env.NEXT_PUBLIC_SERVICE_DOMAIN}/api/terms/latest/${termCode}`, {
53
+ method: 'GET'
54
+ })
55
+ .then(obj => obj.json())
56
+ .then(obj => obj.data);
57
+ },
58
+ enabled: !!termCode
59
+ });
60
+ useEffect(() => {
61
+ var _a;
62
+ if (termListStatus === 'success' && Array.isArray(termList)) {
63
+ setRequiredTermItems([
64
+ { title: '전체 동의', name: 'all', checked: false, isContent: false, isAll: true, termCode: '' },
65
+ ...((_a = termList === null || termList === void 0 ? void 0 : termList.map(item => ({
66
+ title: `${item.code_name} (필수)`,
67
+ name: 'required',
68
+ checked: false,
69
+ isContent: !!item.contents,
70
+ termCode: item.terms_code || ''
71
+ }))) !== null && _a !== void 0 ? _a : [])
72
+ ]);
73
+ }
74
+ }, [termList, termListStatus]);
31
75
  const router = useRouter();
32
76
  const imagePath = process.env.NEXT_PUBLIC_S3_URL + '';
33
77
  // 쿠키
@@ -36,41 +80,6 @@ const SignContainer = ({ layoutClassName = `mt-[47px] py-[128px] max-lg:mt-[40px
36
80
  provider: ''
37
81
  });
38
82
  const redirect = decodeURIComponent(getCookie('redirect')) || '/';
39
- const [requiredTermItems, setRequiredTermItems] = useState([
40
- { title: '전체 동의', name: 'all', checked: false, isContent: false, isAll: true },
41
- { title: '만 14세 이상 동의 (필수)', name: 'required', checked: false, isContent: false },
42
- { title: '서비스 이용약관 동의 (필수)', name: 'required', checked: false, isContent: true },
43
- { title: '개인정보 수집·이용 동의 (필수)', name: 'required', checked: false, isContent: true },
44
- { title: '개인정보 제3자 제공 동의 (필수)', name: 'required', checked: false, isContent: true }
45
- ]);
46
- const [optionalTermItems, setOptionalTermItems] = useState([
47
- {
48
- title: '사건관련 알림 수신 동의 (선택)',
49
- checked: false,
50
- isContent: true,
51
- cautionTitle: '*사건관련 알림을 수신할 채널을 선택해 주세요.',
52
- name: 'optionalMain',
53
- alarmTypeList: [
54
- { title: '푸시알림', name: 'optionalSelect', checked: false, value: 1 },
55
- { title: '카카오알림톡', name: 'optionalSelect', checked: false, value: 2 },
56
- { title: 'SMS', name: 'optionalSelect', checked: false, value: 4 },
57
- { title: '이메일', name: 'optionalSelect', checked: false, value: 8 }
58
- ]
59
- },
60
- {
61
- title: '마케팅 정보 수신 동의 (선택)',
62
- checked: false,
63
- isContent: true,
64
- cautionTitle: '*마케팅 정보를 수신할 채널을 선택해 주세요.',
65
- name: 'optionalMain',
66
- alarmTypeList: [
67
- { title: '푸시알림', name: 'optionalSelect', checked: false, value: 1 },
68
- { title: '카카오알림톡', name: 'optionalSelect', checked: false, value: 2 },
69
- { title: 'SMS', name: 'optionalSelect', checked: false, value: 4 },
70
- { title: '이메일', name: 'optionalSelect', checked: false, value: 8 }
71
- ]
72
- }
73
- ]);
74
83
  // 회원가입 미완료 시 쿠키 삭제
75
84
  useEffect(() => {
76
85
  const handleUnload = () => __awaiter(void 0, void 0, void 0, function* () {
@@ -224,18 +233,11 @@ const SignContainer = ({ layoutClassName = `mt-[47px] py-[128px] max-lg:mt-[40px
224
233
  const parentIdx = Number(dataset.parentidx);
225
234
  const index = Number(dataset.idx);
226
235
  const newRequiredTermItems = [...requiredTermItems];
227
- const newOptionalTermItems = [...optionalTermItems];
228
236
  if (name === 'all') {
229
237
  const reverseState = !newRequiredTermItems[index].checked;
230
238
  newRequiredTermItems.forEach(item => {
231
239
  item.checked = reverseState;
232
240
  });
233
- newOptionalTermItems.forEach(item => {
234
- item.checked = reverseState;
235
- item.alarmTypeList.forEach(alarmItem => {
236
- alarmItem.checked = reverseState;
237
- });
238
- });
239
241
  }
240
242
  else if (name === 'required') {
241
243
  // 기본 체크
@@ -244,29 +246,7 @@ const SignContainer = ({ layoutClassName = `mt-[47px] py-[128px] max-lg:mt-[40px
244
246
  newRequiredTermItems[0].checked = check;
245
247
  // 전부 올 체크인지
246
248
  }
247
- else if (name === 'optionalMain') {
248
- const checkedValue = !newOptionalTermItems[index].checked;
249
- newOptionalTermItems[index].checked = checkedValue;
250
- newOptionalTermItems[index].alarmTypeList.forEach(item => {
251
- item.checked = checkedValue;
252
- });
253
- const check = newOptionalTermItems.every(item => item.checked) &&
254
- newRequiredTermItems.slice(1).every(item => item.checked);
255
- newRequiredTermItems[0].checked = check;
256
- }
257
- else if (name === 'optionalSelect') {
258
- // 선택된 체크
259
- newOptionalTermItems[parentIdx].alarmTypeList[index].checked =
260
- !newOptionalTermItems[parentIdx].alarmTypeList[index].checked;
261
- // 전부 체크인지 확인
262
- newOptionalTermItems[parentIdx].checked = newOptionalTermItems[parentIdx].alarmTypeList.some(item => item.checked);
263
- // 이제 전체동의 여부 확인
264
- const check = newOptionalTermItems.every(item => item.checked) &&
265
- newRequiredTermItems.slice(1).every(item => item.checked);
266
- newRequiredTermItems[0].checked = check;
267
- }
268
249
  setRequiredTermItems(newRequiredTermItems);
269
- setOptionalTermItems(newOptionalTermItems);
270
250
  };
271
251
  const timeChange = useCallback(() => {
272
252
  setTimeLeft(210); // 초기화
@@ -349,7 +329,7 @@ const SignContainer = ({ layoutClassName = `mt-[47px] py-[128px] max-lg:mt-[40px
349
329
  setIsModal(true);
350
330
  }
351
331
  });
352
- const completeUser = (_a) => __awaiter(void 0, [_a], void 0, function* ({ completeBodyData, termBodyData }) {
332
+ const completeUser = (_a) => __awaiter(void 0, [_a], void 0, function* ({ completeBodyData }) {
353
333
  // 이름 설정
354
334
  if (!userValidObj.nameValid) {
355
335
  const { title, subTitle, key } = modalValueSet[modalValueSetKey.nameError];
@@ -371,14 +351,6 @@ const SignContainer = ({ layoutClassName = `mt-[47px] py-[128px] max-lg:mt-[40px
371
351
  setIsModal(true);
372
352
  return;
373
353
  }
374
- // 약관 저장
375
- const termResult = yield optionalTermAgree({
376
- bodyData: termBodyData
377
- });
378
- if (!termResult.result) {
379
- // alert('회원가입 실패');
380
- return;
381
- }
382
354
  // 회원가입 완료
383
355
  const result = yield completeUserSign({
384
356
  bodyData: completeBodyData
@@ -402,6 +374,9 @@ const SignContainer = ({ layoutClassName = `mt-[47px] py-[128px] max-lg:mt-[40px
402
374
  setIsModal(false);
403
375
  setModalObj({ title: '', subTitle: '', key: '' });
404
376
  };
377
+ if (termListStatus !== 'success' || (termCode && termObjStatus !== 'success')) {
378
+ return <Loader fullScreen/>;
379
+ }
405
380
  return (<Suspense>
406
381
  <section className={layoutClassName}>
407
382
  <PageWrapper>
@@ -569,19 +544,11 @@ const SignContainer = ({ layoutClassName = `mt-[47px] py-[128px] max-lg:mt-[40px
569
544
  var _a;
570
545
  return (<RequiredCheckBox isAll={(_a = item.isAll) !== null && _a !== void 0 ? _a : false} checked={item.checked} index={index} name={item.name} key={index} title={item.title} isContent={item.isContent} setModal={() => {
571
546
  setIsTermModal(true);
547
+ setTermCode(item.termCode);
572
548
  }} handleButton={handleCheckBox}/>);
573
549
  })}
574
550
  </div>
575
551
  </div>
576
- <div className={' mt-[37px] flex flex-col gap-[40px] ' +
577
- ' max-lg:mt-[32px] max-lg:gap-[32px] ' +
578
- ' max-sm:mt-[30px] max-sm:gap-[30px] '}>
579
- {optionalTermItems.map((item, index) => {
580
- return (<OptionalCheckBox key={`option-${index}`} name={item.name} checked={item.checked} title={item.title} isContent={true} setModal={() => {
581
- setIsTermModal(true);
582
- }} cautionTitle={item.cautionTitle} parentIndex={index} optionalItemList={item.alarmTypeList} handleButton={handleCheckBox}/>);
583
- })}
584
- </div>
585
552
  <div className={' mt-[80px] flex items-center justify-center ' +
586
553
  ' max-lg:mt-[72px] ' +
587
554
  ' max-sm:mt-[40px] '}>
@@ -591,14 +558,6 @@ const SignContainer = ({ layoutClassName = `mt-[47px] py-[128px] max-lg:mt-[40px
591
558
  name: userObj.name,
592
559
  phoneNumber: formatPhoneNumber(userObj.phoneNumber) || '',
593
560
  uuid: userObj.uuid
594
- },
595
- termBodyData: {
596
- alert_agree: optionalTermItems[0].alarmTypeList
597
- .filter(item => item.checked)
598
- .reduce((sum, item) => sum + item.value, 0), // checked된 항목들의 value 합산
599
- marketing_agree: optionalTermItems[1].alarmTypeList
600
- .filter(item => item.checked)
601
- .reduce((sum, item) => sum + item.value, 0) // 마케팅 관련 동의 값 합산
602
561
  }
603
562
  });
604
563
  })} className={` ${checkAll ? ' bg-[#AE0E36] text-white ' : ' bg-[#EDEDED] text-[#909090] '} ` +
@@ -612,8 +571,9 @@ const SignContainer = ({ layoutClassName = `mt-[47px] py-[128px] max-lg:mt-[40px
612
571
  </PageWrapper>
613
572
  <ConfirmModal isOpen={isModal} handleClick={modalHandleClose} onClose={modalHandleClose} title={modalObj.title} subTitle={modalObj.subTitle}/>
614
573
  <TermModal isOpen={isTermModal} onClose={() => {
574
+ setTermCode('');
615
575
  setIsTermModal(false);
616
- }} title={'서비스 이용약관 (필수)'} content={''}/>
576
+ }} title={(termObj && `${termObj.code_name} (필수)`) || ''} content={(termObj && termObj.contents) || ''}/>
617
577
  </section>
618
578
  </Suspense>);
619
579
  };