From 5affcdf9876d3559eb4e5de63f97f56b63151dc8 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 7 Nov 2023 21:10:13 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20fix(storeContext.tsx):=20add=20m?= =?UTF-8?q?issing=20import=20for=20checkHasApiKey=20function=20in=20API=20?= =?UTF-8?q?controller=20=F0=9F=94=A7=20fix(API/index.ts):=20add=20checkHas?= =?UTF-8?q?ApiKey=20function=20to=20check=20if=20store=20has=20an=20API=20?= =?UTF-8?q?key?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/frontend/src/contexts/storeContext.tsx | 17 +++++++++++++++-- src/frontend/src/controllers/API/index.ts | 12 ++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/frontend/src/contexts/storeContext.tsx b/src/frontend/src/contexts/storeContext.tsx index 8a60d4a63..8acda7fe4 100644 --- a/src/frontend/src/contexts/storeContext.tsx +++ b/src/frontend/src/contexts/storeContext.tsx @@ -1,5 +1,5 @@ import { createContext, useEffect, useState } from "react"; -import { checkHasStore } from "../controllers/API"; +import { checkHasApiKey, checkHasStore } from "../controllers/API"; import { storeContextType } from "../types/contexts/store"; //store context to share user components and update them @@ -27,7 +27,6 @@ export function StoreProvider({ children }) { if (storeChecked) return; const res = await checkHasStore(); setHasStore(res?.enabled ?? false); - setHasApiKey(res?.has_api_key ?? false); setStoreChecked(true); } catch (e) { console.log(e); @@ -37,6 +36,20 @@ export function StoreProvider({ children }) { fetchStoreData(); }, []); + useEffect(() => { + const fetchStoreData = async () => { + try { + if (storeChecked) return; + const res = await checkHasApiKey(); + setHasApiKey(res?.has_api_key ?? false); + } catch (e) { + console.log(e); + } + }; + + fetchStoreData(); + }, [storeChecked]); + return (