diff --git a/src/entities/alarm/ui/alarm-item.tsx b/src/entities/alarm/ui/alarm-item.tsx index 66235b4..f572abb 100644 --- a/src/entities/alarm/ui/alarm-item.tsx +++ b/src/entities/alarm/ui/alarm-item.tsx @@ -2,6 +2,9 @@ import { PATHS } from '@/shared/constants/paths'; import { IMAGE_ROOT } from '@/shared/constants/common'; import { useNavigate } from '@/shared/lib/hooks/use-navigate'; import moment from 'moment'; +import { useAppAlarmMarkMutation } from '../api/use-app-alarm-mark-mutation'; +import { AppAlarmMarkParams, AppAlarmMarkResponse } from '../model/types'; +import { useStore } from '@/shared/model/store'; export interface AlarmItemProps { appNotificationSequence?: number; @@ -22,9 +25,52 @@ export const AlarmItem = ({ }: AlarmItemProps) => { const { navigate } = useNavigate(); + let userInfo = useStore.getState().UserStore.userInfo; + const {mutateAsync: appAlarmMark} = useAppAlarmMarkMutation(); + const onClickToNavigate = () => { let path = PATHS.support.notice.detail + appNotificationSequence; - // navigate(path); + let pathState = {}; + + console.log('appNotificationSequence : [' + appNotificationSequence + ']'); + console.log('appNotificationCategory : [' + appNotificationCategory + ']'); + console.log('notificationReceivedDate : [' + notificationReceivedDate + ']'); + console.log('appNotificationTitle : [' + appNotificationTitle + ']'); + console.log('appNotificationContent : [' + appNotificationContent + ']'); + console.log('appNotificationLink : [' + appNotificationLink + ']'); + + if(appNotificationCategory === '10'){ + + } + else if(appNotificationCategory === '20'){ + + } + else if(appNotificationCategory === '30'){ + + } + else if(appNotificationCategory === '40'){ + + } + else if(appNotificationCategory === '60'){ + + } + navigate(path, { + state: pathState + }); + }; + + const callAppAlarmMark = () => { + if(!!userInfo.usrid && !!appNotificationSequence){ + let params: AppAlarmMarkParams = { + appNotificationSequence: appNotificationSequence, + usrid: userInfo.usrid + }; + appAlarmMark(params).then((rs: AppAlarmMarkResponse) => { + console.log(rs); + }).finally(() => { + onClickToNavigate(); + }); + } }; return ( @@ -38,7 +84,7 @@ export const AlarmItem = ({
onClickToNavigate() } + onClick={ () => callAppAlarmMark() } > { getAlarmItems() }
+
※ 알림은 90일간 보관 후 삭제됩니다.
); diff --git a/src/pages/setting/setting-page.tsx b/src/pages/setting/setting-page.tsx index c6060c4..bca0fe5 100644 --- a/src/pages/setting/setting-page.tsx +++ b/src/pages/setting/setting-page.tsx @@ -1,18 +1,92 @@ +import { useAppAlarmConsentMutation } from '@/entities/alarm/api/use-app-alarm-consent-mutation'; +import { useAppAlarmFindMutation } from '@/entities/alarm/api/use-app-alarm-find-mutation'; +import { AppAlarmConsentParams, AppAlarmConsentResponse, AppAlarmFindParams, AppAlarmFindResponse, MERCHANT_ADMIN_APP } from '@/entities/alarm/model/types'; import { HeaderType } from '@/entities/common/model/types'; +import { useStore } from '@/shared/model/store'; import { useSetHeaderTitle, useSetHeaderType, useSetFooterMode } from '@/widgets/sub-layout/use-sub-layout'; +import { ChangeEvent, useEffect, useState } from 'react'; export const SettingPage = () => { + let userInfo = useStore.getState().UserStore.userInfo; useSetHeaderTitle('설정'); useSetHeaderType(HeaderType.LeftArrow); useSetFooterMode(false); + const {mutateAsync: appAlarmFind} = useAppAlarmFindMutation(); + const {mutateAsync: appAlarmConsent} = useAppAlarmConsentMutation(); + + const [alarmSetting, setAlarmSetting] = useState>({ + '21': false, + '11': false, + '31': false, + '41': false, + '61': false, + '62': false, + '15': false + }); + + const onClickPrivacyPolicy = () => { window.open('https://www.nicevan.co.kr/privacy-policy', '_blank'); }; + + const callAppAlarmFind = () => { + if(userInfo.usrid){ + let params: AppAlarmFindParams = { + usrid: userInfo.usrid, + appCl: MERCHANT_ADMIN_APP.MERCHANT_ADMIN_APP + }; + appAlarmFind(params).then((rs: AppAlarmFindResponse) => { + responseAlarmSetting(rs); + }); + } + }; + + const responseAlarmSetting = (data: AppAlarmFindResponse) => { + let responseAlarms: Record = {}; + for(let i=0;i { + if(userInfo.usrid){ + let params: AppAlarmConsentParams = { + usrid: userInfo.usrid, + appCl: MERCHANT_ADMIN_APP.MERCHANT_ADMIN_APP, + appNotificationSubCategory: alarmCode, + appNotificationAllowed: value + }; + appAlarmConsent(params).then((rs: AppAlarmConsentResponse) => { + setAlarmSetting({ + ...alarmSetting, + ...{ ['' + alarmCode]: value } + }); + }).catch((e: any) => { + setAlarmSetting({ + ...alarmSetting, + ...{ ['' + alarmCode]: !value } + }); + }); + } + }; + + useEffect(() => { + callAppAlarmFind(); + }, []); return ( <> @@ -33,28 +107,44 @@ export const SettingPage = () => {
서비스 운영 및 장애
무이자 혜택 및 이벤트
서비스 이용 및 정책 변경
NICE소식 및 기타 정보
@@ -65,14 +155,22 @@ export const SettingPage = () => {
정산처리 현황
정산한도 알림
@@ -84,7 +182,11 @@ export const SettingPage = () => {
마케팅 정보 수신 동의