-
Notifications
You must be signed in to change notification settings - Fork 607
refactor: remove rsc from apis #3392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
142 changes: 107 additions & 35 deletions
142
apps/dashboard/app/(app)/apis/_components/api-list-client.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| import { Key, ProgressBar } from "@unkey/icons"; | ||
|
|
||
| export const ChartSkeleton = () => { | ||
| return <div className="h-[140px] bg-grayA-2 p-4 flex items-end gap-1" />; | ||
| }; | ||
ogzhanolguncu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| export const MetricStatsSkeleton = () => { | ||
| return ( | ||
| <> | ||
| <div className="flex gap-[14px] items-center"> | ||
| <div className="flex flex-col gap-1"> | ||
| <div className="flex gap-2 items-center h-4"> | ||
| <div className="bg-accent-8 rounded h-[10px] w-1 animate-pulse" /> | ||
| <div className="h-3 w-16 bg-grayA-3 rounded animate-pulse" /> | ||
| </div> | ||
| </div> | ||
| <div className="flex flex-col gap-1"> | ||
| <div className="flex gap-2 items-center h-4"> | ||
| <div className="bg-orange-9 rounded h-[10px] w-1 animate-pulse" /> | ||
| <div className="h-3 w-16 bg-grayA-3 rounded animate-pulse" /> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| <div className="flex items-center gap-2 min-w-0 max-w-[40%] h-4"> | ||
| <Key className="text-accent-11 flex-shrink-0 opacity-30" /> | ||
| <div className="h-3 w-10 bg-grayA-3 rounded animate-pulse" /> | ||
| </div> | ||
| </> | ||
| ); | ||
| }; | ||
ogzhanolguncu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| export const ApiCardSkeleton = () => { | ||
| return ( | ||
| <div className="flex flex-col border border-gray-6 rounded-xl overflow-hidden"> | ||
| <ChartSkeleton /> | ||
| <div className="p-4 md:p-6 border-t border-gray-6 flex flex-col gap-2"> | ||
| <div className="flex justify-between items-center"> | ||
| <div className="flex flex-col flex-grow min-w-0"> | ||
| <div className="flex gap-2 md:gap-3 items-center h-6"> | ||
| <div className="flex-shrink-0 opacity-30"> | ||
| <ProgressBar className="text-accent-11" /> | ||
| </div> | ||
| <div className="h-5 w-32 bg-grayA-3 rounded animate-pulse" /> | ||
| </div> | ||
| <div className="h-4"> | ||
| <div className="h-3 w-32 bg-grayA-3 rounded animate-pulse" /> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| <div className="flex items-center w-full justify-between gap-3 md:gap-4 mt-2 h-[18px]"> | ||
| <MetricStatsSkeleton /> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,36 +1,28 @@ | ||
| import { getAuth } from "@/lib/auth"; | ||
| import { db } from "@/lib/db"; | ||
| import { redirect } from "next/navigation"; | ||
| import { ApiListClient } from "./_components/api-list-client"; | ||
| import { DEFAULT_OVERVIEW_FETCH_LIMIT } from "./_components/constants"; | ||
| import { fetchApiOverview } from "./actions"; | ||
| import { Navigation } from "./navigation"; | ||
|
|
||
| export const dynamic = "force-dynamic"; | ||
|
|
||
| type Props = { | ||
| searchParams: { new?: boolean }; | ||
| }; | ||
| "use client"; | ||
|
|
||
| export default async function ApisOverviewPage(props: Props) { | ||
| const { orgId } = await getAuth(); | ||
| const workspace = await db.query.workspaces.findFirst({ | ||
| where: (table, { and, eq, isNull }) => and(eq(table.orgId, orgId), isNull(table.deletedAtM)), | ||
| }); | ||
|
|
||
| if (!workspace) { | ||
| return redirect("/new"); | ||
| } | ||
| import { Navbar } from "@/components/navigation/navbar"; | ||
| import { Nodes } from "@unkey/icons"; | ||
| import { useSearchParams } from "next/navigation"; | ||
| import { ApiListClient } from "./_components/api-list-client"; | ||
| import { CreateApiButton } from "./_components/create-api-button"; | ||
|
|
||
| const initialData = await fetchApiOverview({ | ||
| workspaceId: workspace.id, | ||
| limit: DEFAULT_OVERVIEW_FETCH_LIMIT, | ||
| }); | ||
| export default function ApisOverviewPage() { | ||
| const searchParams = useSearchParams(); | ||
| const isNewApi = searchParams?.get("new") === "true"; | ||
|
|
||
ogzhanolguncu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return ( | ||
| <div> | ||
| <Navigation isNewApi={!!props.searchParams.new} apisLength={initialData.total} /> | ||
| <ApiListClient initialData={initialData} /> | ||
| <Navbar> | ||
| <Navbar.Breadcrumbs icon={<Nodes />}> | ||
| <Navbar.Breadcrumbs.Link href="/apis" active> | ||
| APIs | ||
| </Navbar.Breadcrumbs.Link> | ||
| </Navbar.Breadcrumbs> | ||
| <Navbar.Actions> | ||
| <CreateApiButton key="createApi" defaultOpen={isNewApi} /> | ||
| </Navbar.Actions> | ||
| </Navbar> | ||
| <ApiListClient /> | ||
| </div> | ||
| ); | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Consider potential state synchronization conflicts
The
useEffectsynchronizesallApis(server data) toapiList(local state), but search operations modifyapiListdirectly. If new server data arrives while searching, the search results would be overwritten.While this may not be a practical issue due to search disabling pagination, consider a more explicit state management pattern to avoid potential conflicts.
🤖 Prompt for AI Agents