paper-ai-release-24-07-21/components/Settings.tsx

82 lines
2.7 KiB
TypeScript
Raw Normal View History

2024-01-29 13:35:24 +08:00
"use client";
2024-01-21 23:08:25 +08:00
// Settings.tsx
import { useAppDispatch, useAppSelector } from "@/app/store";
2024-01-29 13:35:24 +08:00
import {
setApiKey,
setUpsreamUrl,
setSystemPrompt,
} from "@/app/store/slices/authSlice";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faArrowLeft } from "@fortawesome/free-solid-svg-icons";
import Link from "next/link";
2024-01-21 23:08:25 +08:00
const Settings = () => {
const dispatch = useAppDispatch();
2024-01-22 08:53:58 +08:00
const apiKey = useAppSelector((state) => state.auth.apiKey);
const upstreamUrl = useAppSelector((state) => state.auth.upsreamUrl);
2024-01-29 13:35:24 +08:00
const systemPrompt = useAppSelector((state) => state.auth.systemPrompt);
2024-01-21 23:08:25 +08:00
return (
2024-02-03 23:07:02 +08:00
<div className="max-w-md rounded overflow-hidden shadow-lg bg-blue-gray-100 z-1000 mx-auto ">
2024-01-29 13:35:24 +08:00
<h1 className="font-bold text-3xl">settings</h1>
<br />
<div className="flex justify-end mt-4 mr-4">
<Link href="/" aria-label="Settings">
<FontAwesomeIcon icon={faArrowLeft} size="2x" />
</Link>
</div>
2024-01-22 08:53:58 +08:00
<div className="mb-4">
<label
className="block text-gray-700 text-sm font-bold mb-2"
htmlFor="api-key"
>
API Key:
</label>
2024-01-21 23:08:25 +08:00
<input
2024-01-22 08:53:58 +08:00
id="api-key"
2024-01-21 23:08:25 +08:00
type="text"
value={apiKey}
onChange={(event) => dispatch(setApiKey(event.target.value))}
2024-01-22 08:53:58 +08:00
className="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
2024-01-21 23:08:25 +08:00
/>
{/* upstream-url */}
<div className="mb-4">
<label
className="block text-gray-700 text-sm font-bold mb-2"
htmlFor="upstream-url"
>
Upstream URL:
</label>
<input
id="upstream-url"
type="text"
value={upstreamUrl} // 这里假设你有一个upstreamUrl状态
onChange={(event) => dispatch(setUpsreamUrl(event.target.value))}
className="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
/>
</div>
2024-01-29 13:35:24 +08:00
{/* systemPrompt */}
<div className="mb-4">
<label
className="block text-gray-700 text-sm font-bold mb-2"
htmlFor="system-prompt"
>
System Prompt(Paper2AI):
</label>
<textarea
id="system-prompt"
value={systemPrompt}
onChange={(event) => setSystemPrompt(event.target.value)}
className="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
rows={8}
/>
</div>
2024-01-22 08:53:58 +08:00
</div>
2024-01-21 23:08:25 +08:00
</div>
);
};
export default Settings;