forked from phoenix/litellm-mirror
store current page on url
This commit is contained in:
parent
c60261c3bc
commit
adc3c0beb7
1 changed files with 20 additions and 10 deletions
|
@ -82,16 +82,26 @@ const CreateKeyPage = () => {
|
||||||
const invitation_id = searchParams.get("invitation_id");
|
const invitation_id = searchParams.get("invitation_id");
|
||||||
const token = getCookie('token');
|
const token = getCookie('token');
|
||||||
|
|
||||||
|
// Get page from URL, default to 'api-keys' if not present
|
||||||
const [page, setPage] = useState(() => {
|
const [page, setPage] = useState(() => {
|
||||||
if (typeof window !== 'undefined') {
|
return searchParams.get('page') || 'api-keys';
|
||||||
return localStorage.getItem('selectedPage') || "api-keys";
|
|
||||||
}
|
|
||||||
return "api-keys";
|
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
// Custom setPage function that updates URL
|
||||||
localStorage.setItem('selectedPage', page);
|
const updatePage = (newPage: string) => {
|
||||||
}, [page]);
|
// Update URL without full page reload
|
||||||
|
const newSearchParams = new URLSearchParams(searchParams);
|
||||||
|
newSearchParams.set('page', newPage);
|
||||||
|
|
||||||
|
// Use Next.js router to update URL
|
||||||
|
window.history.pushState(
|
||||||
|
null,
|
||||||
|
'',
|
||||||
|
`?${newSearchParams.toString()}`
|
||||||
|
);
|
||||||
|
|
||||||
|
setPage(newPage);
|
||||||
|
};
|
||||||
|
|
||||||
const [accessToken, setAccessToken] = useState<string | null>(null);
|
const [accessToken, setAccessToken] = useState<string | null>(null);
|
||||||
|
|
||||||
|
@ -172,8 +182,8 @@ const CreateKeyPage = () => {
|
||||||
/>
|
/>
|
||||||
<div className="flex flex-1 overflow-auto">
|
<div className="flex flex-1 overflow-auto">
|
||||||
<div className="mt-8">
|
<div className="mt-8">
|
||||||
<Sidebar
|
<Sidebar
|
||||||
setPage={setPage}
|
setPage={updatePage}
|
||||||
userRole={userRole}
|
userRole={userRole}
|
||||||
defaultSelectedKey={page}
|
defaultSelectedKey={page}
|
||||||
/>
|
/>
|
||||||
|
@ -289,7 +299,7 @@ const CreateKeyPage = () => {
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue