paper-ai-release-24-07-21/components/Settings.tsx
Liuweiqing e7d296cd95 init
2024-01-21 23:08:25 +08:00

37 lines
979 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Settings.tsx
import { useState, FormEvent } from "react";
import { useAppDispatch, useAppSelector } from "@/app/store";
import { setApiKey } from "@/app/store/slices/authSlice";
const Settings = () => {
const dispatch = useAppDispatch();
const apiKey = useAppSelector((state: any) => state.auth.apiKey);
console.log(apiKey);
// const handleSubmit = (event: FormEvent) => {
// event.preventDefault();
// // 在这里你可以将apiKey保存到你想要的地方例如发送到服务器或保存到localStorage
// dispatch(setApiKey(apiKey));
// console.log(apiKey);
// };
return (
<div>
{/* <form onSubmit={handleSubmit}> */}
<label>
API Key:
<input
type="text"
value={apiKey}
onChange={(event) => dispatch(setApiKey(event.target.value))}
/>
</label>
{/* <button type="submit">Save</button>
</form> */}
</div>
);
};
export default Settings;