@tscircuit/fake-snippets 0.0.36 → 0.0.38
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/bun-tests/fake-snippets-api/routes/package_files/create_or_update.test.ts +575 -0
- package/bun-tests/fake-snippets-api/routes/package_files/delete.test.ts +233 -0
- package/bun-tests/fake-snippets-api/routes/snippets/list_newest.test.ts +2 -2
- package/dist/bundle.js +499 -249
- package/dist/index.d.ts +23 -4
- package/dist/index.js +30 -2
- package/fake-snippets-api/lib/db/db-client.ts +29 -1
- package/fake-snippets-api/lib/db/schema.ts +3 -0
- package/fake-snippets-api/routes/api/package_files/create_or_update.ts +179 -0
- package/fake-snippets-api/routes/api/package_files/delete.ts +106 -0
- package/fake-snippets-api/routes/api/snippets/{list_newest.ts → list_latest.ts} +2 -2
- package/package.json +1 -1
- package/scripts/generate-sitemap.ts +1 -1
- package/src/App.tsx +2 -2
- package/src/components/EditorNav.tsx +4 -4
- package/src/components/Footer.tsx +9 -3
- package/src/components/HiddenFilesDropdown.tsx +44 -0
- package/src/components/LatestSnippets.tsx +1 -1
- package/src/components/ViewPackagePage/components/package-header.tsx +0 -4
- package/src/components/ViewPackagePage/components/tab-views/3d-view.tsx +1 -1
- package/src/components/ViewPackagePage/components/tab-views/bom-view.tsx +1 -1
- package/src/components/ViewPackagePage/components/tab-views/files-view.tsx +23 -2
- package/src/components/ViewPackagePage/components/tab-views/schematic-view.tsx +1 -0
- package/src/components/dialogs/confirm-delete-package-dialog.tsx +48 -0
- package/src/hooks/use-delete-package.ts +40 -0
- package/src/hooks/use-fork-package-mutation.ts +14 -61
- package/src/pages/dashboard.tsx +8 -8
- package/src/pages/latest.tsx +212 -0
- package/src/pages/user-profile.tsx +15 -14
- package/src/components/dialogs/confirm-delete-snippet-dialog.tsx +0 -80
- package/src/pages/newest.tsx +0 -16
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "../ui/dialog"
|
|
2
|
-
import { Button } from "../ui/button"
|
|
3
|
-
import { useState } from "react"
|
|
4
|
-
import { createUseDialog } from "./create-use-dialog"
|
|
5
|
-
import { useAxios } from "@/hooks/use-axios"
|
|
6
|
-
import { useToast } from "@/hooks/use-toast"
|
|
7
|
-
import { useQueryClient } from "react-query"
|
|
8
|
-
import { useLocation } from "wouter"
|
|
9
|
-
|
|
10
|
-
export const ConfirmDeleteSnippetDialog = ({
|
|
11
|
-
open,
|
|
12
|
-
onOpenChange,
|
|
13
|
-
snippetId,
|
|
14
|
-
snippetName,
|
|
15
|
-
}: {
|
|
16
|
-
open: boolean
|
|
17
|
-
onOpenChange: (open: boolean) => void
|
|
18
|
-
snippetId: string
|
|
19
|
-
snippetName: string
|
|
20
|
-
}) => {
|
|
21
|
-
const axios = useAxios()
|
|
22
|
-
const { toast } = useToast()
|
|
23
|
-
const qc = useQueryClient()
|
|
24
|
-
const [pending, setPending] = useState(false)
|
|
25
|
-
const [, navigate] = useLocation()
|
|
26
|
-
|
|
27
|
-
const handleDelete = async () => {
|
|
28
|
-
try {
|
|
29
|
-
setPending(true)
|
|
30
|
-
await axios.post("/snippets/delete", {
|
|
31
|
-
snippet_id: snippetId,
|
|
32
|
-
})
|
|
33
|
-
onOpenChange(false)
|
|
34
|
-
setPending(false)
|
|
35
|
-
toast({
|
|
36
|
-
title: "Snippet deleted",
|
|
37
|
-
description: `Successfully deleted "${snippetName}"`,
|
|
38
|
-
})
|
|
39
|
-
qc.invalidateQueries({ queryKey: ["snippets"] })
|
|
40
|
-
navigate("/dashboard")
|
|
41
|
-
} catch (error) {
|
|
42
|
-
console.error("Error deleting snippet:", error)
|
|
43
|
-
toast({
|
|
44
|
-
title: "Error",
|
|
45
|
-
description: "Failed to delete the snippet. Please try again.",
|
|
46
|
-
variant: "destructive",
|
|
47
|
-
})
|
|
48
|
-
} finally {
|
|
49
|
-
setPending(false)
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return (
|
|
54
|
-
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
55
|
-
<DialogContent>
|
|
56
|
-
<DialogHeader>
|
|
57
|
-
<DialogTitle>Confirm Delete Snippet</DialogTitle>
|
|
58
|
-
</DialogHeader>
|
|
59
|
-
<p>Are you sure you want to delete the snippet "{snippetName}"?</p>
|
|
60
|
-
<p>This action cannot be undone.</p>
|
|
61
|
-
<div className="flex justify-end space-x-2 mt-4">
|
|
62
|
-
<Button variant="outline" onClick={() => onOpenChange(false)}>
|
|
63
|
-
Cancel
|
|
64
|
-
</Button>
|
|
65
|
-
<Button
|
|
66
|
-
variant="destructive"
|
|
67
|
-
onClick={handleDelete}
|
|
68
|
-
disabled={pending}
|
|
69
|
-
>
|
|
70
|
-
{pending ? "Deleting..." : "Delete"}
|
|
71
|
-
</Button>
|
|
72
|
-
</div>
|
|
73
|
-
</DialogContent>
|
|
74
|
-
</Dialog>
|
|
75
|
-
)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export const useConfirmDeleteSnippetDialog = createUseDialog(
|
|
79
|
-
ConfirmDeleteSnippetDialog,
|
|
80
|
-
)
|
package/src/pages/newest.tsx
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import Header from "@/components/Header"
|
|
2
|
-
import Footer from "@/components/Footer"
|
|
3
|
-
import { LatestSnippets } from "@/components/LatestSnippets"
|
|
4
|
-
|
|
5
|
-
export const NewestPage = () => {
|
|
6
|
-
return (
|
|
7
|
-
<div>
|
|
8
|
-
<Header />
|
|
9
|
-
<div className="container mx-auto px-4 py-8">
|
|
10
|
-
<h1 className="text-3xl font-bold mb-6">Newest Snippets</h1>
|
|
11
|
-
<LatestSnippets />
|
|
12
|
-
</div>
|
|
13
|
-
<Footer />
|
|
14
|
-
</div>
|
|
15
|
-
)
|
|
16
|
-
}
|