Skip to content

Commit

Permalink
add Header
Browse files Browse the repository at this point in the history
  • 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.
30 changes: 30 additions & 0 deletions components/Header.tsx
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>
)
}

1 comment on commit 4102110

@vercel
Copy link

@vercel vercel bot commented on 4102110 Mar 8, 2023

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

Please sign in to comment.