fix(storeContext.tsx): change hasStore initial value to true to reflect correct initial state
fix(API/index.ts): update API endpoint for checkHasStore function to match backend route feat(StorePage/index.tsx): add functionality to fetch and display store tags from backend
This commit is contained in:
parent
01a1484e43
commit
695f219460
3 changed files with 14 additions and 4 deletions
|
|
@ -6,7 +6,7 @@ import { storeContextType } from "../types/contexts/store";
|
|||
const initialValue = {
|
||||
savedFlows: new Set<string>(),
|
||||
setSavedFlows: () => {},
|
||||
hasStore: false,
|
||||
hasStore: true,
|
||||
setHasStore: () => {},
|
||||
};
|
||||
|
||||
|
|
@ -15,7 +15,7 @@ export const StoreContext = createContext<storeContextType>(initialValue);
|
|||
export function StoreProvider({ children }) {
|
||||
const [savedFlows, setSavedFlows] = useState<Set<string>>(new Set());
|
||||
|
||||
const [hasStore, setHasStore] = useState(false);
|
||||
const [hasStore, setHasStore] = useState(true);
|
||||
|
||||
checkHasStore().then((res) => {
|
||||
setHasStore(res["enabled"]);
|
||||
|
|
|
|||
|
|
@ -685,7 +685,7 @@ export async function searchComponent(
|
|||
|
||||
export async function checkHasStore() {
|
||||
try {
|
||||
const res = await api.get(`${BASE_URL_API}store`);
|
||||
const res = await api.get(`${BASE_URL_API}store/check/`);
|
||||
if (res.status === 200) {
|
||||
return res.data;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { cloneDeep } from "lodash";
|
||||
import { Search } from "lucide-react";
|
||||
import { useContext, useEffect, useState } from "react";
|
||||
import { useContext, useEffect, useRef, useState } from "react";
|
||||
import PaginatorComponent from "../../components/PaginatorComponent";
|
||||
import IconComponent from "../../components/genericIconComponent";
|
||||
import Header from "../../components/headerComponent";
|
||||
|
|
@ -23,6 +23,7 @@ import {
|
|||
getNumberOfComponents,
|
||||
getStoreComponents,
|
||||
getStoreSavedComponents,
|
||||
getStoreTags,
|
||||
searchComponent,
|
||||
} from "../../controllers/API";
|
||||
import StoreApiKeyModal from "../../modals/StoreApiKeyModal";
|
||||
|
|
@ -48,6 +49,15 @@ export default function StorePage(): JSX.Element {
|
|||
const [errorApiKey, setErrorApiKey] = useState(false);
|
||||
const { setSavedFlows } = useContext(StoreContext);
|
||||
const [tags, setTags] = useState<string[]>([]);
|
||||
const tagListId = useRef<{ id: string; name: string }[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
getStoreTags().then((res) => {
|
||||
tagListId.current = res;
|
||||
let tags = res.map((tag) => tag.name);
|
||||
setTags(tags);
|
||||
});
|
||||
}, []);
|
||||
|
||||
async function getSavedComponents() {
|
||||
setLoading(true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue