fix(storeContext.tsx): add console.log statement to log the response from checkHasApiKey() function
fix(StoreApiKeyModal/index.tsx): initialize apiKeyValue state with a fake API key if hasApiKey is true
This commit is contained in:
parent
7a15fb7a0d
commit
fec102b6e7
2 changed files with 7 additions and 3 deletions
|
|
@ -75,6 +75,7 @@ export function StoreProvider({ children }) {
|
||||||
try {
|
try {
|
||||||
if (storeChecked) return;
|
if (storeChecked) return;
|
||||||
const res = await checkHasApiKey();
|
const res = await checkHasApiKey();
|
||||||
|
console.log(res);
|
||||||
setHasApiKey(res?.has_api_key ?? false);
|
setHasApiKey(res?.has_api_key ?? false);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
|
|
||||||
|
|
@ -20,13 +20,15 @@ export default function StoreApiKeyModal({
|
||||||
onCloseModal,
|
onCloseModal,
|
||||||
}: StoreApiKeyType) {
|
}: StoreApiKeyType) {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const [apiKeyValue, setApiKeyValue] = useState("");
|
|
||||||
const [inputState, setInputState] =
|
const [inputState, setInputState] =
|
||||||
useState<ApiKeyInputType>(CONTROL_NEW_API_KEY);
|
useState<ApiKeyInputType>(CONTROL_NEW_API_KEY);
|
||||||
const { setSuccessData, setErrorData } = useContext(alertContext);
|
const { setSuccessData, setErrorData } = useContext(alertContext);
|
||||||
const inputRef = useRef<HTMLInputElement | null>(null);
|
const inputRef = useRef<HTMLInputElement | null>(null);
|
||||||
const { storeApiKey } = useContext(AuthContext);
|
const { storeApiKey } = useContext(AuthContext);
|
||||||
const { hasApiKey } = useContext(StoreContext);
|
const { hasApiKey } = useContext(StoreContext);
|
||||||
|
const [apiKeyValue, setApiKeyValue] = useState(
|
||||||
|
hasApiKey ? "this is not a real api key :)" : ""
|
||||||
|
);
|
||||||
|
|
||||||
function handleInput({
|
function handleInput({
|
||||||
target: { name, value },
|
target: { name, value },
|
||||||
|
|
@ -36,7 +38,7 @@ export default function StoreApiKeyModal({
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (open) {
|
if (open) {
|
||||||
resetForm();
|
// resetForm();
|
||||||
} else {
|
} else {
|
||||||
onCloseModal();
|
onCloseModal();
|
||||||
}
|
}
|
||||||
|
|
@ -89,10 +91,11 @@ export default function StoreApiKeyModal({
|
||||||
<Form.Control asChild>
|
<Form.Control asChild>
|
||||||
<Input
|
<Input
|
||||||
//fake api key
|
//fake api key
|
||||||
value={hasApiKey ? "this is not a real api key :)" : ""}
|
value={apiKeyValue}
|
||||||
type="password"
|
type="password"
|
||||||
onChange={({ target: { value } }) => {
|
onChange={({ target: { value } }) => {
|
||||||
handleInput({ target: { name: "apikey", value } });
|
handleInput({ target: { name: "apikey", value } });
|
||||||
|
setApiKeyValue(value);
|
||||||
}}
|
}}
|
||||||
placeholder="Insert your API Key"
|
placeholder="Insert your API Key"
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue