diff --git a/web/next.config.ts b/web/next.config.ts index f87216d..a680de3 100644 --- a/web/next.config.ts +++ b/web/next.config.ts @@ -26,8 +26,10 @@ const nextConfig: NextConfig = { transpilePackages: [ "@bytelyst/api-client", "@bytelyst/blob-client", + "@bytelyst/dashboard-components", "@bytelyst/design-tokens", "@bytelyst/diagnostics-client", + "@bytelyst/extraction", "@bytelyst/feature-flag-client", "@bytelyst/kill-switch-client", "@bytelyst/platform-client", diff --git a/web/package.json b/web/package.json index 8001396..e0c6033 100644 --- a/web/package.json +++ b/web/package.json @@ -21,10 +21,12 @@ "@bytelyst/feature-flag-client": "^0.1.0", "@bytelyst/kill-switch-client": "^0.1.0", "@bytelyst/platform-client": "^0.1.0", + "@bytelyst/dashboard-components": "^0.1.0", + "@bytelyst/extraction": "^0.1.0", "@bytelyst/react-auth": "^0.1.0", "@bytelyst/telemetry-client": "^0.1.0", - "@bytelyst/ui": "file:../../learning_ai_common_plat/packages/ui", "lucide-react": "^0.575.0", + "sonner": "^2.0.0", "next": "16.1.6", "react": "19.2.0", "react-dom": "19.2.0", diff --git a/web/src/app/error.tsx b/web/src/app/error.tsx index 8fb1202..01522b3 100644 --- a/web/src/app/error.tsx +++ b/web/src/app/error.tsx @@ -1,25 +1,12 @@ -'use client'; +"use client"; -import { useEffect } from 'react'; +import { useEffect } from "react"; +import { ErrorPage } from "@bytelyst/dashboard-components"; export default function Error({ error, reset }: { error: Error & { digest?: string }; reset: () => void }) { - useEffect(() => { console.error('Unhandled error:', error); }, [error]); + useEffect(() => { + console.error("Unhandled error:", error); + }, [error]); - return ( -
-
-

Something went wrong

-

- {error.message || 'An unexpected error occurred.'} -

- -
-
- ); + return ; } diff --git a/web/src/app/loading.tsx b/web/src/app/loading.tsx index 3109277..559cc05 100644 --- a/web/src/app/loading.tsx +++ b/web/src/app/loading.tsx @@ -1,13 +1,9 @@ +import { LoadingSpinner } from "@bytelyst/dashboard-components"; + export default function Loading() { return ( -
-
-
-

Loading...

-
+
+
); } diff --git a/web/src/app/not-found.tsx b/web/src/app/not-found.tsx index b69d182..dc5dbd5 100644 --- a/web/src/app/not-found.tsx +++ b/web/src/app/not-found.tsx @@ -1,18 +1,15 @@ -import Link from "next/link"; +"use client"; -export default function NotFoundPage() { +import { useRouter } from "next/navigation"; +import { NotFoundPage } from "@bytelyst/dashboard-components"; + +export default function NotFound() { + const router = useRouter(); return ( -
-
-
Missing note or route
-

Not found

-

- The requested note or view does not exist or is no longer available for your current workspace access. -

- - Back to dashboard - -
-
+ router.push("/dashboard")} + /> ); } diff --git a/web/src/app/providers.tsx b/web/src/app/providers.tsx index 3444630..05bc8d9 100644 --- a/web/src/app/providers.tsx +++ b/web/src/app/providers.tsx @@ -2,10 +2,10 @@ import type { ReactNode } from "react"; import { useEffect } from "react"; +import { Toaster } from "sonner"; import { AuthProvider } from "@/lib/auth"; import { initDiagnostics } from "@/lib/diagnostics"; import { initTelemetry } from "@/lib/telemetry"; -import { ToastProvider } from "@bytelyst/ui"; export function Providers({ children }: { children: ReactNode }) { useEffect(() => { @@ -14,8 +14,20 @@ export function Providers({ children }: { children: ReactNode }) { }, []); return ( - + <> + {children} - + ); } diff --git a/web/src/lib/extraction-client.ts b/web/src/lib/extraction-client.ts index 0463e2d..9118da2 100644 --- a/web/src/lib/extraction-client.ts +++ b/web/src/lib/extraction-client.ts @@ -1,36 +1,23 @@ "use client"; -import { createApiClient } from "@bytelyst/api-client"; +import { createExtractionClient, type ExtractionClient } from "@bytelyst/extraction"; import { EXTRACTION_SERVICE_URL, PRODUCT_ID } from "@/lib/product-config"; import type { NoteTask } from "@/lib/types"; -type ExtractionEntity = { - extraction_class: string; - extraction_text: string; - attributes?: Record; -}; - -type ExtractResponse = { - extractions: ExtractionEntity[]; -}; - function getAccessToken(): string | null { - if (typeof window === "undefined") { - return null; - } - + if (typeof window === "undefined") return null; return localStorage.getItem(`${PRODUCT_ID}_access_token`); } -let _extractionApi: ReturnType | null = null; -function getExtractionApi() { - if (!_extractionApi) { - _extractionApi = createApiClient({ +let _client: ExtractionClient | null = null; +function getClient(): ExtractionClient { + if (!_client) { + _client = createExtractionClient({ baseUrl: EXTRACTION_SERVICE_URL, getToken: getAccessToken, }); } - return _extractionApi; + return _client; } function slugify(value: string): string { @@ -42,13 +29,10 @@ function slugify(value: string): string { } export async function extractSuggestedTasks(text: string): Promise { - const response = await getExtractionApi().fetch("/api/extract", { - method: "POST", - body: JSON.stringify({ - text, - taskId: "transcript-extraction", - productId: PRODUCT_ID, - }), + const response = await getClient().extract({ + text, + taskId: "transcript-extraction", + productId: PRODUCT_ID, }); return response.extractions diff --git a/web/src/lib/toast.ts b/web/src/lib/toast.ts new file mode 100644 index 0000000..be17a82 --- /dev/null +++ b/web/src/lib/toast.ts @@ -0,0 +1,3 @@ +"use client"; + +export { toast } from "sonner";