summaryrefslogtreecommitdiff
path: root/app/src/pages/index.tsx
blob: 99202e533f75e6fe9ea4f4a95d8f10b032eecf76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import * as Bun from "bun";
import { Suspense } from "react";
import { TwitterApiService } from "../lib/twitter-api";
import { BookmarkList } from "../components/bookmark-list";

async function BookmarkFetcher() {
  const cookie = Bun.env.TWATTER_COKI;

  if (!cookie) {
    return (
      <div className="text-red-600">Missing Twitter cookie configuration</div>
    );
  }

  try {
    const twitterService = new TwitterApiService(cookie);
    const bookmarks = await twitterService.fetchAllBookmarks();
    const file = Bun.file("testData.json");
    await file.write(JSON.stringify(bookmarks));

    return (
      <div className="space-y-6">
        <div className="bg-white border border-gray-200 rounded-lg p-6">
          <h2 className="text-xl font-semibold mb-4">Your Bookmarks</h2>
          <BookmarkList bookmarks={bookmarks} />
        </div>
      </div>
    );
  } catch (error) {
    return (
      <div className="bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-lg">
        Error loading bookmarks:{" "}
        {error instanceof Error ? error.message : "Unknown error"}
      </div>
    );
  }
}

function LoadingSpinner() {
  return (
    <div className="flex items-center justify-center py-12">
      <div className="animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600"></div>
      <span className="ml-3 text-gray-600">
        Loading your Twitter bookmarks...
      </span>
    </div>
  );
}

export default async function HomePage() {
  return (
    <div className="max-w-4xl mx-auto">
      <title>SORMARK - Twitter Bookmark Manager</title>
      <div className="mb-8">
        <h1 className="text-4xl font-bold tracking-tight mb-4">SORMARK</h1>
        <p className="text-lg text-gray-600">
          Your Twitter bookmark manager powered by AI
        </p>
      </div>

      <Suspense fallback={<LoadingSpinner />}>
        <BookmarkFetcher />
      </Suspense>
    </div>
  );
}

export const getConfig = async () => {
  return {
    render: "static",
  } as const;
};