Add localization for alarm notification categories
- Add translation keys for alarm categories in ko.json and en.json - Implement getCategoryLabel function to map category codes to localized labels - Sort categories to display "etc" category at the end - Replace hardcoded desc1 values with localized category labels 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -20,11 +20,32 @@ export const ListPage = () => {
|
||||
|
||||
const [appNotificationCategory, setAppNotificationCategory] = useState<string>('');
|
||||
|
||||
const getCategoryLabel = (code1: string) => {
|
||||
const categoryMap: { [key: string]: string } = {
|
||||
'10': t('alarm.categories.benefits'),
|
||||
'20': t('alarm.categories.notice'),
|
||||
'30': t('alarm.categories.serviceGuide'),
|
||||
'40': t('alarm.categories.etc'),
|
||||
'60': t('alarm.categories.settlement'),
|
||||
'61': t('alarm.categories.settlementStatus'),
|
||||
'62': t('alarm.categories.settlementLimit')
|
||||
};
|
||||
return categoryMap[code1] || '';
|
||||
};
|
||||
|
||||
const resetAlarmCategories = () => {
|
||||
if(appNotificationCategories){
|
||||
let newAppNotificationCategories = appNotificationCategories.filter((value, index) => {
|
||||
return value.code1 !== '****' && value.code2 === '*';
|
||||
});
|
||||
|
||||
// '기타' 카테고리(code1 === '40')를 맨 마지막으로 이동
|
||||
newAppNotificationCategories.sort((a, b) => {
|
||||
if (a.code1 === '40') return 1;
|
||||
if (b.code1 === '40') return -1;
|
||||
return 0;
|
||||
});
|
||||
|
||||
console.log(newAppNotificationCategories)
|
||||
setAppNotificationCategories(newAppNotificationCategories);
|
||||
}
|
||||
@@ -33,6 +54,10 @@ export const ListPage = () => {
|
||||
useEffect(() => {
|
||||
resetAlarmCategories();
|
||||
}, [totalAppNotificationCategories])
|
||||
|
||||
useEffect(() => {
|
||||
console.log('totalAppNotificationCategories', totalAppNotificationCategories);
|
||||
}, [totalAppNotificationCategories]);
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -45,10 +70,11 @@ export const ListPage = () => {
|
||||
>{t('alarm.all')}</button>
|
||||
{ !!appNotificationCategories &&
|
||||
appNotificationCategories.map((value, index) => (
|
||||
<button
|
||||
<button
|
||||
key={index}
|
||||
className={ `tab36 ${(appNotificationCategory === value.code1)? 'on': ''}`}
|
||||
onClick={ () => setAppNotificationCategory(value.code1) }
|
||||
>{ value.desc1 }</button>
|
||||
>{ getCategoryLabel(value.code1) }</button>
|
||||
))
|
||||
}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user