@tscircuit/fake-snippets 0.0.100 → 0.0.102
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/generated-index.js +23 -1
- package/bun.lock +2 -2
- package/dist/bundle.js +620 -412
- package/dist/index.d.ts +33 -4
- package/dist/index.js +43 -1
- package/dist/schema.d.ts +94 -1
- package/dist/schema.js +17 -1
- package/fake-snippets-api/lib/db/db-client.ts +38 -1
- package/fake-snippets-api/lib/db/schema.ts +15 -0
- package/fake-snippets-api/lib/public-mapping/public-map-package.ts +2 -0
- package/fake-snippets-api/routes/api/accounts/search.ts +20 -0
- package/fake-snippets-api/routes/api/github/installations/create_new_installation_redirect.ts +75 -0
- package/fake-snippets-api/routes/api/github/repos/list_available.ts +91 -0
- package/fake-snippets-api/routes/api/packages/update.ts +4 -0
- package/package.json +2 -2
- package/src/App.tsx +10 -1
- package/src/components/CmdKMenu.tsx +154 -19
- package/src/components/CreateReleaseDialog.tsx +124 -0
- package/src/components/FileSidebar.tsx +128 -23
- package/src/components/Header2.tsx +106 -25
- package/src/components/PackageBuildsPage/package-build-header.tsx +28 -16
- package/src/components/PageSearchComponent.tsx +2 -2
- package/src/components/SearchComponent.tsx +2 -2
- package/src/components/SuspenseRunFrame.tsx +2 -2
- package/src/components/TrendingPackagesCarousel.tsx +2 -2
- package/src/components/ViewPackagePage/components/important-files-view.tsx +18 -13
- package/src/components/ViewPackagePage/components/mobile-sidebar.tsx +1 -0
- package/src/components/ViewPackagePage/components/sidebar-about-section.tsx +1 -0
- package/src/components/dialogs/GitHubRepositorySelector.tsx +123 -0
- package/src/components/dialogs/create-use-dialog.tsx +8 -2
- package/src/components/dialogs/edit-package-details-dialog.tsx +22 -3
- package/src/components/dialogs/view-ts-files-dialog.tsx +178 -33
- package/src/components/package-port/CodeAndPreview.tsx +4 -1
- package/src/components/package-port/CodeEditor.tsx +42 -35
- package/src/components/package-port/CodeEditorHeader.tsx +26 -20
- package/src/components/package-port/EditorNav.tsx +94 -37
- package/src/components/preview/BuildsList.tsx +238 -0
- package/src/components/preview/ConnectedRepoDashboard.tsx +258 -0
- package/src/components/preview/ConnectedRepoOverview.tsx +454 -0
- package/src/components/preview/ConnectedRepoSettings.tsx +343 -0
- package/src/components/preview/ConnectedReposCards.tsx +191 -0
- package/src/components/preview/index.tsx +207 -0
- package/src/components/ui/tree-view.tsx +23 -6
- package/src/hooks/use-axios.ts +2 -2
- package/src/hooks/use-create-release-dialog.ts +160 -0
- package/src/hooks/use-package-details-form.ts +7 -0
- package/src/hooks/use-packages-base-api-url.ts +1 -1
- package/src/hooks/use-sign-in.ts +2 -2
- package/src/hooks/useFileManagement.ts +22 -2
- package/src/index.css +4 -0
- package/src/lib/utils/formatTimeAgo.ts +10 -0
- package/src/lib/utils/isValidFileName.ts +15 -3
- package/src/pages/dashboard.tsx +2 -2
- package/src/pages/dev-login.tsx +2 -2
- package/src/pages/landing.tsx +1 -1
- package/src/pages/latest.tsx +2 -2
- package/src/pages/preview-build.tsx +380 -0
- package/src/pages/search.tsx +2 -2
- package/src/pages/trending.tsx +2 -2
- package/src/pages/user-profile.tsx +32 -24
- package/src/pages/view-connected-repo.tsx +24 -0
package/src/pages/landing.tsx
CHANGED
package/src/pages/latest.tsx
CHANGED
|
@@ -6,7 +6,7 @@ import Header from "@/components/Header"
|
|
|
6
6
|
import Footer from "@/components/Footer"
|
|
7
7
|
import { Search, Keyboard, Cpu, Layers, LucideBellElectric } from "lucide-react"
|
|
8
8
|
import { Input } from "@/components/ui/input"
|
|
9
|
-
import {
|
|
9
|
+
import { useApiBaseUrl } from "@/hooks/use-packages-base-api-url"
|
|
10
10
|
import {
|
|
11
11
|
Select,
|
|
12
12
|
SelectContent,
|
|
@@ -18,7 +18,7 @@ import PackageSearchResults from "@/components/PackageSearchResults"
|
|
|
18
18
|
|
|
19
19
|
const LatestPage: React.FC = () => {
|
|
20
20
|
const axios = useAxios()
|
|
21
|
-
const apiBaseUrl =
|
|
21
|
+
const apiBaseUrl = useApiBaseUrl()
|
|
22
22
|
const [searchQuery, setSearchQuery] = useState("")
|
|
23
23
|
const [category, setCategory] = useState("all")
|
|
24
24
|
|
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
import { useState } from "react"
|
|
2
|
+
import { useParams } from "wouter"
|
|
3
|
+
import { Loader2, ChevronLeft, ChevronRight, File, Folder } from "lucide-react"
|
|
4
|
+
import Header from "@/components/Header"
|
|
5
|
+
import { SuspenseRunFrame } from "@/components/SuspenseRunFrame"
|
|
6
|
+
import { TreeView, TreeDataItem } from "@/components/ui/tree-view"
|
|
7
|
+
import { cn } from "@/lib/utils"
|
|
8
|
+
import { PrefetchPageLink } from "@/components/PrefetchPageLink"
|
|
9
|
+
import NotFoundPage from "./404"
|
|
10
|
+
import { getBuildStatus, MOCK_DEPLOYMENTS } from "@/components/preview"
|
|
11
|
+
|
|
12
|
+
const MOCK_DEPLOYMENT_FILES: Record<
|
|
13
|
+
string,
|
|
14
|
+
Array<{ path: string; content: string }>
|
|
15
|
+
> = {
|
|
16
|
+
pb_1a2b3c4d: [
|
|
17
|
+
{
|
|
18
|
+
path: "index.tsx",
|
|
19
|
+
content: `export default () => (
|
|
20
|
+
<board width="10mm" height="10mm">
|
|
21
|
+
<resistor
|
|
22
|
+
resistance="1k"
|
|
23
|
+
footprint="0402"
|
|
24
|
+
name="R1"
|
|
25
|
+
schX={3}
|
|
26
|
+
pcbX={3}
|
|
27
|
+
/>
|
|
28
|
+
<capacitor
|
|
29
|
+
capacitance="1000pF"
|
|
30
|
+
footprint="0402"
|
|
31
|
+
name="C1"
|
|
32
|
+
schX={-3}
|
|
33
|
+
pcbX={-3}
|
|
34
|
+
/>
|
|
35
|
+
<trace from=".R1 > .pin1" to=".C1 > .pin1" />
|
|
36
|
+
</board>
|
|
37
|
+
)`,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
path: "components/Button.tsx",
|
|
41
|
+
content: `export default () => (
|
|
42
|
+
<board width="10mm" height="10mm">
|
|
43
|
+
<resistor
|
|
44
|
+
resistance="1k"
|
|
45
|
+
footprint="0402"
|
|
46
|
+
name="R1"
|
|
47
|
+
schX={3}
|
|
48
|
+
pcbX={3}
|
|
49
|
+
/>
|
|
50
|
+
<capacitor
|
|
51
|
+
capacitance="1000pF"
|
|
52
|
+
footprint="0402"
|
|
53
|
+
name="C1"
|
|
54
|
+
schX={-3}
|
|
55
|
+
pcbX={-3}
|
|
56
|
+
/>
|
|
57
|
+
<trace from=".R1 > .pin1" to=".C1 > .pin1" />
|
|
58
|
+
</board>
|
|
59
|
+
)`,
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
pb_9i8j7k6l: [
|
|
63
|
+
{
|
|
64
|
+
path: "index.tsx",
|
|
65
|
+
content: `export default () => (
|
|
66
|
+
<board width="10mm" height="10mm">
|
|
67
|
+
<resistor
|
|
68
|
+
resistance="1k"
|
|
69
|
+
footprint="0402"
|
|
70
|
+
name="R1"
|
|
71
|
+
schX={3}
|
|
72
|
+
pcbX={3}
|
|
73
|
+
/>
|
|
74
|
+
<capacitor
|
|
75
|
+
capacitance="1000pF"
|
|
76
|
+
footprint="0402"
|
|
77
|
+
name="C1"
|
|
78
|
+
schX={-3}
|
|
79
|
+
pcbX={-3}
|
|
80
|
+
/>
|
|
81
|
+
<trace from=".R1 > .pin1" to=".C1 > .pin1" />
|
|
82
|
+
</board>
|
|
83
|
+
)`,
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
path: "utils/helpers.ts",
|
|
87
|
+
content: `export default () => (
|
|
88
|
+
<board width="10mm" height="10mm">
|
|
89
|
+
<resistor
|
|
90
|
+
resistance="1k"
|
|
91
|
+
footprint="0402"
|
|
92
|
+
name="R1"
|
|
93
|
+
schX={3}
|
|
94
|
+
pcbX={3}
|
|
95
|
+
/>
|
|
96
|
+
<capacitor
|
|
97
|
+
capacitance="1000pF"
|
|
98
|
+
footprint="0402"
|
|
99
|
+
name="C1"
|
|
100
|
+
schX={-3}
|
|
101
|
+
pcbX={-3}
|
|
102
|
+
/>
|
|
103
|
+
<trace from=".R1 > .pin1" to=".C1 > .pin1" />
|
|
104
|
+
</board>
|
|
105
|
+
)`,
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
pb_1q2w3e4r: [
|
|
109
|
+
{
|
|
110
|
+
path: "index.tsx",
|
|
111
|
+
content: `export default () => (
|
|
112
|
+
<board width="10mm" height="10mm">
|
|
113
|
+
<resistor
|
|
114
|
+
resistance="1k"
|
|
115
|
+
footprint="0402"
|
|
116
|
+
name="R1"
|
|
117
|
+
schX={3}
|
|
118
|
+
pcbX={3}
|
|
119
|
+
/>
|
|
120
|
+
<capacitor
|
|
121
|
+
capacitance="1000pF"
|
|
122
|
+
footprint="0402"
|
|
123
|
+
name="C1"
|
|
124
|
+
schX={-3}
|
|
125
|
+
pcbX={-3}
|
|
126
|
+
/>
|
|
127
|
+
<trace from=".R1 > .pin1" to=".C1 > .pin1" />
|
|
128
|
+
</board>
|
|
129
|
+
)`,
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
pb_9o8i7u6y: [
|
|
133
|
+
{
|
|
134
|
+
path: "index.tsx",
|
|
135
|
+
content: `export default () => (
|
|
136
|
+
<board width="10mm" height="10mm">
|
|
137
|
+
<resistor
|
|
138
|
+
resistance="1k"
|
|
139
|
+
footprint="0402"
|
|
140
|
+
name="R1"
|
|
141
|
+
schX={3}
|
|
142
|
+
pcbX={3}
|
|
143
|
+
/>
|
|
144
|
+
<capacitor
|
|
145
|
+
capacitance="1000pF"
|
|
146
|
+
footprint="0402"
|
|
147
|
+
name="C1"
|
|
148
|
+
schX={-3}
|
|
149
|
+
pcbX={-3}
|
|
150
|
+
/>
|
|
151
|
+
<trace from=".R1 > .pin1" to=".C1 > .pin1" />
|
|
152
|
+
</board>
|
|
153
|
+
)`,
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const getBuildFiles = (buildId: string | null) => {
|
|
159
|
+
if (!buildId) return []
|
|
160
|
+
return MOCK_DEPLOYMENT_FILES[buildId] || []
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const getBuildFsMap = (buildId: string | null) => {
|
|
164
|
+
const files = getBuildFiles(buildId)
|
|
165
|
+
return Object.fromEntries(files.map((f) => [f.path, f.content]))
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const StatusPill = ({ status }: { status: string }) => {
|
|
169
|
+
const color =
|
|
170
|
+
status === "success"
|
|
171
|
+
? "bg-emerald-600"
|
|
172
|
+
: status === "failed"
|
|
173
|
+
? "bg-red-600"
|
|
174
|
+
: status === "building"
|
|
175
|
+
? "bg-blue-600 animate-pulse"
|
|
176
|
+
: "bg-gray-500"
|
|
177
|
+
return <span className={cn("inline-block w-2 h-2 rounded-full", color)} />
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export default function PreviewBuildPage() {
|
|
181
|
+
const params = useParams<{ buildId: string }>()
|
|
182
|
+
const buildId = params?.buildId || null
|
|
183
|
+
|
|
184
|
+
const [sidebarCollapsed, setSidebarCollapsed] = useState(false)
|
|
185
|
+
const [selectedFile, setSelectedFile] = useState<string | null>("index.tsx")
|
|
186
|
+
const [selectedItemId, setSelectedItemId] = useState<string>("")
|
|
187
|
+
|
|
188
|
+
const buildFiles = getBuildFiles(buildId)
|
|
189
|
+
const buildFsMap = getBuildFsMap(buildId)
|
|
190
|
+
|
|
191
|
+
const build = buildId
|
|
192
|
+
? MOCK_DEPLOYMENTS.find((d) => d.package_build_id === buildId)
|
|
193
|
+
: MOCK_DEPLOYMENTS[0]
|
|
194
|
+
|
|
195
|
+
if (!build) {
|
|
196
|
+
return <NotFoundPage heading="Build Not Found" />
|
|
197
|
+
}
|
|
198
|
+
const { status, label } = getBuildStatus(build)
|
|
199
|
+
const convertFilesToTreeData = (
|
|
200
|
+
files: Array<{ path: string; content: string }>,
|
|
201
|
+
): TreeDataItem[] => {
|
|
202
|
+
const tree: TreeDataItem[] = []
|
|
203
|
+
const pathMap = new Map<string, TreeDataItem>()
|
|
204
|
+
|
|
205
|
+
files.forEach((file) => {
|
|
206
|
+
const parts = file.path.split("/")
|
|
207
|
+
let currentPath = ""
|
|
208
|
+
|
|
209
|
+
parts.forEach((part, index) => {
|
|
210
|
+
const isLast = index === parts.length - 1
|
|
211
|
+
currentPath = currentPath ? `${currentPath}/${part}` : part
|
|
212
|
+
|
|
213
|
+
if (!pathMap.has(currentPath)) {
|
|
214
|
+
const item: TreeDataItem = {
|
|
215
|
+
id: currentPath,
|
|
216
|
+
name: part,
|
|
217
|
+
icon: isLast ? File : Folder,
|
|
218
|
+
children: isLast ? undefined : [],
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
pathMap.set(currentPath, item)
|
|
222
|
+
|
|
223
|
+
if (index === 0) {
|
|
224
|
+
tree.push(item)
|
|
225
|
+
} else {
|
|
226
|
+
const parentPath = parts.slice(0, index).join("/")
|
|
227
|
+
const parent = pathMap.get(parentPath)
|
|
228
|
+
if (parent && parent.children) {
|
|
229
|
+
parent.children.push(item)
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
})
|
|
234
|
+
})
|
|
235
|
+
|
|
236
|
+
return tree
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const treeData = convertFilesToTreeData(buildFiles)
|
|
240
|
+
|
|
241
|
+
return (
|
|
242
|
+
<>
|
|
243
|
+
<Header />
|
|
244
|
+
<div className="flex flex-col h-screen overflow-hidden !-mt-1">
|
|
245
|
+
<div className="flex flex-1 overflow-hidden">
|
|
246
|
+
<aside
|
|
247
|
+
className={cn(
|
|
248
|
+
"relative border-r border-gray-200 rounded-r-lg z-[5] h-full transition-all duration-300 ease-in-out bg-white",
|
|
249
|
+
sidebarCollapsed ? "w-3" : "w-80",
|
|
250
|
+
)}
|
|
251
|
+
>
|
|
252
|
+
<button
|
|
253
|
+
onClick={() => setSidebarCollapsed(!sidebarCollapsed)}
|
|
254
|
+
className="absolute top-4 -right-3 z-10 bg-white border border-gray-200 rounded-full p-1 hover:bg-gray-50"
|
|
255
|
+
>
|
|
256
|
+
{sidebarCollapsed ? (
|
|
257
|
+
<ChevronRight size={20} />
|
|
258
|
+
) : (
|
|
259
|
+
<ChevronLeft size={20} />
|
|
260
|
+
)}
|
|
261
|
+
</button>
|
|
262
|
+
|
|
263
|
+
{!sidebarCollapsed && (
|
|
264
|
+
<>
|
|
265
|
+
<div className="p-4 border-b border-gray-200">
|
|
266
|
+
<div className="space-y-3">
|
|
267
|
+
<div className="flex items-center justify-between">
|
|
268
|
+
<h2 className="text-lg font-semibold text-gray-900">
|
|
269
|
+
Deployment
|
|
270
|
+
</h2>
|
|
271
|
+
<StatusPill status={status} />
|
|
272
|
+
</div>
|
|
273
|
+
|
|
274
|
+
<div className="space-y-2">
|
|
275
|
+
<div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2">
|
|
276
|
+
<span className="text-xs text-gray-500 uppercase tracking-wide">
|
|
277
|
+
ID
|
|
278
|
+
</span>
|
|
279
|
+
<PrefetchPageLink
|
|
280
|
+
href={`/build/${build.package_build_id}`}
|
|
281
|
+
className="font-mono text-sm text-gray-900 bg-gray-100 px-2 py-1 rounded"
|
|
282
|
+
>
|
|
283
|
+
{build.package_build_id}
|
|
284
|
+
</PrefetchPageLink>
|
|
285
|
+
</div>
|
|
286
|
+
|
|
287
|
+
<div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2">
|
|
288
|
+
<span className="text-xs text-gray-500 uppercase tracking-wide">
|
|
289
|
+
Commit
|
|
290
|
+
</span>
|
|
291
|
+
<PrefetchPageLink
|
|
292
|
+
href={`https://github.com/${build.commit_author}/tscircuit.com/commit/${build.commit_message}`}
|
|
293
|
+
className="font-mono text-xs text-gray-600 bg-gray-50 px-2 text-right py-1 rounded line-clamp-1"
|
|
294
|
+
>
|
|
295
|
+
{build.commit_message}
|
|
296
|
+
</PrefetchPageLink>
|
|
297
|
+
</div>
|
|
298
|
+
|
|
299
|
+
<div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2">
|
|
300
|
+
<span className="text-xs text-gray-500 uppercase tracking-wide">
|
|
301
|
+
Status
|
|
302
|
+
</span>
|
|
303
|
+
<span
|
|
304
|
+
className={`text-xs font-medium px-2 py-1 rounded-full capitalize ${
|
|
305
|
+
status === "success"
|
|
306
|
+
? "bg-emerald-100 text-emerald-800"
|
|
307
|
+
: status === "failed"
|
|
308
|
+
? "bg-red-100 text-red-800"
|
|
309
|
+
: status === "building"
|
|
310
|
+
? "bg-blue-100 text-blue-800"
|
|
311
|
+
: "bg-gray-100 text-gray-800"
|
|
312
|
+
}`}
|
|
313
|
+
>
|
|
314
|
+
{status}
|
|
315
|
+
</span>
|
|
316
|
+
</div>
|
|
317
|
+
</div>
|
|
318
|
+
</div>
|
|
319
|
+
</div>
|
|
320
|
+
|
|
321
|
+
<div className="flex-1 overflow-hidden">
|
|
322
|
+
<div className="px-4 py-3 border-b border-gray-200">
|
|
323
|
+
<h3 className="text-sm font-semibold text-gray-900">
|
|
324
|
+
Files
|
|
325
|
+
</h3>
|
|
326
|
+
<p className="text-xs text-gray-500 mt-1">
|
|
327
|
+
{buildFiles.length} file
|
|
328
|
+
{buildFiles.length !== 1 ? "s" : ""}
|
|
329
|
+
</p>
|
|
330
|
+
</div>
|
|
331
|
+
<div className="px-2 py-2 overflow-y-auto select-none">
|
|
332
|
+
<TreeView
|
|
333
|
+
selectedItemId={selectedItemId || ""}
|
|
334
|
+
setSelectedItemId={(v) => setSelectedItemId(v || "")}
|
|
335
|
+
data={treeData}
|
|
336
|
+
className="w-full"
|
|
337
|
+
onSelectChange={(item) => {
|
|
338
|
+
if (item && !item.children) {
|
|
339
|
+
setSelectedFile(item.id)
|
|
340
|
+
}
|
|
341
|
+
}}
|
|
342
|
+
/>
|
|
343
|
+
</div>
|
|
344
|
+
</div>
|
|
345
|
+
</>
|
|
346
|
+
)}
|
|
347
|
+
</aside>
|
|
348
|
+
|
|
349
|
+
<main className="flex-1 overflow-y-auto">
|
|
350
|
+
<div className="flex flex-col h-full overflow-h-hidden">
|
|
351
|
+
{status === "success" ? (
|
|
352
|
+
<SuspenseRunFrame
|
|
353
|
+
fsMap={buildFsMap}
|
|
354
|
+
mainComponentPath={selectedFile ?? "index.tsx"}
|
|
355
|
+
showRunButton={false}
|
|
356
|
+
className="[&>div]:overflow-y-hidden"
|
|
357
|
+
/>
|
|
358
|
+
) : (
|
|
359
|
+
<div className="flex-1 flex items-center justify-center">
|
|
360
|
+
{status === "building" ? (
|
|
361
|
+
<div className="flex flex-col items-center gap-3 text-gray-500">
|
|
362
|
+
<Loader2 className="w-6 h-6 animate-spin" />
|
|
363
|
+
<p>Building…</p>
|
|
364
|
+
</div>
|
|
365
|
+
) : status === "failed" ? (
|
|
366
|
+
<div className="text-center">
|
|
367
|
+
<p className="text-red-600 font-medium mb-2">
|
|
368
|
+
Build Failed
|
|
369
|
+
</p>
|
|
370
|
+
</div>
|
|
371
|
+
) : null}
|
|
372
|
+
</div>
|
|
373
|
+
)}
|
|
374
|
+
</div>
|
|
375
|
+
</main>
|
|
376
|
+
</div>
|
|
377
|
+
</div>
|
|
378
|
+
</>
|
|
379
|
+
)
|
|
380
|
+
}
|
package/src/pages/search.tsx
CHANGED
|
@@ -7,7 +7,7 @@ import Footer from "@/components/Footer"
|
|
|
7
7
|
import { Input } from "@/components/ui/input"
|
|
8
8
|
import { Search } from "lucide-react"
|
|
9
9
|
import PackageSearchResults from "@/components/PackageSearchResults"
|
|
10
|
-
import {
|
|
10
|
+
import { useApiBaseUrl } from "@/hooks/use-packages-base-api-url"
|
|
11
11
|
import {
|
|
12
12
|
Select,
|
|
13
13
|
SelectContent,
|
|
@@ -19,7 +19,7 @@ import { Package } from "fake-snippets-api/lib/db/schema"
|
|
|
19
19
|
|
|
20
20
|
export const SearchPage = () => {
|
|
21
21
|
const axios = useAxios()
|
|
22
|
-
const apiBaseUrl =
|
|
22
|
+
const apiBaseUrl = useApiBaseUrl()
|
|
23
23
|
const [searchParams, setSearchParams] = useSearchParams()
|
|
24
24
|
|
|
25
25
|
const [searchQuery, setSearchQuery] = useState(searchParams.get("q") || "")
|
package/src/pages/trending.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import { useAxios } from "@/hooks/use-axios"
|
|
|
4
4
|
import Header from "@/components/Header"
|
|
5
5
|
import Footer from "@/components/Footer"
|
|
6
6
|
import { useSearchParams } from "wouter"
|
|
7
|
-
import {
|
|
7
|
+
import { useApiBaseUrl } from "@/hooks/use-packages-base-api-url"
|
|
8
8
|
import { Search, Keyboard, Cpu, Layers, LucideBellElectric } from "lucide-react"
|
|
9
9
|
import { Input } from "@/components/ui/input"
|
|
10
10
|
import {
|
|
@@ -19,7 +19,7 @@ import PackageSearchResults from "@/components/PackageSearchResults"
|
|
|
19
19
|
|
|
20
20
|
const TrendingPage: React.FC = () => {
|
|
21
21
|
const axios = useAxios()
|
|
22
|
-
const apiBaseUrl =
|
|
22
|
+
const apiBaseUrl = useApiBaseUrl()
|
|
23
23
|
const [searchParams, setSearchParams] = useSearchParams()
|
|
24
24
|
|
|
25
25
|
const [searchQuery, setSearchQuery] = useState(searchParams.get("q") || "")
|
|
@@ -8,7 +8,7 @@ import { Input } from "@/components/ui/input"
|
|
|
8
8
|
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"
|
|
9
9
|
import { useAxios } from "@/hooks/use-axios"
|
|
10
10
|
import { useGlobalStore } from "@/hooks/use-global-store"
|
|
11
|
-
import {
|
|
11
|
+
import { useApiBaseUrl } from "@/hooks/use-packages-base-api-url"
|
|
12
12
|
import { GitHubLogoIcon } from "@radix-ui/react-icons"
|
|
13
13
|
import type { Package } from "fake-snippets-api/lib/db/schema"
|
|
14
14
|
import type React from "react"
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
} from "@/components/ui/select"
|
|
26
26
|
import { Box, Star } from "lucide-react"
|
|
27
27
|
import { PackageCardSkeleton } from "@/components/PackageCardSkeleton"
|
|
28
|
+
import { ConnectedReposCards } from "@/components/preview/ConnectedReposCards"
|
|
28
29
|
|
|
29
30
|
export const UserProfilePage = () => {
|
|
30
31
|
const { username } = useParams()
|
|
@@ -95,7 +96,7 @@ export const UserProfilePage = () => {
|
|
|
95
96
|
},
|
|
96
97
|
)
|
|
97
98
|
|
|
98
|
-
const baseUrl =
|
|
99
|
+
const baseUrl = useApiBaseUrl()
|
|
99
100
|
|
|
100
101
|
if (accountError) {
|
|
101
102
|
return <NotFoundPage heading="User Not Found" />
|
|
@@ -178,30 +179,37 @@ export const UserProfilePage = () => {
|
|
|
178
179
|
<TabsList>
|
|
179
180
|
<TabsTrigger value="all">Packages</TabsTrigger>
|
|
180
181
|
<TabsTrigger value="starred">Starred Packages</TabsTrigger>
|
|
182
|
+
{isCurrentUserProfile && (
|
|
183
|
+
<TabsTrigger value="repos">Connected Repositories</TabsTrigger>
|
|
184
|
+
)}
|
|
181
185
|
</TabsList>
|
|
182
186
|
</Tabs>
|
|
183
|
-
|
|
184
|
-
<
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
<
|
|
193
|
-
<
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
<
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
187
|
+
{activeTab !== "repos" && (
|
|
188
|
+
<div className="flex gap-4 mb-4">
|
|
189
|
+
<Input
|
|
190
|
+
type="text"
|
|
191
|
+
placeholder="Searching User Packages..."
|
|
192
|
+
value={searchQuery}
|
|
193
|
+
onChange={(e) => setSearchQuery(e.target.value)}
|
|
194
|
+
className="mb-4"
|
|
195
|
+
/>
|
|
196
|
+
<Select value={filter} onValueChange={setFilter}>
|
|
197
|
+
<SelectTrigger className="w-[180px]">
|
|
198
|
+
<SelectValue placeholder="Sort by" />
|
|
199
|
+
</SelectTrigger>
|
|
200
|
+
<SelectContent>
|
|
201
|
+
<SelectItem value="most-recent">Most Recent</SelectItem>
|
|
202
|
+
<SelectItem value="least-recent">Least Recent</SelectItem>
|
|
203
|
+
<SelectItem value="most-starred">Most Starred</SelectItem>
|
|
204
|
+
<SelectItem value="a-z">A-Z</SelectItem>
|
|
205
|
+
<SelectItem value="z-a">Z-A</SelectItem>
|
|
206
|
+
</SelectContent>
|
|
207
|
+
</Select>
|
|
208
|
+
</div>
|
|
209
|
+
)}
|
|
210
|
+
{activeTab === "repos" ? (
|
|
211
|
+
<ConnectedReposCards user={String(githubUsername)} />
|
|
212
|
+
) : isLoading ? (
|
|
205
213
|
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
|
|
206
214
|
{[...Array(6)].map((_, i) => (
|
|
207
215
|
<PackageCardSkeleton key={i} />
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useParams } from "wouter"
|
|
2
|
+
import NotFoundPage from "./404"
|
|
3
|
+
import { ConnectedRepoDashboard, MOCK_DEPLOYMENTS } from "@/components/preview"
|
|
4
|
+
|
|
5
|
+
export default function ViewConnectedRepoOverview() {
|
|
6
|
+
const params = useParams<{ buildId: string }>()
|
|
7
|
+
const buildId = params?.buildId || null
|
|
8
|
+
|
|
9
|
+
const selectedBuild = buildId
|
|
10
|
+
? MOCK_DEPLOYMENTS.find((d) => d.package_build_id === buildId)
|
|
11
|
+
: MOCK_DEPLOYMENTS[0]
|
|
12
|
+
|
|
13
|
+
if (!selectedBuild) {
|
|
14
|
+
return <NotFoundPage heading="Build Not Found" />
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<ConnectedRepoDashboard
|
|
19
|
+
projectName="tscircuit-project"
|
|
20
|
+
builds={MOCK_DEPLOYMENTS}
|
|
21
|
+
selectedBuild={selectedBuild}
|
|
22
|
+
/>
|
|
23
|
+
)
|
|
24
|
+
}
|