-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(front): Add apikey input form (#58)
set custom api key form catch 401 error trigger new request on api key change style and focus on text input by default
- Loading branch information
Showing
4 changed files
with
94 additions
and
16 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
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,37 @@ | ||
import React, {useState, useRef, useEffect} from 'react'; | ||
|
||
const ApiKeyPrompt = ({failedKey, setApiKey: submitNewApiKey}) => { | ||
const [formApiKey, updateFormApiKey] = useState(failedKey); | ||
const inputEl = useRef(null); | ||
useEffect(() => inputEl.current.focus()); | ||
|
||
return ( | ||
<section> | ||
<div className="form-group"> | ||
<div className="input mt-3 mb-3"> | ||
<input | ||
ref={inputEl} | ||
type="text" | ||
className="form-control" | ||
placeholder={ | ||
'Current key: ' + | ||
(failedKey || process.env.YOLO_APP_PW || 'no key set') | ||
} | ||
onChange={(e) => { | ||
updateFormApiKey(e.target.value); | ||
}} | ||
/> | ||
</div> | ||
<button | ||
className="btn" | ||
onClick={() => submitNewApiKey(formApiKey)} | ||
disabled={!formApiKey} | ||
> | ||
Update | ||
</button> | ||
</div> | ||
</section> | ||
); | ||
}; | ||
|
||
export default ApiKeyPrompt; |
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
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