-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSettingsNavigation.tsx
More file actions
164 lines (147 loc) · 3.53 KB
/
SettingsNavigation.tsx
File metadata and controls
164 lines (147 loc) · 3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
import React, { useState, useEffect } from 'react';
import { Collapse } from 'antd';
import { useNavigate, useLocation } from 'react-router-dom';
import styled from 'styled-components';
import {
FilterOutlined,
PictureOutlined,
ApiOutlined,
RobotOutlined,
TwitterOutlined,
InfoCircleOutlined,
WalletOutlined,
GlobalOutlined,
BellOutlined,
} from '@ant-design/icons';
const { Panel } = Collapse;
const StyledCollapse = styled(Collapse)`
margin-bottom: 1.5rem;
.ant-collapse-header {
display: flex;
align-items: center;
padding: 12px 16px !important;
.ant-collapse-arrow {
right: 16px;
left: auto !important;
}
}
.ant-collapse-content-box {
padding: 0 !important;
}
.panel-icon {
margin-right: 12px;
font-size: 16px;
}
`;
const NavigationItem = styled.div`
padding: 12px 16px;
cursor: pointer;
transition: all 0.3s;
display: flex;
align-items: center;
&:hover {
background-color: rgba(255, 255, 255, 0.1);
}
&.active {
background-color: rgba(255, 255, 255, 0.05);
}
.item-icon {
margin-right: 12px;
font-size: 16px;
}
`;
interface SettingsTab {
key: string;
label: string;
icon: React.ReactNode;
path: string;
}
const settingsTabs: SettingsTab[] = [
{
key: 'image_moderation',
label: 'Image Moderation',
icon: <PictureOutlined className="item-icon" />,
path: '/settings/image-moderation'
},
{
key: 'content_filter',
label: 'Content Filter',
icon: <FilterOutlined className="item-icon" />,
path: '/settings/content-filter'
},
{
key: 'ollama',
label: 'Ollama',
icon: <RobotOutlined className="item-icon" />,
path: '/settings/ollama'
},
{
key: 'push_notifications',
label: 'Push Notifications',
icon: <BellOutlined className="item-icon" />,
path: '/settings/push-notifications'
},
{
key: 'relay_info',
label: 'Relay Info',
icon: <InfoCircleOutlined className="item-icon" />,
path: '/settings/relay-info'
},
{
key: 'wallet',
label: 'Wallet',
icon: <WalletOutlined className="item-icon" />,
path: '/settings/wallet'
},
{
key: 'general',
label: 'General',
icon: <GlobalOutlined className="item-icon" />,
path: '/settings/general'
},
];
const SettingsNavigation: React.FC = () => {
const navigate = useNavigate();
const location = useLocation();
const [activeKey, setActiveKey] = useState<string | undefined>(undefined);
// Determine active tab based on current path
useEffect(() => {
const path = location.pathname;
const tab = settingsTabs.find(tab => tab.path === path);
if (tab) {
setActiveKey(tab.key);
}
}, [location.pathname]);
const handleItemClick = (tab: SettingsTab) => {
navigate(tab.path);
setActiveKey(tab.key);
};
return (
<StyledCollapse
accordion
expandIconPosition="end"
ghost
activeKey={activeKey}
onChange={(key) => setActiveKey(key as string | undefined)}
>
{settingsTabs.map(tab => (
<Panel
key={tab.key}
header={
<span>
{React.cloneElement(tab.icon as React.ReactElement, { className: 'panel-icon' })} {tab.label}
</span>
}
>
<NavigationItem
className={activeKey === tab.key ? 'active' : ''}
onClick={() => handleItemClick(tab)}
>
{tab.label}
</NavigationItem>
</Panel>
))}
</StyledCollapse>
);
};
export default SettingsNavigation;