Skip to content

Commit

Permalink
feat: show errors in a message bar
Browse files Browse the repository at this point in the history
  • Loading branch information
filippofinke committed Apr 23, 2023
1 parent 6449a58 commit 744a800
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/taskpane/components/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from "react";
import { DefaultButton, ProgressIndicator, TextField } from "@fluentui/react";
import { DefaultButton, MessageBar, MessageBarType, ProgressIndicator, TextField } from "@fluentui/react";
import { Configuration, OpenAIApi } from "openai";
import Center from "./Center";
import Container from "./Container";
Expand All @@ -9,6 +9,7 @@ import Login from "./Login";
export default function App() {
const [apiKey, setApiKey] = React.useState<string>("");
const [prompt, setPrompt] = React.useState<string>("");
const [error, setError] = React.useState<string>("");
const [loading, setLoading] = React.useState<boolean>(false);
const [generatedText, setGeneratedText] = React.useState<string>("");

Expand All @@ -30,6 +31,7 @@ export default function App() {
const saveApiKey = (key) => {
setApiKey(key);
localStorage.setItem("apiKey", key);
setError("");
};

const onClick = async () => {
Expand All @@ -44,6 +46,7 @@ export default function App() {
temperature: 0.7,
});
} catch (error) {
setError(error.message);
setApiKey("");
}
setLoading(false);
Expand Down Expand Up @@ -107,6 +110,7 @@ export default function App() {
) : (
<Login onSave={saveApiKey} />
)}
{error && <MessageBar messageBarType={MessageBarType.error}>{error}</MessageBar>}
</Container>
);
}

1 comment on commit 744a800

@vercel
Copy link

@vercel vercel bot commented on 744a800 Apr 23, 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:

word-gpt – ./

word-gpt-git-main-filippofinke.vercel.app
word-gpt.vercel.app
word-gpt-filippofinke.vercel.app

Please sign in to comment.