@tscircuit/fake-snippets 0.0.67 → 0.0.69
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/packages/update.test.ts +104 -0
- package/bun.lock +26 -83
- package/dist/bundle.js +17 -5
- package/dist/index.d.ts +5 -0
- package/dist/index.js +2 -1
- package/dist/schema.d.ts +8 -0
- package/dist/schema.js +2 -1
- package/fake-snippets-api/lib/db/schema.ts +4 -0
- package/fake-snippets-api/routes/api/packages/create.ts +1 -0
- package/fake-snippets-api/routes/api/packages/update.ts +11 -2
- package/package.json +3 -4
- package/src/App.tsx +0 -4
- package/src/components/CmdKMenu.tsx +19 -19
- package/src/components/FAQ.tsx +3 -1
- package/src/components/FileSidebar.tsx +50 -1
- package/src/components/Header2.tsx +20 -9
- package/src/components/JLCPCBImportDialog.tsx +13 -16
- package/src/components/ViewPackagePage/components/important-files-view.tsx +1 -1
- package/src/components/ViewPackagePage/components/mobile-sidebar.tsx +1 -0
- package/src/components/ViewPackagePage/components/package-header.tsx +22 -12
- package/src/components/ViewPackagePage/components/repo-page-content.tsx +23 -7
- package/src/components/ViewPackagePage/components/sidebar-about-section.tsx +1 -0
- package/src/components/dialogs/confirm-delete-package-dialog.tsx +8 -0
- package/src/components/dialogs/edit-package-details-dialog.tsx +177 -139
- package/src/components/package-port/CodeAndPreview.tsx +40 -19
- package/src/components/package-port/CodeEditor.tsx +8 -27
- package/src/components/package-port/EditorNav.tsx +1 -11
- package/src/hooks/use-package-details-form.ts +15 -1
- package/src/hooks/useFileManagement.ts +59 -0
- package/src/index.css +13 -0
- package/src/lib/utils/isValidFileName.ts +5 -0
- package/src/pages/dashboard.tsx +1 -0
- package/src/pages/quickstart.tsx +5 -5
- package/src/pages/search.tsx +1 -1
- package/src/pages/user-profile.tsx +1 -0
- package/src/components/OrderPreviewContent.tsx +0 -61
- package/src/components/ViewSnippetSidebar.tsx +0 -162
- package/src/components/dialogs/create-order-dialog.tsx +0 -146
- package/src/pages/preview.tsx +0 -44
- package/src/pages/view-order.tsx +0 -111
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "../ui/dialog"
|
|
2
|
-
import { Button } from "../ui/button"
|
|
3
|
-
import { Checkbox } from "../ui/checkbox"
|
|
4
|
-
import { useState, useEffect } from "react"
|
|
5
|
-
import { createUseDialog } from "./create-use-dialog"
|
|
6
|
-
import { useAxios } from "@/hooks/use-axios"
|
|
7
|
-
import { useToast } from "@/hooks/use-toast"
|
|
8
|
-
import { useQueryClient } from "react-query"
|
|
9
|
-
|
|
10
|
-
export const CreateOrderDialog = ({
|
|
11
|
-
open,
|
|
12
|
-
onOpenChange,
|
|
13
|
-
}: {
|
|
14
|
-
open: boolean
|
|
15
|
-
onOpenChange: (open: boolean) => void
|
|
16
|
-
}) => {
|
|
17
|
-
const axios = useAxios()
|
|
18
|
-
const { toast } = useToast()
|
|
19
|
-
const qc = useQueryClient()
|
|
20
|
-
const [pending, setPending] = useState(false)
|
|
21
|
-
const [checkpoints, setCheckpoints] = useState({
|
|
22
|
-
shipping: false,
|
|
23
|
-
errors: false,
|
|
24
|
-
parts: false,
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
if (open) {
|
|
29
|
-
validateCheckpoints()
|
|
30
|
-
}
|
|
31
|
-
}, [open])
|
|
32
|
-
|
|
33
|
-
const validateCheckpoints = async () => {
|
|
34
|
-
try {
|
|
35
|
-
// Placeholder: Check if shipping information is in profile
|
|
36
|
-
const hasShippingInfo = await checkShippingInfo()
|
|
37
|
-
|
|
38
|
-
// Placeholder: Check if PCB has no errors
|
|
39
|
-
const hasNoErrors = await checkPCBErrors()
|
|
40
|
-
|
|
41
|
-
// Placeholder: Check if all parts are available at PCB fab
|
|
42
|
-
const allPartsAvailable = await checkPartsAvailability()
|
|
43
|
-
|
|
44
|
-
setCheckpoints({
|
|
45
|
-
shipping: hasShippingInfo,
|
|
46
|
-
errors: hasNoErrors,
|
|
47
|
-
parts: allPartsAvailable,
|
|
48
|
-
})
|
|
49
|
-
} catch (error) {
|
|
50
|
-
console.error("Error validating checkpoints:", error)
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const checkShippingInfo = async () => {
|
|
55
|
-
// Placeholder: Implement actual check for shipping info
|
|
56
|
-
return true
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const checkPCBErrors = async () => {
|
|
60
|
-
// Placeholder: Implement actual check for PCB errors
|
|
61
|
-
return true
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const checkPartsAvailability = async () => {
|
|
65
|
-
// Placeholder: Implement actual check for parts availability
|
|
66
|
-
return true
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const handleSubmit = async () => {
|
|
70
|
-
try {
|
|
71
|
-
setPending(true)
|
|
72
|
-
// TODO: Implement order submission logic
|
|
73
|
-
onOpenChange(false)
|
|
74
|
-
setPending(false)
|
|
75
|
-
toast({
|
|
76
|
-
title: "Order submitted",
|
|
77
|
-
description: "Your order has been successfully submitted.",
|
|
78
|
-
})
|
|
79
|
-
qc.invalidateQueries({ queryKey: ["orders"] })
|
|
80
|
-
} catch (error) {
|
|
81
|
-
console.error("Error submitting order:", error)
|
|
82
|
-
toast({
|
|
83
|
-
title: "Error",
|
|
84
|
-
description: "Failed to submit the order. Please try again.",
|
|
85
|
-
variant: "destructive",
|
|
86
|
-
})
|
|
87
|
-
} finally {
|
|
88
|
-
setPending(false)
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return (
|
|
93
|
-
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
94
|
-
<DialogContent>
|
|
95
|
-
<DialogHeader>
|
|
96
|
-
<DialogTitle>Create Order</DialogTitle>
|
|
97
|
-
</DialogHeader>
|
|
98
|
-
<p className="text-sm text-gray-500 mb-4">
|
|
99
|
-
Order the circuit board fully assembled from a PCB fabricator
|
|
100
|
-
</p>
|
|
101
|
-
<div className="space-y-4">
|
|
102
|
-
<div className="flex items-center space-x-2">
|
|
103
|
-
<Checkbox id="shipping" checked={checkpoints.shipping} />
|
|
104
|
-
<label
|
|
105
|
-
htmlFor="shipping"
|
|
106
|
-
className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
107
|
-
>
|
|
108
|
-
Shipping Information in Profile
|
|
109
|
-
</label>
|
|
110
|
-
</div>
|
|
111
|
-
<div className="flex items-center space-x-2">
|
|
112
|
-
<Checkbox id="errors" checked={checkpoints.errors} />
|
|
113
|
-
<label
|
|
114
|
-
htmlFor="errors"
|
|
115
|
-
className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
116
|
-
>
|
|
117
|
-
PCB Has No Errors
|
|
118
|
-
</label>
|
|
119
|
-
</div>
|
|
120
|
-
<div className="flex items-center space-x-2">
|
|
121
|
-
<Checkbox id="parts" checked={checkpoints.parts} />
|
|
122
|
-
<label
|
|
123
|
-
htmlFor="parts"
|
|
124
|
-
className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
125
|
-
>
|
|
126
|
-
All parts available at PCB fabricator
|
|
127
|
-
</label>
|
|
128
|
-
</div>
|
|
129
|
-
</div>
|
|
130
|
-
<div className="flex justify-end space-x-2 mt-4">
|
|
131
|
-
<Button variant="outline" onClick={() => onOpenChange(false)}>
|
|
132
|
-
Cancel
|
|
133
|
-
</Button>
|
|
134
|
-
<Button
|
|
135
|
-
onClick={handleSubmit}
|
|
136
|
-
disabled={pending || !Object.values(checkpoints).every(Boolean)}
|
|
137
|
-
>
|
|
138
|
-
{pending ? "Submitting..." : "Submit Order"}
|
|
139
|
-
</Button>
|
|
140
|
-
</div>
|
|
141
|
-
</DialogContent>
|
|
142
|
-
</Dialog>
|
|
143
|
-
)
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
export const useCreateOrderDialog = createUseDialog(CreateOrderDialog)
|
package/src/pages/preview.tsx
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { useSnippet } from "@/hooks/use-snippet"
|
|
2
|
-
import { useUrlParams } from "@/hooks/use-url-params"
|
|
3
|
-
import { CircuitJsonPreview } from "@tscircuit/runframe"
|
|
4
|
-
import { Loader2 } from "lucide-react"
|
|
5
|
-
|
|
6
|
-
export const PreviewPage = () => {
|
|
7
|
-
const urlParams = useUrlParams()
|
|
8
|
-
const snippetId = urlParams.snippet_id
|
|
9
|
-
const { data: snippet, isLoading, error } = useSnippet(snippetId)
|
|
10
|
-
|
|
11
|
-
if (isLoading) {
|
|
12
|
-
return (
|
|
13
|
-
<div className="w-full h-screen flex items-center justify-center">
|
|
14
|
-
<Loader2 className="w-8 h-8 animate-spin" />
|
|
15
|
-
</div>
|
|
16
|
-
)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (error) {
|
|
20
|
-
return (
|
|
21
|
-
<div className="w-full h-screen flex items-center justify-center text-red-500">
|
|
22
|
-
Error loading snippet: {error.message}
|
|
23
|
-
</div>
|
|
24
|
-
)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (!snippet) {
|
|
28
|
-
return (
|
|
29
|
-
<div className="w-full h-screen flex items-center justify-center text-gray-500">
|
|
30
|
-
Snippet not found
|
|
31
|
-
</div>
|
|
32
|
-
)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (!snippet.circuit_json) {
|
|
36
|
-
return (
|
|
37
|
-
<div className="w-full h-screen flex items-center justify-center text-gray-500">
|
|
38
|
-
No circuit data available
|
|
39
|
-
</div>
|
|
40
|
-
)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return <CircuitJsonPreview circuitJson={snippet.circuit_json as any} />
|
|
44
|
-
}
|
package/src/pages/view-order.tsx
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import React 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 { Order } from "fake-snippets-api/lib/db/schema"
|
|
7
|
-
import { Link, useParams } from "wouter"
|
|
8
|
-
import { Button } from "@/components/ui/button"
|
|
9
|
-
import { OrderPreviewContent } from "@/components/OrderPreviewContent"
|
|
10
|
-
import { AnyCircuitElement } from "circuit-json"
|
|
11
|
-
|
|
12
|
-
export const ViewOrderPage = () => {
|
|
13
|
-
const { orderId } = useParams()
|
|
14
|
-
const axios = useAxios()
|
|
15
|
-
|
|
16
|
-
const {
|
|
17
|
-
data: order,
|
|
18
|
-
isLoading,
|
|
19
|
-
error,
|
|
20
|
-
} = useQuery<Order>(
|
|
21
|
-
["order", orderId],
|
|
22
|
-
async () => {
|
|
23
|
-
const response = await axios.get(`/orders/get?order_id=${orderId}`)
|
|
24
|
-
return response.data.order
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
enabled: !!orderId,
|
|
28
|
-
},
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
if (isLoading) {
|
|
32
|
-
return <div>Loading order...</div>
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (error) {
|
|
36
|
-
return <div>Error loading order: {(error as Error).message}</div>
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (!order) {
|
|
40
|
-
return <div>Order not found</div>
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<div>
|
|
45
|
-
<Header />
|
|
46
|
-
<div className="container mx-auto px-4 py-4">
|
|
47
|
-
<h1 className="text-3xl font-bold mb-6">Order Details</h1>
|
|
48
|
-
<div className="flex flex-col md:flex-row gap-6">
|
|
49
|
-
<div className="w-full md:w-1/2 md:max-w-[50%]">
|
|
50
|
-
<div className="bg-white shadow overflow-hidden sm:rounded-lg mb-6">
|
|
51
|
-
<div className="px-4 py-5 sm:px-6">
|
|
52
|
-
<h3 className="text-lg leading-6 font-medium text-gray-900">
|
|
53
|
-
Order #{order.order_id}
|
|
54
|
-
</h3>
|
|
55
|
-
<p className="mt-1 max-w-2xl text-sm text-gray-500">
|
|
56
|
-
Created at: {new Date(order.created_at).toLocaleString()}
|
|
57
|
-
</p>
|
|
58
|
-
</div>
|
|
59
|
-
<div className="border-t border-gray-200">
|
|
60
|
-
<dl>
|
|
61
|
-
<div className="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
|
62
|
-
<dt className="text-sm font-medium text-gray-500">
|
|
63
|
-
Status
|
|
64
|
-
</dt>
|
|
65
|
-
<dd className="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
|
|
66
|
-
{order.is_running ? "Running" : "Finished"}
|
|
67
|
-
</dd>
|
|
68
|
-
</div>
|
|
69
|
-
<div className="bg-white px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
|
70
|
-
<dt className="text-sm font-medium text-gray-500">
|
|
71
|
-
Started at
|
|
72
|
-
</dt>
|
|
73
|
-
<dd className="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
|
|
74
|
-
{order.started_at
|
|
75
|
-
? new Date(order.started_at).toLocaleString()
|
|
76
|
-
: "Not started"}
|
|
77
|
-
</dd>
|
|
78
|
-
</div>
|
|
79
|
-
<div className="bg-gray-50 px-4 py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
|
|
80
|
-
<dt className="text-sm font-medium text-gray-500">
|
|
81
|
-
Pending Validation
|
|
82
|
-
</dt>
|
|
83
|
-
<dd className="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
|
|
84
|
-
{order.completed_at
|
|
85
|
-
? new Date(order.completed_at).toLocaleString()
|
|
86
|
-
: "Not finished"}
|
|
87
|
-
</dd>
|
|
88
|
-
</div>
|
|
89
|
-
</dl>
|
|
90
|
-
</div>
|
|
91
|
-
</div>
|
|
92
|
-
<div className="mt-6">
|
|
93
|
-
<Link href={`/my-orders`}>
|
|
94
|
-
<Button variant="outline" onClick={() => window.history.back()}>
|
|
95
|
-
Back to Orders
|
|
96
|
-
</Button>
|
|
97
|
-
</Link>
|
|
98
|
-
</div>
|
|
99
|
-
</div>
|
|
100
|
-
<div className="w-full md:w-1/2 md:max-w-[50%]">
|
|
101
|
-
<OrderPreviewContent
|
|
102
|
-
circuitJson={order.circuit_json as AnyCircuitElement[]}
|
|
103
|
-
className="h-[calc(100vh-200px)]"
|
|
104
|
-
/>
|
|
105
|
-
</div>
|
|
106
|
-
</div>
|
|
107
|
-
</div>
|
|
108
|
-
<Footer />
|
|
109
|
-
</div>
|
|
110
|
-
)
|
|
111
|
-
}
|