mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-03 21:29:08 +00:00
Add our first view via Next.js for Agents (#817)
Initialize our migration to use Next.js for front-end views via Agents. This includes setup for getting authenticated users, reading in available agents, setting up a pop-up modal when you're clicking on an agent, and allowing users to start new conversations with agents. Best attempt at an in-place migration, though there are some noticeable differences. Also adds view for chat that are not being used, but in experimental phase.
This commit is contained in:
23
src/interface/web/app/common/auth.ts
Normal file
23
src/interface/web/app/common/auth.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
'use client'
|
||||
|
||||
import useSWR from 'swr'
|
||||
|
||||
export interface UserProfile {
|
||||
email: string;
|
||||
username: string;
|
||||
photo: string;
|
||||
is_active: boolean;
|
||||
has_documents: boolean;
|
||||
}
|
||||
|
||||
const userFetcher = () => window.fetch('/api/v1/user').then(res => res.json()).catch(err => console.log(err));
|
||||
|
||||
export function useAuthenticatedData() {
|
||||
|
||||
const { data, error } = useSWR<UserProfile>('/api/v1/user', userFetcher, { revalidateOnFocus: false });
|
||||
|
||||
if (error) return null;
|
||||
if (!data) return null;
|
||||
|
||||
return data;
|
||||
}
|
||||
Reference in New Issue
Block a user