-
Notifications
You must be signed in to change notification settings - Fork 328
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Initial Projects and Teams setup in dashboard (#3682)
<!-- start pr-codex --> ## PR-Codex overview This PR adds new pages and components related to team and project settings, navigation improvements, and styling updates. ### Detailed summary - Added new pages for settings, contracts, and various connect options - Implemented navigation improvements with NavLink and SidebarLink components - Styling updates for scrollbar and badge variants - Created components like TWAutoConnect and TeamTabs for better UI/UX > The following files were skipped due to too many changes: `apps/dashboard/src/@/components/ui/badge.tsx`, `apps/dashboard/src/app/components/Header/TeamHeader/SearchInput.tsx`, `apps/dashboard/src/app/team/[team_slug]/[project_slug]/connect/ConnectMobileSidebar.tsx`, `apps/dashboard/src/app/team/[team_slug]/components/active-wallet-logo.tsx`, `apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/(chainPage)/layout.tsx`, `apps/dashboard/src/components/app-layouts/provider-setup.tsx`, `apps/dashboard/src/@/components/ui/select.tsx`, `apps/dashboard/src/@/components/blocks/BurgerMenuButton.tsx`, `apps/dashboard/.storybook/preview.tsx`, `apps/dashboard/src/components/icons/ChainIcon.tsx`, `apps/dashboard/src/app/team/[team_slug]/[project_slug]/connect/layout.tsx`, `apps/dashboard/src/@/api/team-members.ts`, `apps/dashboard/src/app/components/Header/TeamHeader/ProjectSelectorMobileMenuButton.tsx`, `apps/dashboard/src/app/team/[team_slug]/(team)/layout.tsx`, `apps/dashboard/src/app/components/Header/TeamHeader/TeamSelectorMobileMenuButton.tsx`, `apps/dashboard/src/app/components/Header/TeamHeader/TeamHeader.tsx`, `apps/dashboard/src/@/api/team.ts`, `apps/dashboard/src/app/team/[team_slug]/(team)/~/settings/layout.tsx`, `apps/dashboard/src/@/api/projects.ts`, `apps/dashboard/src/app/team/[team_slug]/[project_slug]/layout.tsx`, `apps/dashboard/src/app/components/Header/TeamHeader/ResourcesDropdownButton.tsx`, `apps/dashboard/src/app/components/Header/TeamHeader/TeamAndProjectSelectorPopoverButton.tsx`, `apps/dashboard/src/app/team/[team_slug]/components/account-button.client.tsx`, `apps/dashboard/src/app/components/Header/TeamHeader/ProjectSelectorUI.tsx`, `apps/dashboard/src/app/components/Header/TeamHeader/TeamSelectionUI.tsx`, `apps/dashboard/src/components/cmd-k-search/index.tsx`, `apps/dashboard/src/@/components/ui/tabs.tsx`, `apps/dashboard/src/stories/Header.stories.tsx`, `apps/dashboard/src/app/components/Header/TeamHeader/MobileBurgerMenuButton.tsx`, `apps/dashboard/src/app/components/Header/TeamHeader/TeamHeaderUI.tsx`, `apps/dashboard/src/app/team/[team_slug]/(team)/TeamOverviewPage.tsx` > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
- Loading branch information
Showing
61 changed files
with
2,350 additions
and
93 deletions.
There are no files selected for viewing
This file contains 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 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 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,73 @@ | ||
import "server-only"; | ||
import { COOKIE_ACTIVE_ACCOUNT, COOKIE_PREFIX_TOKEN } from "@/constants/cookie"; | ||
import { cookies } from "next/headers"; | ||
|
||
const THIRDWEB_API_HOST = | ||
process.env.NEXT_PUBLIC_THIRDWEB_API_HOST || "https://api.thirdweb.com"; | ||
|
||
export type Project = { | ||
id: string; | ||
name: string; | ||
createdAt: Date; | ||
updatedAt: Date; | ||
deletedAt: Date | null; | ||
bannedAt: Date | null; | ||
domains: string[]; | ||
bundleIds: string[]; | ||
redirectUrls: string[]; | ||
lastAccessedAt: Date | null; | ||
slug: string; | ||
teamId: string; | ||
publishableKey: string; | ||
// image: string; // TODO | ||
}; | ||
|
||
export async function getProjects(teamSlug: string) { | ||
const cookiesManager = cookies(); | ||
const activeAccount = cookiesManager.get(COOKIE_ACTIVE_ACCOUNT)?.value; | ||
const token = activeAccount | ||
? cookiesManager.get(COOKIE_PREFIX_TOKEN + activeAccount)?.value | ||
: null; | ||
|
||
if (!token) { | ||
return []; | ||
} | ||
|
||
const teamsRes = await fetch( | ||
`${THIRDWEB_API_HOST}/v1/teams/${teamSlug}/projects`, | ||
{ | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
}, | ||
); | ||
if (teamsRes.ok) { | ||
return (await teamsRes.json())?.result as Project[]; | ||
} | ||
return []; | ||
} | ||
|
||
export async function getProject(teamSlug: string, projectSlug: string) { | ||
const cookiesManager = cookies(); | ||
const activeAccount = cookiesManager.get(COOKIE_ACTIVE_ACCOUNT)?.value; | ||
const token = activeAccount | ||
? cookiesManager.get(COOKIE_PREFIX_TOKEN + activeAccount)?.value | ||
: null; | ||
|
||
if (!token) { | ||
return null; | ||
} | ||
|
||
const teamsRes = await fetch( | ||
`${THIRDWEB_API_HOST}/v1/teams/${teamSlug}/projects/${projectSlug}`, | ||
{ | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
}, | ||
); | ||
if (teamsRes.ok) { | ||
return (await teamsRes.json())?.result as Project; | ||
} | ||
return null; | ||
} |
This file contains 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,53 @@ | ||
import "server-only"; | ||
import { COOKIE_ACTIVE_ACCOUNT, COOKIE_PREFIX_TOKEN } from "@/constants/cookie"; | ||
import { cookies } from "next/headers"; | ||
|
||
const THIRDWEB_API_HOST = | ||
process.env.NEXT_PUBLIC_THIRDWEB_API_HOST || "https://api.thirdweb.com"; | ||
|
||
const TeamAccountRole = { | ||
OWNER: "OWNER", | ||
MEMBER: "MEMBER", | ||
} as const; | ||
|
||
export type TeamAccountRole = | ||
(typeof TeamAccountRole)[keyof typeof TeamAccountRole]; | ||
|
||
export type TeamMember = { | ||
account: { | ||
name: string; | ||
email: string | null; | ||
}; | ||
} & { | ||
deletedAt: Date | null; | ||
accountId: string; | ||
teamId: string; | ||
createdAt: Date; | ||
updatedAt: Date; | ||
role: TeamAccountRole; | ||
}; | ||
|
||
export async function getMembers(teamSlug: string) { | ||
const cookiesManager = cookies(); | ||
const activeAccount = cookiesManager.get(COOKIE_ACTIVE_ACCOUNT)?.value; | ||
const token = activeAccount | ||
? cookiesManager.get(COOKIE_PREFIX_TOKEN + activeAccount)?.value | ||
: null; | ||
|
||
if (!token) { | ||
return []; | ||
} | ||
|
||
const teamsRes = await fetch( | ||
`${THIRDWEB_API_HOST}/v1/teams/${teamSlug}/members`, | ||
{ | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
}, | ||
); | ||
if (teamsRes.ok) { | ||
return (await teamsRes.json())?.result as TeamMember[]; | ||
} | ||
return []; | ||
} |
This file contains 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,58 @@ | ||
import "server-only"; | ||
import { COOKIE_ACTIVE_ACCOUNT, COOKIE_PREFIX_TOKEN } from "@/constants/cookie"; | ||
import { cookies } from "next/headers"; | ||
|
||
const THIRDWEB_API_HOST = | ||
process.env.NEXT_PUBLIC_THIRDWEB_API_HOST || "https://api.thirdweb.com"; | ||
|
||
export type Team = { | ||
name: string; | ||
slug: string; | ||
// image: string; // -> TODO | ||
billingPlan: "pro" | "growth" | "free"; | ||
billingStatus: "validPayment" | (string & {}); // what's the other value? | ||
}; | ||
|
||
export async function getTeamBySlug(slug: string) { | ||
const cookiesManager = cookies(); | ||
const activeAccount = cookiesManager.get(COOKIE_ACTIVE_ACCOUNT)?.value; | ||
const token = activeAccount | ||
? cookiesManager.get(COOKIE_PREFIX_TOKEN + activeAccount)?.value | ||
: null; | ||
|
||
if (!token) { | ||
return null; | ||
} | ||
|
||
const teamRes = await fetch(`${THIRDWEB_API_HOST}/v1/teams/${slug}`, { | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
}); | ||
if (teamRes.ok) { | ||
return (await teamRes.json())?.result as Team; | ||
} | ||
return null; | ||
} | ||
|
||
export async function getTeams() { | ||
const cookiesManager = cookies(); | ||
const activeAccount = cookiesManager.get(COOKIE_ACTIVE_ACCOUNT)?.value; | ||
const token = activeAccount | ||
? cookiesManager.get(COOKIE_PREFIX_TOKEN + activeAccount)?.value | ||
: null; | ||
|
||
if (!token) { | ||
return []; | ||
} | ||
|
||
const teamsRes = await fetch(`${THIRDWEB_API_HOST}/v1/teams`, { | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
}); | ||
if (teamsRes.ok) { | ||
return (await teamsRes.json())?.result as Team[]; | ||
} | ||
return []; | ||
} |
This file contains 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 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 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 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 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
Oops, something went wrong.