1
Fork 0
mirror of https://github.com/thegeneralist01/archivr synced 2026-07-22 11:15:41 +02:00

fix: sync URL to active view and settings sub-tab

This commit is contained in:
TheGeneralist 2026-07-01 14:43:41 +02:00
parent c4f1c7a137
commit 44f67390be
Signed by: thegeneralist01
SSH key fingerprint: SHA256:pp9qddbCNmVNoSjevdvQvM5z0DHN7LTa8qBMbcMq/R4
5 changed files with 85 additions and 48 deletions

View file

@ -8,10 +8,9 @@ import {
const ROLE_ADMIN = 4
export default function SettingsView() {
export default function SettingsView({ tab, onTabChange }) {
const { currentUser, setCurrentUser } = useContext(AuthContext) ?? {}
const isAdmin = currentUser && ((currentUser.role_bits & ROLE_ADMIN) !== 0)
const [tab, setTab] = useState('profile')
const tabs = ['profile', 'tokens', ...(isAdmin ? ['instance'] : [])]
const tabLabels = { profile: 'Profile', tokens: 'API Tokens', instance: 'Instance' }
@ -23,7 +22,7 @@ export default function SettingsView() {
{tabs.map(t => (
<button key={t}
className={`view-tab${tab === t ? ' is-active' : ''}`}
onClick={() => setTab(t)}>
onClick={() => onTabChange(t)}>
{tabLabels[t]}
</button>
))}