import { useState } from 'react' import { Outlet, NavLink } from 'react-router-dom' import { useAuth } from '../core/auth/AuthContext' import { apiClient } from '../core/api/api-client' import HBLogo from './ui/HBLogo' const NAV_ITEMS = [ { to: '/dashboard', label: 'Dashboard' }, { to: '/mitras', label: 'Mitra' }, { to: '/sessions', label: 'Sesi' }, { to: '/failed-pairings', label: 'Failed Pairings' }, { to: '/users', label: 'Users' }, { to: '/mitra-activity', label: 'Aktivitas Mitra' }, { to: '/payment-catalog', label: 'Payment Catalog' }, { to: '/settings', label: 'Settings' }, ] const PasswordChangeForm = ({ onDone }) => { const [current, setCurrent] = useState('') const [next, setNext] = useState('') const [saving, setSaving] = useState(false) const [error, setError] = useState('') const [success, setSuccess] = useState(false) const submit = async (e) => { e.preventDefault() setError('') setSaving(true) try { await apiClient.patch('/internal/control-center-users/me/password', { current_password: current, new_password: next, }) setSuccess(true) setCurrent('') setNext('') } catch (err) { const code = err?.response?.data?.error?.code const msg = err?.response?.data?.error?.message if (code === 'INVALID_CREDENTIALS') setError('Password saat ini salah.') else if (code?.startsWith('PASSWORD_')) setError(msg || 'Password tidak memenuhi syarat.') else setError('Gagal mengubah password.') } finally { setSaving(false) } } return (
setCurrent(e.target.value)} required style={{ marginBottom: 8 }} /> setNext(e.target.value)} required minLength={8} style={{ marginBottom: 8 }} /> {error &&

{error}

} {success &&

Password berhasil diubah.

}
) } export default function Layout() { const { user, logout } = useAuth() const [showPwForm, setShowPwForm] = useState(false) return (
) }