-
-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
cgsv
authored and
cgsv
committed
Mar 8, 2023
1 parent
95dd050
commit 4102110
Showing
1 changed file
with
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import Image from "next/image"; | ||
import Github from "./Github"; | ||
import { useLocalStorage } from "react-use"; | ||
import { checkOpenaiApiKey } from "@/lib/openai/openai"; | ||
import { toast, Toaster } from "react-hot-toast"; | ||
|
||
export default function Header() { | ||
const [userKey, setUserKey] = useLocalStorage<string>("user-openai-apikey-trans"); | ||
|
||
const setOpenAIKey = () => { | ||
const key = prompt("Please enter your OpenAI API key"); | ||
if (key && checkOpenaiApiKey(key)) { | ||
setUserKey(key); | ||
toast.success("OpenAI API key successfully set"); | ||
} else { | ||
toast.error("OpenAI API key is invalid"); | ||
} | ||
} | ||
|
||
return ( | ||
<div style={{display:"flex", alignItems:"center", justifyContent:"space-between"}}> | ||
<div style={{marginLeft: "10px", marginTop: "10px"}}> | ||
<Github width="33" height="33"></Github> | ||
</div> | ||
<div style={{marginRight: "10px", marginTop: "10px"}}> | ||
<Image onClick={setOpenAIKey} alt="settings" width={33} height={33} src="/set1.png" /> | ||
</div> | ||
</div> | ||
) | ||
} |
4102110
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
nextjs – ./
nextjs-git-main-cgsvv.vercel.app
nextjs-cgsvv.vercel.app
nextjs-bay-one-40.vercel.app
next.cgsv.top