This repository has been archived by the owner on Jan 2, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* initial setup and formatting * add package_info table and routes * implement package name fix * Update dev-server-api/routes/api/package_info/get.ts Co-authored-by: Severin Ibarluzea <[email protected]> * Update dev-server-api/routes/api/package_info/create.ts Co-authored-by: Severin Ibarluzea <[email protected]> --------- Co-authored-by: Severin Ibarluzea <[email protected]>
- Loading branch information
Showing
12 changed files
with
142 additions
and
37 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { withWinterSpec } from "src/with-winter-spec" | ||
import { z } from "zod" | ||
|
||
export default withWinterSpec({ | ||
methods: ["POST"], | ||
jsonBody: z.object({ | ||
package_name: z.string() | ||
}), | ||
jsonResponse: z.object({ | ||
package_info: z.object({ | ||
name: z.string() | ||
}) | ||
}), | ||
auth: "none", | ||
})(async (req, ctx) => { | ||
const package_name = req.jsonBody.package_name | ||
const package_info = await ctx.db | ||
.insertInto("package_info") | ||
.values({ | ||
name: package_name | ||
}) | ||
.returningAll() | ||
.executeTakeFirstOrThrow() | ||
|
||
return ctx.json({ | ||
package_info | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { export_package_info } from "src/lib/zod/export_package_info" | ||
import { withWinterSpec } from "src/with-winter-spec" | ||
import { z } from "zod" | ||
|
||
export default withWinterSpec({ | ||
methods: ["GET"], | ||
jsonResponse: z.object({ | ||
package_info: export_package_info | ||
}), | ||
auth: "none", | ||
})(async (req, ctx) => { | ||
const package_info = await ctx.db | ||
.selectFrom("package_info") | ||
.select("name") | ||
.executeTakeFirstOrThrow() | ||
|
||
return ctx.json({ package_info }) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { z } from "zod" | ||
|
||
export const export_package_info = z.object({ | ||
name: z.string() | ||
}) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,26 @@ | ||
import axios from "axios" | ||
import { useState } from "react" | ||
import toast from "react-hot-toast" | ||
import { useQuery } from "react-query" | ||
import { | ||
Menubar, | ||
MenubarCheckboxItem, | ||
MenubarContent, | ||
MenubarItem, | ||
MenubarMenu, | ||
MenubarRadioGroup, | ||
MenubarRadioItem, | ||
MenubarCheckboxItem, | ||
MenubarSeparator, | ||
MenubarSub, | ||
MenubarSubContent, | ||
MenubarSubTrigger, | ||
MenubarTrigger, | ||
} from "src/components/ui/menubar" | ||
import toast from "react-hot-toast" | ||
import { useGlobalStore } from "./hooks/use-global-store" | ||
import frontendPackageJson from "../package.json" | ||
import cliPackageJson from "../../package.json" | ||
import { useGerberExportDialog } from "./components/dialogs/gerber-export-dialog" | ||
import frontendPackageJson from "../package.json" | ||
import { useGenericExportDialog } from "./components/dialogs/generic-export-dialog" | ||
import { useGerberExportDialog } from "./components/dialogs/gerber-export-dialog" | ||
import { useGlobalStore } from "./hooks/use-global-store" | ||
|
||
export const HeaderMenu = () => { | ||
const [viewMode, setViewMode] = useGlobalStore((s) => [ | ||
|
@@ -29,6 +31,23 @@ export const HeaderMenu = () => { | |
s.split_mode, | ||
s.setSplitMode, | ||
]) | ||
|
||
const { | ||
data, | ||
isLoading, | ||
} = useQuery( | ||
["package_info"], | ||
async () => | ||
axios | ||
.get(`/api/package_info/get`), | ||
{ | ||
refetchOnWindowFocus: true, | ||
retry: false, | ||
}, | ||
) | ||
|
||
const name = data?.data.package_info.name | ||
|
||
const [inDebugMode, setInDebugMode] = useState(false) | ||
const gerberExportDialog = useGerberExportDialog() | ||
const pnpExportDialog = useGenericExportDialog({ | ||
|
@@ -65,7 +84,7 @@ export const HeaderMenu = () => { | |
<MenubarMenu> | ||
<MenubarTrigger>File</MenubarTrigger> | ||
<MenubarContent className="z-[200]"> | ||
<MenubarItem disabled>seveibar/[email protected]</MenubarItem> | ||
<MenubarItem disabled>{name}</MenubarItem> | ||
<MenubarSeparator /> | ||
<MenubarItem | ||
onSelect={() => { | ||
|
@@ -150,7 +169,7 @@ export const HeaderMenu = () => { | |
<MenubarMenu> | ||
<MenubarTrigger>Package</MenubarTrigger> | ||
<MenubarContent className="z-[200]"> | ||
<MenubarItem disabled>seveibar/[email protected]</MenubarItem> | ||
<MenubarItem disabled>{name}</MenubarItem> | ||
<MenubarSeparator /> | ||
<MenubarCheckboxItem | ||
checked | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters