-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: fetch and display template menu items
- Loading branch information
1 parent
d22c017
commit 089116b
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
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,29 @@ | ||
import * as React from "react"; | ||
|
||
import { MenubarRadioGroup, MenubarRadioItem } from "@/components/ui/menubar"; | ||
|
||
async function getData() { | ||
let url = `https://playground-next.test.aelf.dev/playground/templates`; | ||
if (process.env.NODE_ENV === "production") { | ||
url = `/playground/templates`; | ||
} | ||
|
||
const res = await fetch(url); | ||
const data = await res.json(); | ||
|
||
return data as string[]; | ||
} | ||
|
||
export async function TemplatesMenu() { | ||
const data = await getData(); | ||
|
||
return ( | ||
<MenubarRadioGroup> | ||
{data.map((i) => ( | ||
<MenubarRadioItem key={i} value={i}> | ||
{i} | ||
</MenubarRadioItem> | ||
))} | ||
</MenubarRadioGroup> | ||
); | ||
} |