@daeryun/dr_components 0.4.2 → 0.4.4

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.
@@ -27,7 +27,10 @@ import LInput from './LoginComp/Linput';
27
27
  import LButton from './LoginComp/LButton';
28
28
  import TermModal from './LoginComp/Modal/TermModal';
29
29
  import ConfirmModal from './LoginComp/Modal/ConfirmModal';
30
+ import MyPageOptionalCheckBox from './LoginComp/Update/MyPageOptionalCheckBox';
31
+ import { optionalTermAgree } from './_api/optionalTermAgree';
30
32
  const Personal = ({ layoutClassName = ` mt-[47px] py-[128px] max-lg:mt-[40px] max-lg:py-[112px] max-sm:mt-[28px] max-sm:py-[100px] `, resetUser }) => {
33
+ var _a, _b;
31
34
  const router = useRouter();
32
35
  const imagePath = process.env.NEXT_PUBLIC_S3_URL + '';
33
36
  const { data: userData, status: userDataStatus } = useQuery({
@@ -39,6 +42,14 @@ const Personal = ({ layoutClassName = ` mt-[47px] py-[128px] max-lg:mt-[40px] m
39
42
  },
40
43
  staleTime: 1000 * 60 * 5
41
44
  });
45
+ const { data: userAgree, status: userAgreeStatus } = useQuery({
46
+ queryKey: ['user', 'agree'],
47
+ queryFn: () => {
48
+ return Fetch(`/api/lawfirm/app/user/agree`, {
49
+ method: 'GET'
50
+ });
51
+ }
52
+ });
42
53
  const [userObj, setUserObj] = useState({
43
54
  name: '',
44
55
  phoneNumber: '',
@@ -60,6 +71,34 @@ const Personal = ({ layoutClassName = ` mt-[47px] py-[128px] max-lg:mt-[40px] m
60
71
  subTitle: '',
61
72
  key: ''
62
73
  });
74
+ const [optionalTermItems, setOptionalTermItems] = useState([
75
+ {
76
+ title: '사건관련 알림 수신 동의 (선택)',
77
+ checked: false,
78
+ isContent: true,
79
+ cautionTitle: '*사건관련 알림을 수신할 채널을 선택해 주세요.',
80
+ name: 'optionalMain',
81
+ alarmTypeList: [
82
+ { title: '푸시알림', name: 'optionalSelect', checked: false, value: 1 },
83
+ { title: '카카오알림톡', name: 'optionalSelect', checked: false, value: 2 },
84
+ { title: 'SMS', name: 'optionalSelect', checked: false, value: 4 },
85
+ { title: '이메일', name: 'optionalSelect', checked: false, value: 8 }
86
+ ]
87
+ },
88
+ {
89
+ title: '마케팅 정보 수신 동의 (선택)',
90
+ checked: false,
91
+ isContent: true,
92
+ cautionTitle: '*마케팅 정보를 수신할 채널을 선택해 주세요.',
93
+ name: 'optionalMain',
94
+ alarmTypeList: [
95
+ { title: '푸시알림', name: 'optionalSelect', checked: false, value: 1 },
96
+ { title: '카카오알림톡', name: 'optionalSelect', checked: false, value: 2 },
97
+ { title: 'SMS', name: 'optionalSelect', checked: false, value: 4 },
98
+ { title: '이메일', name: 'optionalSelect', checked: false, value: 8 }
99
+ ]
100
+ }
101
+ ]);
63
102
  const modalValueSetKey = {
64
103
  nameError: 'nameError',
65
104
  phoneNumberError: 'phoneNumberError',
@@ -119,7 +158,22 @@ const Personal = ({ layoutClassName = ` mt-[47px] py-[128px] max-lg:mt-[40px] m
119
158
  codeValid: false
120
159
  });
121
160
  // 이름이 바꼈거나 , 휴대전화 인증을 다시 완료했거나 , 약관 총합 값이 바꼈거나
122
- const isAll = ((userData === null || userData === void 0 ? void 0 : userData.data.name) !== (userObj === null || userObj === void 0 ? void 0 : userObj.name) && (userValidObj === null || userValidObj === void 0 ? void 0 : userValidObj.nameValid)) || userValidObj.codeValid;
161
+ const isAll = ((userData === null || userData === void 0 ? void 0 : userData.data.name) !== (userObj === null || userObj === void 0 ? void 0 : userObj.name) && (userValidObj === null || userValidObj === void 0 ? void 0 : userValidObj.nameValid)) ||
162
+ userValidObj.codeValid ||
163
+ ((_a = userAgree === null || userAgree === void 0 ? void 0 : userAgree.data) === null || _a === void 0 ? void 0 : _a.alert_agree) !==
164
+ optionalTermItems[0].alarmTypeList
165
+ .filter(item => item.checked)
166
+ .reduce((sum, item) => sum + item.value, 0) ||
167
+ ((_b = userAgree === null || userAgree === void 0 ? void 0 : userAgree.data) === null || _b === void 0 ? void 0 : _b.marketing_agree) !==
168
+ optionalTermItems[1].alarmTypeList.filter(item => item.checked).reduce((sum, item) => sum + item.value, 0);
169
+ const updateOptionalTermItems = (alertAgree, marketingAgree) => {
170
+ setOptionalTermItems(prevItems => prevItems.map((item, index) => {
171
+ // alertAgree는 첫 번째 항목, marketingAgree는 두 번째 항목을 업데이트
172
+ const agreeValue = index === 0 ? alertAgree : marketingAgree;
173
+ //15면 체크
174
+ return Object.assign(Object.assign({}, item), { checked: index === 0 ? alertAgree === 15 : marketingAgree === 15, alarmTypeList: item.alarmTypeList.map(alarm => (Object.assign(Object.assign({}, alarm), { checked: (agreeValue & alarm.value) !== 0 }))) });
175
+ }));
176
+ };
123
177
  useEffect(() => {
124
178
  return () => {
125
179
  if (timerRef.current) {
@@ -127,6 +181,11 @@ const Personal = ({ layoutClassName = ` mt-[47px] py-[128px] max-lg:mt-[40px] m
127
181
  }
128
182
  };
129
183
  }, []);
184
+ useEffect(() => {
185
+ if (userAgree) {
186
+ updateOptionalTermItems(userAgree.data.alert_agree, userAgree.data.marketing_agree);
187
+ }
188
+ }, [userAgree]);
130
189
  useEffect(() => {
131
190
  if (userData) {
132
191
  setUserObj(prev => (Object.assign(Object.assign({}, prev), { email: userData.data.email, name: userData.data.name, provider: userData.data.provider, phoneNumber: onlyNumberFilter(userData.data.phone_number) })));
@@ -148,6 +207,32 @@ const Personal = ({ layoutClassName = ` mt-[47px] py-[128px] max-lg:mt-[40px] m
148
207
  });
149
208
  }, 1000);
150
209
  }, []);
210
+ const handleCheckBox = (e) => {
211
+ const { name, dataset } = e.currentTarget;
212
+ const parentIdx = Number(dataset.parentidx);
213
+ const index = Number(dataset.idx);
214
+ const newOptionalTermItems = [...optionalTermItems];
215
+ if (name === 'all') {
216
+ newOptionalTermItems[index].checked = true;
217
+ newOptionalTermItems[index].alarmTypeList.forEach(item => {
218
+ item.checked = true;
219
+ });
220
+ }
221
+ else if (name === 'notall') {
222
+ newOptionalTermItems[index].checked = false;
223
+ newOptionalTermItems[index].alarmTypeList.forEach(item => {
224
+ item.checked = false;
225
+ });
226
+ }
227
+ else if (name === 'optionalSelect') {
228
+ // 선택된 체크
229
+ newOptionalTermItems[parentIdx].alarmTypeList[index].checked =
230
+ !newOptionalTermItems[parentIdx].alarmTypeList[index].checked;
231
+ // 전부 체크인지 확인
232
+ newOptionalTermItems[parentIdx].checked = newOptionalTermItems[parentIdx].alarmTypeList.some(item => item.checked);
233
+ }
234
+ setOptionalTermItems(newOptionalTermItems);
235
+ };
151
236
  const handleInput = (e) => {
152
237
  const { name, value } = e.currentTarget;
153
238
  const newUserObj = Object.assign({}, userObj);
@@ -257,6 +342,14 @@ const Personal = ({ layoutClassName = ` mt-[47px] py-[128px] max-lg:mt-[40px] m
257
342
  }
258
343
  const nameCheck = userData.data.name !== userObj.name && userValidObj.nameValid;
259
344
  const phoneCheck = userValidObj.codeValid;
345
+ const termCheck = userAgree.data.alert_agree !==
346
+ optionalTermItems[0].alarmTypeList
347
+ .filter(item => item.checked)
348
+ .reduce((sum, item) => sum + item.value, 0) ||
349
+ userAgree.data.marketing_agree !==
350
+ optionalTermItems[1].alarmTypeList
351
+ .filter(item => item.checked)
352
+ .reduce((sum, item) => sum + item.value, 0);
260
353
  let result = true;
261
354
  if (nameCheck || phoneCheck) {
262
355
  result = yield updateUserInfo({
@@ -264,6 +357,18 @@ const Personal = ({ layoutClassName = ` mt-[47px] py-[128px] max-lg:mt-[40px] m
264
357
  )
265
358
  }).then(obj => obj.result);
266
359
  }
360
+ if (termCheck) {
361
+ result = yield optionalTermAgree({
362
+ bodyData: {
363
+ alert_agree: optionalTermItems[0].alarmTypeList
364
+ .filter(item => item.checked)
365
+ .reduce((sum, item) => sum + item.value, 0), // checked된 항목들의 value 합산
366
+ marketing_agree: optionalTermItems[1].alarmTypeList
367
+ .filter(item => item.checked)
368
+ .reduce((sum, item) => sum + item.value, 0) // 마케팅 관련 동의 값 합산
369
+ }
370
+ }).then(obj => obj.result);
371
+ }
267
372
  if (result) {
268
373
  setIsModalUpdate(false);
269
374
  const queryClient = new QueryClient();
@@ -275,7 +380,7 @@ const Personal = ({ layoutClassName = ` mt-[47px] py-[128px] max-lg:mt-[40px] m
275
380
  return;
276
381
  }
277
382
  });
278
- if (userDataStatus !== 'success') {
383
+ if (userDataStatus !== 'success' || userAgreeStatus !== 'success') {
279
384
  return <Loader fullScreen/>;
280
385
  }
281
386
  return (<section className={layoutClassName}>
@@ -434,6 +539,21 @@ const Personal = ({ layoutClassName = ` mt-[47px] py-[128px] max-lg:mt-[40px] m
434
539
  </div>)}
435
540
  </div>
436
541
  </div>
542
+
543
+ <div className={' mt-[80px] ' + ' max-lg:mt-[60px] ' + ' max-sm:mt-[60px] '}>
544
+ <div className={' body_large1 text-[#000000] ' + ' max-lg:body_large1_tb ' + ' max-sm:body_large1_mo '}>
545
+ 정보 수신 동의
546
+ </div>
547
+ <div className={' mt-[52px] flex flex-col gap-[59px] ' +
548
+ ' max-lg:mt-[40px] max-lg:gap-[50px] ' +
549
+ ' max-sm:mt-[32px] max-sm:gap-[40px] '}>
550
+ {optionalTermItems.map((item, index) => {
551
+ return (<MyPageOptionalCheckBox key={`option-${index}`} name={item.name} checked={item.checked} title={item.title} isContent={true} setModal={() => {
552
+ setIsTermModal(true);
553
+ }} cautionTitle={item.cautionTitle} parentIndex={index} optionalItemList={item.alarmTypeList} handleButton={handleCheckBox}/>);
554
+ })}
555
+ </div>
556
+ </div>
437
557
  <div className={'mt-[80px] flex items-center justify-center' + ' max-lg:mt-[78px] ' + ' max-sm:mt-[40px] '}>
438
558
  <button type={'button'} onClick={isAll
439
559
  ? () => {
@@ -18,6 +18,8 @@ import LInput from './LoginComp/Linput';
18
18
  import LButton from './LoginComp/LButton';
19
19
  import TermModal from './LoginComp/Modal/TermModal';
20
20
  import ConfirmModal from './LoginComp/Modal/ConfirmModal';
21
+ import MyPageOptionalCheckBox from './LoginComp/Update/MyPageOptionalCheckBox';
22
+ import { optionalTermAgree } from './_api/optionalTermAgree';
21
23
 
22
24
  interface IUser {
23
25
  name: string;
@@ -35,6 +37,22 @@ interface IUserValid {
35
37
  codeValid: boolean; // 인증번호 확인완료여부
36
38
  }
37
39
 
40
+ interface IOptionalCheckItem {
41
+ title: string;
42
+ checked: boolean;
43
+ name: string;
44
+ isContent: boolean;
45
+ cautionTitle: string;
46
+ alarmTypeList: IOptionalCheckAlarm[];
47
+ }
48
+
49
+ export interface IOptionalCheckAlarm {
50
+ title: string;
51
+ checked: boolean;
52
+ name: string;
53
+ value: number;
54
+ }
55
+
38
56
  type props = {
39
57
  layoutClassName?: string;
40
58
  resetUser?: () => void;
@@ -55,6 +73,14 @@ const Personal = ({
55
73
  },
56
74
  staleTime: 1000 * 60 * 5
57
75
  });
76
+ const { data: userAgree, status: userAgreeStatus } = useQuery({
77
+ queryKey: ['user', 'agree'],
78
+ queryFn: () => {
79
+ return Fetch(`/api/lawfirm/app/user/agree`, {
80
+ method: 'GET'
81
+ });
82
+ }
83
+ });
58
84
 
59
85
  const [userObj, setUserObj] = useState<IUser>({
60
86
  name: '',
@@ -81,6 +107,34 @@ const Personal = ({
81
107
  subTitle: '',
82
108
  key: ''
83
109
  });
110
+ const [optionalTermItems, setOptionalTermItems] = useState<IOptionalCheckItem[]>([
111
+ {
112
+ title: '사건관련 알림 수신 동의 (선택)',
113
+ checked: false,
114
+ isContent: true,
115
+ cautionTitle: '*사건관련 알림을 수신할 채널을 선택해 주세요.',
116
+ name: 'optionalMain',
117
+ alarmTypeList: [
118
+ { title: '푸시알림', name: 'optionalSelect', checked: false, value: 1 },
119
+ { title: '카카오알림톡', name: 'optionalSelect', checked: false, value: 2 },
120
+ { title: 'SMS', name: 'optionalSelect', checked: false, value: 4 },
121
+ { title: '이메일', name: 'optionalSelect', checked: false, value: 8 }
122
+ ]
123
+ },
124
+ {
125
+ title: '마케팅 정보 수신 동의 (선택)',
126
+ checked: false,
127
+ isContent: true,
128
+ cautionTitle: '*마케팅 정보를 수신할 채널을 선택해 주세요.',
129
+ name: 'optionalMain',
130
+ alarmTypeList: [
131
+ { title: '푸시알림', name: 'optionalSelect', checked: false, value: 1 },
132
+ { title: '카카오알림톡', name: 'optionalSelect', checked: false, value: 2 },
133
+ { title: 'SMS', name: 'optionalSelect', checked: false, value: 4 },
134
+ { title: '이메일', name: 'optionalSelect', checked: false, value: 8 }
135
+ ]
136
+ }
137
+ ]);
84
138
 
85
139
  const modalValueSetKey: {
86
140
  nameError: 'nameError';
@@ -152,7 +206,33 @@ const Personal = ({
152
206
  });
153
207
 
154
208
  // 이름이 바꼈거나 , 휴대전화 인증을 다시 완료했거나 , 약관 총합 값이 바꼈거나
155
- const isAll = (userData?.data.name !== userObj?.name && userValidObj?.nameValid) || userValidObj.codeValid;
209
+ const isAll =
210
+ (userData?.data.name !== userObj?.name && userValidObj?.nameValid) ||
211
+ userValidObj.codeValid ||
212
+ userAgree?.data?.alert_agree !==
213
+ optionalTermItems[0].alarmTypeList
214
+ .filter(item => item.checked)
215
+ .reduce((sum, item) => sum + item.value, 0) ||
216
+ userAgree?.data?.marketing_agree !==
217
+ optionalTermItems[1].alarmTypeList.filter(item => item.checked).reduce((sum, item) => sum + item.value, 0);
218
+ const updateOptionalTermItems = (alertAgree: number, marketingAgree: number) => {
219
+ setOptionalTermItems(prevItems =>
220
+ prevItems.map((item, index) => {
221
+ // alertAgree는 첫 번째 항목, marketingAgree는 두 번째 항목을 업데이트
222
+ const agreeValue = index === 0 ? alertAgree : marketingAgree;
223
+ //15면 체크
224
+
225
+ return {
226
+ ...item,
227
+ checked: index === 0 ? alertAgree === 15 : marketingAgree === 15,
228
+ alarmTypeList: item.alarmTypeList.map(alarm => ({
229
+ ...alarm,
230
+ checked: (agreeValue & alarm.value) !== 0
231
+ }))
232
+ };
233
+ })
234
+ );
235
+ };
156
236
 
157
237
  useEffect(() => {
158
238
  return () => {
@@ -161,6 +241,11 @@ const Personal = ({
161
241
  }
162
242
  };
163
243
  }, []);
244
+ useEffect(() => {
245
+ if (userAgree) {
246
+ updateOptionalTermItems(userAgree.data.alert_agree, userAgree.data.marketing_agree);
247
+ }
248
+ }, [userAgree]);
164
249
 
165
250
  useEffect(() => {
166
251
  if (userData) {
@@ -197,6 +282,34 @@ const Personal = ({
197
282
  }, 1000);
198
283
  }, []);
199
284
 
285
+ const handleCheckBox = (e: React.FormEvent<HTMLButtonElement>) => {
286
+ const { name, dataset } = e.currentTarget;
287
+ const parentIdx = Number(dataset.parentidx);
288
+ const index = Number(dataset.idx);
289
+
290
+ const newOptionalTermItems = [...optionalTermItems];
291
+ if (name === 'all') {
292
+ newOptionalTermItems[index].checked = true;
293
+ newOptionalTermItems[index].alarmTypeList.forEach(item => {
294
+ item.checked = true;
295
+ });
296
+ } else if (name === 'notall') {
297
+ newOptionalTermItems[index].checked = false;
298
+ newOptionalTermItems[index].alarmTypeList.forEach(item => {
299
+ item.checked = false;
300
+ });
301
+ } else if (name === 'optionalSelect') {
302
+ // 선택된 체크
303
+ newOptionalTermItems[parentIdx].alarmTypeList[index].checked =
304
+ !newOptionalTermItems[parentIdx].alarmTypeList[index].checked;
305
+ // 전부 체크인지 확인
306
+ newOptionalTermItems[parentIdx].checked = newOptionalTermItems[parentIdx].alarmTypeList.some(
307
+ item => item.checked
308
+ );
309
+ }
310
+ setOptionalTermItems(newOptionalTermItems);
311
+ };
312
+
200
313
  const handleInput = (e: FormEvent<HTMLInputElement>) => {
201
314
  const { name, value } = e.currentTarget;
202
315
  const newUserObj = { ...userObj };
@@ -314,6 +427,15 @@ const Personal = ({
314
427
 
315
428
  const nameCheck = userData.data.name !== userObj.name && userValidObj.nameValid;
316
429
  const phoneCheck = userValidObj.codeValid;
430
+ const termCheck =
431
+ userAgree.data.alert_agree !==
432
+ optionalTermItems[0].alarmTypeList
433
+ .filter(item => item.checked)
434
+ .reduce((sum, item) => sum + item.value, 0) ||
435
+ userAgree.data.marketing_agree !==
436
+ optionalTermItems[1].alarmTypeList
437
+ .filter(item => item.checked)
438
+ .reduce((sum, item) => sum + item.value, 0);
317
439
 
318
440
  let result = true;
319
441
  if (nameCheck || phoneCheck) {
@@ -324,6 +446,19 @@ const Personal = ({
324
446
  }
325
447
  }).then(obj => obj.result);
326
448
  }
449
+ if (termCheck) {
450
+ result = await optionalTermAgree({
451
+ bodyData: {
452
+ alert_agree: optionalTermItems[0].alarmTypeList
453
+ .filter(item => item.checked)
454
+ .reduce((sum, item) => sum + item.value, 0), // checked된 항목들의 value 합산
455
+
456
+ marketing_agree: optionalTermItems[1].alarmTypeList
457
+ .filter(item => item.checked)
458
+ .reduce((sum, item) => sum + item.value, 0) // 마케팅 관련 동의 값 합산
459
+ }
460
+ }).then(obj => obj.result);
461
+ }
327
462
  if (result) {
328
463
  setIsModalUpdate(false);
329
464
  const queryClient = new QueryClient();
@@ -335,7 +470,7 @@ const Personal = ({
335
470
  }
336
471
  };
337
472
 
338
- if (userDataStatus !== 'success') {
473
+ if (userDataStatus !== 'success' || userAgreeStatus !== 'success') {
339
474
  return <Loader fullScreen />;
340
475
  }
341
476
 
@@ -661,6 +796,42 @@ const Personal = ({
661
796
  )}
662
797
  </div>
663
798
  </div>
799
+
800
+ <div className={' mt-[80px] ' + ' max-lg:mt-[60px] ' + ' max-sm:mt-[60px] '}>
801
+ <div
802
+ className={
803
+ ' body_large1 text-[#000000] ' + ' max-lg:body_large1_tb ' + ' max-sm:body_large1_mo '
804
+ }
805
+ >
806
+ 정보 수신 동의
807
+ </div>
808
+ <div
809
+ className={
810
+ ' mt-[52px] flex flex-col gap-[59px] ' +
811
+ ' max-lg:mt-[40px] max-lg:gap-[50px] ' +
812
+ ' max-sm:mt-[32px] max-sm:gap-[40px] '
813
+ }
814
+ >
815
+ {optionalTermItems.map((item: IOptionalCheckItem, index: number) => {
816
+ return (
817
+ <MyPageOptionalCheckBox
818
+ key={`option-${index}`}
819
+ name={item.name}
820
+ checked={item.checked}
821
+ title={item.title}
822
+ isContent={true}
823
+ setModal={() => {
824
+ setIsTermModal(true);
825
+ }}
826
+ cautionTitle={item.cautionTitle}
827
+ parentIndex={index}
828
+ optionalItemList={item.alarmTypeList}
829
+ handleButton={handleCheckBox}
830
+ />
831
+ );
832
+ })}
833
+ </div>
834
+ </div>
664
835
  <div
665
836
  className={
666
837
  'mt-[80px] flex items-center justify-center' + ' max-lg:mt-[78px] ' + ' max-sm:mt-[40px] '
@@ -36,7 +36,6 @@ const ContactInfo = ({ id }) => {
36
36
  // };
37
37
  const [isOpen, setIsOpen] = useState(false);
38
38
  const { data: list, isLoading } = useActionGetContact(id);
39
- console.log('list@@ ', list);
40
39
  return (<CaseLayout isMobilePadding={false} outerClassName="mt-[35px] sm-top:mt-[24px] lg:mt-[40px] " innerClassName={'pt-[32px] px-[20px] pb-[40px] 2sm:px-[40px] sm-top:mt-[24px] sm-top:px-[50px] sm-top:pb-[60px] sm-top:pt-[56px] lg:pt-[60px] lg:pb-[80px] lg:px-[60px]'}>
41
40
  <div className="flex flex-row items-center justify-between">
42
41
  <div className="flex flex-row gap-[12px] sm-top:gap-[28px] lg:gap-[32px]">
@@ -45,7 +45,7 @@ const ContactInfo = ({ id }: { id: string }) => {
45
45
  // };
46
46
  const [isOpen, setIsOpen] = useState(false);
47
47
  const { data: list, isLoading } = useActionGetContact(id);
48
- console.log('list@@ ', list);
48
+
49
49
  return (
50
50
  <CaseLayout
51
51
  isMobilePadding={false}