'use client'; import { useEffect, useMemo, useState } from 'react'; import JobsTable from '@/components/JobsTable'; import { TopBar, MainContent } from '@/components/layout'; import Link from 'next/link'; import { useAuth } from '@/contexts/AuthContext'; import HFLoginButton from '@/components/HFLoginButton'; import useSettings from '@/hooks/useSettings'; import { apiClient } from '@/utils/api'; export default function Dashboard() { const { status: authStatus, namespace, token: authToken } = useAuth(); const { settings } = useSettings(); const isAuthenticated = authStatus === 'authenticated'; const effectiveToken = useMemo(() => authToken || settings.HF_TOKEN, [authToken, settings.HF_TOKEN]); type OrgStatus = 'idle' | 'checking' | 'member' | 'missing' | 'error'; const [orgStatus, setOrgStatus] = useState('idle'); useEffect(() => { if (!isAuthenticated) { setOrgStatus('idle'); return; } if (!effectiveToken) { setOrgStatus('idle'); return; } let cancelled = false; setOrgStatus('checking'); apiClient .post('/api/hf-hub', { action: 'whoami', token: effectiveToken, }) .then(response => { if (cancelled) return; const orgsRaw = response.data?.user?.orgs ?? response.data?.user?.organizations ?? []; const REQUIRED_ORG = 'lora-training-frenzi'; const isMember = Array.isArray(orgsRaw) ? orgsRaw.some((org: any) => { if (!org) return false; if (typeof org === 'string') { return org === REQUIRED_ORG; } const nameMatch = org?.name || org?.organization || org?.namespace || org?.id; return nameMatch === REQUIRED_ORG; }) : false; setOrgStatus(isMember ? 'member' : 'missing'); }) .catch(() => { if (!cancelled) { setOrgStatus('error'); } }); return () => { cancelled = true; }; }, [effectiveToken, isAuthenticated]); return ( <>

Dashboard

{isAuthenticated ? `Welcome back, ${namespace || 'creator'}!` : 'Welcome to Ostris AI Toolkit'}

{isAuthenticated ? 'You are signed in with Hugging Face and can manage jobs, datasets, and submissions. Train LoRAs at $0.042/minute if you are a PRO user.' : 'Authenticate with Hugging Face or add a personal access token to create jobs, upload datasets, and launch training. Train LoRAs at $0.042/minute if you are a PRO user.'} {!isAuthenticated && ( <> {' '} Subscribe to PRO )}

{isAuthenticated ? (
Create a Training Job Manage Datasets Settings
) : (
Or manage tokens in Settings
)}

Active Jobs

View All
{isAuthenticated ? ( ) : (
Sign in with Hugging Face or add an access token in Settings to view and manage jobs.
)}
); }