@tscircuit/fake-snippets 0.0.41 → 0.0.43

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.
@@ -1,18 +1,3 @@
1
- import {
2
- Dialog,
3
- DialogContent,
4
- DialogHeader,
5
- DialogTitle,
6
- DialogDescription,
7
- } from "../ui/dialog"
8
- import { Button } from "../ui/button"
9
- import { useMutation, useQueryClient } from "react-query"
10
- import { createUseDialog } from "./create-use-dialog"
11
- import { useAxios } from "@/hooks/use-axios"
12
- import { useToast } from "@/hooks/use-toast"
13
- import { Textarea } from "../ui/textarea"
14
- import { Input } from "../ui/input"
15
- import { Label } from "../ui/label"
16
1
  import {
17
2
  Select,
18
3
  SelectContent,
@@ -20,8 +5,23 @@ import {
20
5
  SelectTrigger,
21
6
  SelectValue,
22
7
  } from "@/components/ui/select"
23
- import { getLicenseContent } from "../ViewPackagePage/utils/get-license-content"
8
+ import { useAxios } from "@/hooks/use-axios"
24
9
  import { usePackageDetailsForm } from "@/hooks/use-package-details-form"
10
+ import { useToast } from "@/hooks/use-toast"
11
+ import { useMutation, useQueryClient } from "react-query"
12
+ import { getLicenseContent } from "../ViewPackagePage/utils/get-license-content"
13
+ import { Button } from "../ui/button"
14
+ import {
15
+ Dialog,
16
+ DialogContent,
17
+ DialogDescription,
18
+ DialogHeader,
19
+ DialogTitle,
20
+ } from "../ui/dialog"
21
+ import { Input } from "../ui/input"
22
+ import { Label } from "../ui/label"
23
+ import { Textarea } from "../ui/textarea"
24
+ import { createUseDialog } from "./create-use-dialog"
25
25
 
26
26
  export const EditPackageDetailsDialog = ({
27
27
  open,
@@ -77,9 +77,7 @@ export const EditPackageDetailsDialog = ({
77
77
  if (hasLicenseChanged) {
78
78
  await axios.post("/package_releases/update", {
79
79
  package_id: packageId,
80
- description: formData.description,
81
80
  package_release_id: packageReleaseId,
82
- website: formData.website,
83
81
  license: formData.license ?? "unset",
84
82
  })
85
83
  }
@@ -87,7 +85,6 @@ export const EditPackageDetailsDialog = ({
87
85
  const response = await axios.post("/packages/update", {
88
86
  package_id: packageId,
89
87
  description: formData.description,
90
- package_release_id: packageReleaseId,
91
88
  website: formData.website,
92
89
  })
93
90
 
@@ -98,7 +95,7 @@ export const EditPackageDetailsDialog = ({
98
95
 
99
96
  const packageFiles = []
100
97
  const packageFilesResponse = await axios.post("/package_files/list", {
101
- package_name_with_version: `${packageName}`,
98
+ package_name_with_version: packageName,
102
99
  })
103
100
 
104
101
  if (packageFilesResponse.status === 200) {
@@ -114,28 +111,25 @@ export const EditPackageDetailsDialog = ({
114
111
  packageAuthor,
115
112
  )
116
113
  if (hasLicenseChanged) {
117
- let concludedLicenseResult
118
114
  if (packageFiles.includes("LICENSE") && !licenseContent) {
119
- concludedLicenseResult = await axios.post("/package_files/delete", {
120
- package_name_with_version: `${packageName}`,
115
+ await axios.post("/package_files/delete", {
116
+ package_name_with_version: packageName,
121
117
  file_path: "LICENSE",
122
118
  })
123
119
  }
124
120
  if (licenseContent) {
125
- concludedLicenseResult = await axios.post(
126
- "/package_files/create_or_update",
127
- {
128
- package_name_with_version: `${packageName}`,
129
- file_path: "LICENSE",
130
- content_text: licenseContent,
131
- },
132
- )
121
+ await axios.post("/package_files/create_or_update", {
122
+ package_name_with_version: packageName,
123
+ file_path: "LICENSE",
124
+ content_text: licenseContent,
125
+ })
133
126
  }
134
- try {
135
- if (concludedLicenseResult) {
136
- window?.location?.reload?.()
137
- }
138
- } catch {}
127
+ }
128
+
129
+ return {
130
+ description: formData.description,
131
+ website: formData.website,
132
+ license: formData.license,
139
133
  }
140
134
  },
141
135
  onMutate: async () => {
@@ -149,9 +143,14 @@ export const EditPackageDetailsDialog = ({
149
143
  }))
150
144
  return { previousPackage }
151
145
  },
152
- onSuccess: () => {
153
- onUpdate?.(formData.description, formData.website, formData.license)
146
+ onSuccess: (data) => {
147
+ onUpdate?.(data.description, data.website, data.license)
154
148
  onOpenChange(false)
149
+
150
+ qc.invalidateQueries({
151
+ queryKey: ["packageFile", { package_release_id: packageReleaseId }],
152
+ })
153
+
155
154
  toast({
156
155
  title: "Package details updated",
157
156
  description: "Successfully updated package details",
@@ -168,7 +167,6 @@ export const EditPackageDetailsDialog = ({
168
167
  },
169
168
  onSettled: () => {
170
169
  qc.invalidateQueries({ queryKey: ["packages", packageId] })
171
- qc.invalidateQueries({ queryKey: ["current-package-info"] })
172
170
  },
173
171
  })
174
172
 
@@ -33,6 +33,7 @@ export const useDeletePackage = ({
33
33
  toast({
34
34
  title: "Error deleting package",
35
35
  description: "Failed to delete package",
36
+ variant: "destructive",
36
37
  })
37
38
  },
38
39
  },
@@ -42,6 +42,13 @@ export const useForkPackageMutation = ({
42
42
  onSuccess?.(result)
43
43
  },
44
44
  onError: (error: any) => {
45
+ if (error.data.error_code === "cannot_fork_own_package") {
46
+ toast({
47
+ title: "Cannot Fork Package",
48
+ description: "You cannot fork your own package.",
49
+ })
50
+ return
51
+ }
45
52
  toast({
46
53
  title: "Error",
47
54
  description: "Failed to fork package. Please try again.",