This commit is contained in:
focp212@naver.com
2025-10-27 14:54:50 +09:00
parent 61d8d04174
commit 705383897c
3 changed files with 158 additions and 9 deletions

View File

@@ -2,6 +2,9 @@ import { PATHS } from '@/shared/constants/paths';
import { IMAGE_ROOT } from '@/shared/constants/common'; import { IMAGE_ROOT } from '@/shared/constants/common';
import { useNavigate } from '@/shared/lib/hooks/use-navigate'; import { useNavigate } from '@/shared/lib/hooks/use-navigate';
import moment from 'moment'; 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 { export interface AlarmItemProps {
appNotificationSequence?: number; appNotificationSequence?: number;
@@ -22,9 +25,52 @@ export const AlarmItem = ({
}: AlarmItemProps) => { }: AlarmItemProps) => {
const { navigate } = useNavigate(); const { navigate } = useNavigate();
let userInfo = useStore.getState().UserStore.userInfo;
const {mutateAsync: appAlarmMark} = useAppAlarmMarkMutation();
const onClickToNavigate = () => { const onClickToNavigate = () => {
let path = PATHS.support.notice.detail + appNotificationSequence; 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 ( return (
@@ -38,7 +84,7 @@ export const AlarmItem = ({
</div> </div>
<div <div
className="notice-arrow" className="notice-arrow"
onClick={ () => onClickToNavigate() } onClick={ () => callAppAlarmMark() }
> >
<img <img
src={ IMAGE_ROOT + '/Forward.svg' } src={ IMAGE_ROOT + '/Forward.svg' }

View File

@@ -123,6 +123,7 @@ export const AlarmList = ({
<div className="notice-box sub"> <div className="notice-box sub">
{ getAlarmItems() } { getAlarmItems() }
</div> </div>
<div ref={ setTarget }></div>
<div className="notice-alert"> 90 .</div> <div className="notice-alert"> 90 .</div>
</> </>
); );

View File

@@ -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 { HeaderType } from '@/entities/common/model/types';
import { useStore } from '@/shared/model/store';
import { import {
useSetHeaderTitle, useSetHeaderTitle,
useSetHeaderType, useSetHeaderType,
useSetFooterMode useSetFooterMode
} from '@/widgets/sub-layout/use-sub-layout'; } from '@/widgets/sub-layout/use-sub-layout';
import { ChangeEvent, useEffect, useState } from 'react';
export const SettingPage = () => { export const SettingPage = () => {
let userInfo = useStore.getState().UserStore.userInfo;
useSetHeaderTitle('설정'); useSetHeaderTitle('설정');
useSetHeaderType(HeaderType.LeftArrow); useSetHeaderType(HeaderType.LeftArrow);
useSetFooterMode(false); useSetFooterMode(false);
const {mutateAsync: appAlarmFind} = useAppAlarmFindMutation();
const {mutateAsync: appAlarmConsent} = useAppAlarmConsentMutation();
const [alarmSetting, setAlarmSetting] = useState<Record<string, boolean>>({
'21': false,
'11': false,
'31': false,
'41': false,
'61': false,
'62': false,
'15': false
});
const onClickPrivacyPolicy = () => { const onClickPrivacyPolicy = () => {
window.open('https://www.nicevan.co.kr/privacy-policy', '_blank'); 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<string, boolean> = {};
for(let i=0;i<data.alarmAgree.length;i++){
let item = data.alarmAgree[i];
if(item){
let appNotificationSubCategory = item.appNotificationSubCategory;
let appNotificationAllowed = item.appNotificationAllowed;
responseAlarms['' + appNotificationSubCategory] = appNotificationAllowed;
}
}
setAlarmSetting({
...alarmSetting,
...responseAlarms
});
};
const callAppAlarmConsent = (value: boolean, alarmCode: string) => {
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 ( return (
<> <>
@@ -33,28 +107,44 @@ export const SettingPage = () => {
<div className="settings-row"> <div className="settings-row">
<div className="settings-row-title"> </div> <div className="settings-row-title"> </div>
<label className="settings-switch"> <label className="settings-switch">
<input type="checkbox" /> <input
type="checkbox"
checked={ alarmSetting['21'] }
onChange={ (e: ChangeEvent<HTMLInputElement>) => callAppAlarmConsent(e.target.checked, '21') }
/>
<span className="slider"></span> <span className="slider"></span>
</label> </label>
</div> </div>
<div className="settings-row"> <div className="settings-row">
<div className="settings-row-title"> </div> <div className="settings-row-title"> </div>
<label className="settings-switch"> <label className="settings-switch">
<input type="checkbox" /> <input
type="checkbox"
checked={ alarmSetting['11'] }
onChange={ (e: ChangeEvent<HTMLInputElement>) => callAppAlarmConsent(e.target.checked, '11') }
/>
<span className="slider"></span> <span className="slider"></span>
</label> </label>
</div> </div>
<div className="settings-row"> <div className="settings-row">
<div className="settings-row-title"> </div> <div className="settings-row-title"> </div>
<label className="settings-switch"> <label className="settings-switch">
<input type="checkbox" /> <input
type="checkbox"
checked={ alarmSetting['31'] }
onChange={ (e: ChangeEvent<HTMLInputElement>) => callAppAlarmConsent(e.target.checked, '31') }
/>
<span className="slider"></span> <span className="slider"></span>
</label> </label>
</div> </div>
<div className="settings-row"> <div className="settings-row">
<div className="settings-row-title">NICE소식 </div> <div className="settings-row-title">NICE소식 </div>
<label className="settings-switch"> <label className="settings-switch">
<input type="checkbox" /> <input
type="checkbox"
checked={ alarmSetting['41'] }
onChange={ (e: ChangeEvent<HTMLInputElement>) => callAppAlarmConsent(e.target.checked, '41') }
/>
<span className="slider"></span> <span className="slider"></span>
</label> </label>
</div> </div>
@@ -65,14 +155,22 @@ export const SettingPage = () => {
<div className="settings-row"> <div className="settings-row">
<div className="settings-row-title"> </div> <div className="settings-row-title"> </div>
<label className="settings-switch"> <label className="settings-switch">
<input type="checkbox" /> <input
type="checkbox"
checked={ alarmSetting['61'] }
onChange={ (e: ChangeEvent<HTMLInputElement>) => callAppAlarmConsent(e.target.checked, '61') }
/>
<span className="slider"></span> <span className="slider"></span>
</label> </label>
</div> </div>
<div className="settings-row nopadding"> <div className="settings-row nopadding">
<div className="settings-row-title"> </div> <div className="settings-row-title"> </div>
<label className="settings-switch"> <label className="settings-switch">
<input type="checkbox" /> <input
type="checkbox"
checked={ alarmSetting['62'] }
onChange={ (e: ChangeEvent<HTMLInputElement>) => callAppAlarmConsent(e.target.checked, '62') }
/>
<span className="slider"></span> <span className="slider"></span>
</label> </label>
</div> </div>
@@ -84,7 +182,11 @@ export const SettingPage = () => {
<div className="settings-row link"> <div className="settings-row link">
<div className="settings-row-title bd-style"> </div> <div className="settings-row-title bd-style"> </div>
<label className="settings-switch"> <label className="settings-switch">
<input type="checkbox" /> <input
type="checkbox"
checked={ alarmSetting['15'] }
onChange={ (e: ChangeEvent<HTMLInputElement>) => callAppAlarmConsent(e.target.checked, '15') }
/>
<span className="slider"></span> <span className="slider"></span>
</label> </label>
</div> </div>