@tscircuit/fake-snippets 0.0.94 → 0.0.95
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 +32 -0
- package/bun-tests/fake-snippets-api/routes/datasheets/get.test.ts +12 -0
- package/dist/bundle.js +4 -2
- package/dist/index.js +3 -1
- package/fake-snippets-api/lib/db/db-client.ts +3 -1
- package/package.json +1 -1
- package/src/App.tsx +2 -0
- package/src/pages/datasheets.tsx +80 -0
package/dist/index.js
CHANGED
|
@@ -3129,7 +3129,9 @@ var initializer = combine(databaseSchema.parse({}), (set, get) => ({
|
|
|
3129
3129
|
},
|
|
3130
3130
|
getDatasheetByChipName: (chipName) => {
|
|
3131
3131
|
const state = get();
|
|
3132
|
-
return state.datasheets.find(
|
|
3132
|
+
return state.datasheets.find(
|
|
3133
|
+
(d) => d.chip_name.toLowerCase() === chipName.toLowerCase()
|
|
3134
|
+
);
|
|
3133
3135
|
},
|
|
3134
3136
|
listDatasheets: ({
|
|
3135
3137
|
chip_name,
|
|
@@ -1399,7 +1399,9 @@ const initializer = combine(databaseSchema.parse({}), (set, get) => ({
|
|
|
1399
1399
|
},
|
|
1400
1400
|
getDatasheetByChipName: (chipName: string): Datasheet | undefined => {
|
|
1401
1401
|
const state = get()
|
|
1402
|
-
return state.datasheets.find(
|
|
1402
|
+
return state.datasheets.find(
|
|
1403
|
+
(d) => d.chip_name.toLowerCase() === chipName.toLowerCase(),
|
|
1404
|
+
)
|
|
1403
1405
|
},
|
|
1404
1406
|
listDatasheets: ({
|
|
1405
1407
|
chip_name,
|
package/package.json
CHANGED
package/src/App.tsx
CHANGED
|
@@ -69,6 +69,7 @@ const ViewPackagePage = lazyImport(() => import("@/pages/view-package"))
|
|
|
69
69
|
const PackageBuildsPage = lazyImport(() => import("@/pages/package-builds"))
|
|
70
70
|
const TrendingPage = lazyImport(() => import("@/pages/trending"))
|
|
71
71
|
const DatasheetPage = lazyImport(() => import("@/pages/datasheet"))
|
|
72
|
+
const DatasheetsPage = lazyImport(() => import("@/pages/datasheets"))
|
|
72
73
|
const PackageEditorPage = lazyImport(async () => {
|
|
73
74
|
const [editorModule] = await Promise.all([
|
|
74
75
|
import("@/pages/package-editor"),
|
|
@@ -181,6 +182,7 @@ function App() {
|
|
|
181
182
|
<Route path="/settings" component={SettingsPage} />
|
|
182
183
|
<Route path="/search" component={SearchPage} />
|
|
183
184
|
<Route path="/trending" component={TrendingPage} />
|
|
185
|
+
<Route path="/datasheets" component={DatasheetsPage} />
|
|
184
186
|
<Route path="/datasheets/:chipName" component={DatasheetPage} />
|
|
185
187
|
<Route path="/authorize" component={AuthenticatePage} />
|
|
186
188
|
<Route path="/my-orders" component={MyOrdersPage} />
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import React, { useState } from "react"
|
|
2
|
+
import { useQuery } from "react-query"
|
|
3
|
+
import { useAxios } from "@/hooks/use-axios"
|
|
4
|
+
import Header from "@/components/Header"
|
|
5
|
+
import Footer from "@/components/Footer"
|
|
6
|
+
import { Input } from "@/components/ui/input"
|
|
7
|
+
import { Search } from "lucide-react"
|
|
8
|
+
import { Link } from "wouter"
|
|
9
|
+
|
|
10
|
+
interface DatasheetSummary {
|
|
11
|
+
datasheet_id: string
|
|
12
|
+
chip_name: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const DatasheetsPage: React.FC = () => {
|
|
16
|
+
const axios = useAxios()
|
|
17
|
+
const [searchQuery, setSearchQuery] = useState("")
|
|
18
|
+
|
|
19
|
+
const {
|
|
20
|
+
data: datasheets,
|
|
21
|
+
isLoading,
|
|
22
|
+
error,
|
|
23
|
+
} = useQuery(
|
|
24
|
+
["datasheetList", searchQuery],
|
|
25
|
+
async () => {
|
|
26
|
+
const params = new URLSearchParams()
|
|
27
|
+
if (searchQuery) {
|
|
28
|
+
params.append("chip_name", searchQuery)
|
|
29
|
+
} else {
|
|
30
|
+
params.append("is_popular", "true")
|
|
31
|
+
}
|
|
32
|
+
const { data } = await axios.get(
|
|
33
|
+
`/api/datasheets/list?${params.toString()}`,
|
|
34
|
+
)
|
|
35
|
+
return data.datasheets as DatasheetSummary[]
|
|
36
|
+
},
|
|
37
|
+
{ keepPreviousData: true },
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<div className="min-h-screen flex flex-col">
|
|
42
|
+
<Header />
|
|
43
|
+
<main className="container mx-auto flex-1 px-4 py-8">
|
|
44
|
+
<h1 className="text-3xl font-bold mb-6">Datasheets</h1>
|
|
45
|
+
<div className="max-w-md mb-6">
|
|
46
|
+
<div className="relative">
|
|
47
|
+
<Search className="absolute left-3 top-1/2 -translate-y-1/2 text-gray-400 h-4 w-4" />
|
|
48
|
+
<Input
|
|
49
|
+
type="search"
|
|
50
|
+
placeholder="Search datasheets..."
|
|
51
|
+
className="pl-10"
|
|
52
|
+
value={searchQuery}
|
|
53
|
+
onChange={(e) => setSearchQuery(e.target.value)}
|
|
54
|
+
aria-label="Search datasheets"
|
|
55
|
+
role="searchbox"
|
|
56
|
+
/>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
{isLoading ? (
|
|
60
|
+
<p>Loading...</p>
|
|
61
|
+
) : error ? (
|
|
62
|
+
<p>Error loading datasheets.</p>
|
|
63
|
+
) : datasheets && datasheets.length > 0 ? (
|
|
64
|
+
<ul className="list-disc pl-5 space-y-2">
|
|
65
|
+
{datasheets.map((ds) => (
|
|
66
|
+
<li key={ds.datasheet_id}>
|
|
67
|
+
<Link href={`/datasheets/${ds.chip_name}`}>{ds.chip_name}</Link>
|
|
68
|
+
</li>
|
|
69
|
+
))}
|
|
70
|
+
</ul>
|
|
71
|
+
) : (
|
|
72
|
+
<p>No datasheets found.</p>
|
|
73
|
+
)}
|
|
74
|
+
</main>
|
|
75
|
+
<Footer />
|
|
76
|
+
</div>
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export default DatasheetsPage
|