Skip to content

Commit d6f2511

Browse files
authored
Merge branch 'main' into yash/ref-constructor-params
2 parents cd7f779 + 24a53e3 commit d6f2511

File tree

53 files changed

+1806
-1039
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1806
-1039
lines changed

.changeset/eleven-chicken-smile.md

Lines changed: 0 additions & 47 deletions
This file was deleted.

.changeset/fifty-foxes-rescue.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/eight-poems-end.md renamed to .changeset/green-bottles-approve.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"@thirdweb-dev/service-utils": patch
33
---
44

5-
Added nebula service scope
5+
remove nebula scope

.changeset/hot-bees-turn.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/nice-gifts-argue.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/serious-plants-play.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/slimy-pots-camp.md

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"use server";
2+
3+
import { getAuthToken } from "../../app/api/lib/getAuthToken";
4+
import { API_SERVER_URL } from "../constants/env";
5+
6+
export async function joinTeamWaitlist(options: {
7+
teamSlug: string;
8+
// currently only 'nebula' is supported
9+
scope: "nebula";
10+
}) {
11+
const { teamSlug, scope } = options;
12+
const token = await getAuthToken();
13+
14+
if (!token) {
15+
throw new Error("No Auth token");
16+
}
17+
18+
const res = await fetch(`${API_SERVER_URL}/v1/teams/${teamSlug}/waitlist`, {
19+
method: "POST",
20+
headers: {
21+
"Content-Type": "application/json",
22+
Authorization: `Bearer ${token}`,
23+
},
24+
body: JSON.stringify({
25+
scope,
26+
}),
27+
});
28+
29+
if (!res.ok) {
30+
throw new Error("Failed to join waitlist");
31+
}
32+
33+
return true;
34+
}

apps/dashboard/src/@/api/team.ts

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import "server-only";
22
import { COOKIE_ACTIVE_ACCOUNT, COOKIE_PREFIX_TOKEN } from "@/constants/cookie";
33
import { API_SERVER_URL } from "@/constants/env";
44
import { cookies } from "next/headers";
5+
import { getAuthToken } from "../../app/api/lib/getAuthToken";
56

67
export type Team = {
78
id: string;
@@ -18,11 +19,7 @@ export type Team = {
1819
};
1920

2021
export async function getTeamBySlug(slug: string) {
21-
const cookiesManager = await cookies();
22-
const activeAccount = cookiesManager.get(COOKIE_ACTIVE_ACCOUNT)?.value;
23-
const token = activeAccount
24-
? cookiesManager.get(COOKIE_PREFIX_TOKEN + activeAccount)?.value
25-
: null;
22+
const token = await getAuthToken();
2623

2724
if (!token) {
2825
return null;
@@ -60,3 +57,31 @@ export async function getTeams() {
6057
}
6158
return [];
6259
}
60+
61+
type TeamNebulWaitList = {
62+
onWaitlist: boolean;
63+
createdAt: null | string;
64+
};
65+
66+
export async function getTeamNebulaWaitList(teamSlug: string) {
67+
const token = await getAuthToken();
68+
69+
if (!token) {
70+
return null;
71+
}
72+
73+
const res = await fetch(
74+
`${API_SERVER_URL}/v1/teams/${teamSlug}/waitlist?scope=nebula`,
75+
{
76+
headers: {
77+
Authorization: `Bearer ${token}`,
78+
},
79+
},
80+
);
81+
82+
if (res.ok) {
83+
return (await res.json()).result as TeamNebulWaitList;
84+
}
85+
86+
return null;
87+
}
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
"use client";
2+
import { CodeClient } from "@/components/ui/code/code.client";
3+
import type React from "react";
4+
import { type Dispatch, type SetStateAction, useMemo } from "react";
5+
import { TabButtons } from "../ui/tabs";
6+
7+
export type CodeEnvironment =
8+
| "javascript"
9+
| "typescript"
10+
| "react"
11+
| "react-native"
12+
| "unity";
13+
14+
type SupportedEnvironment = {
15+
environment: CodeEnvironment;
16+
title: string;
17+
};
18+
19+
type CodeSnippet = Partial<Record<CodeEnvironment, string>>;
20+
21+
const Environments: SupportedEnvironment[] = [
22+
{
23+
environment: "javascript",
24+
title: "JavaScript",
25+
},
26+
{
27+
environment: "typescript",
28+
title: "TypeScript",
29+
},
30+
{
31+
environment: "react",
32+
title: "React",
33+
},
34+
{
35+
environment: "react-native",
36+
title: "React Native",
37+
},
38+
{
39+
environment: "unity",
40+
title: "Unity",
41+
},
42+
];
43+
44+
interface CodeSegmentProps {
45+
snippet: CodeSnippet;
46+
environment: CodeEnvironment;
47+
setEnvironment:
48+
| Dispatch<SetStateAction<CodeEnvironment>>
49+
| ((language: CodeEnvironment) => void);
50+
isInstallCommand?: boolean;
51+
hideTabs?: boolean;
52+
onlyTabs?: boolean;
53+
}
54+
55+
export const CodeSegment: React.FC<CodeSegmentProps> = ({
56+
snippet,
57+
environment,
58+
setEnvironment,
59+
isInstallCommand,
60+
hideTabs,
61+
onlyTabs,
62+
}) => {
63+
const activeEnvironment: CodeEnvironment = useMemo(() => {
64+
return (
65+
snippet[environment] ? environment : Object.keys(snippet)[0]
66+
) as CodeEnvironment;
67+
}, [environment, snippet]);
68+
69+
const activeSnippet = useMemo(() => {
70+
return snippet[activeEnvironment];
71+
}, [activeEnvironment, snippet]);
72+
73+
const lines = useMemo(
74+
() => (activeSnippet ? activeSnippet.split("\n") : []),
75+
[activeSnippet],
76+
);
77+
78+
const code = lines.join("\n").trim();
79+
80+
const environments = Environments.filter(
81+
(env) =>
82+
Object.keys(snippet).includes(env.environment) &&
83+
snippet[env.environment],
84+
);
85+
86+
return (
87+
<div
88+
className={
89+
"flex flex-col overflow-hidden rounded-lg border border-border"
90+
}
91+
>
92+
{!hideTabs && (
93+
<TabButtons
94+
tabs={environments.map((env) => ({
95+
label: env.title,
96+
onClick: () => setEnvironment(env.environment),
97+
isActive: activeEnvironment === env.environment,
98+
name: env.title,
99+
isEnabled: true,
100+
}))}
101+
tabClassName="text-sm gap-2 !text-sm"
102+
tabIconClassName="size-4"
103+
tabContainerClassName="px-3 pt-1.5 gap-0.5"
104+
hideBottomLine={!!onlyTabs}
105+
/>
106+
)}
107+
108+
{onlyTabs ? null : (
109+
<>
110+
<CodeClient
111+
code={code}
112+
loadingClassName="min-h-[450px] rounded-none border-none"
113+
className="rounded-none border-none"
114+
lang={
115+
isInstallCommand
116+
? activeEnvironment === "react-native"
117+
? "tsx"
118+
: "bash"
119+
: activeEnvironment === "react" ||
120+
activeEnvironment === "react-native"
121+
? "tsx"
122+
: activeEnvironment === "unity"
123+
? "cpp"
124+
: activeEnvironment
125+
}
126+
/>
127+
</>
128+
)}
129+
</div>
130+
);
131+
};

0 commit comments

Comments
 (0)