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 = {
|
const initialValue = {
|
||||||
savedFlows: new Set<string>(),
|
savedFlows: new Set<string>(),
|
||||||
setSavedFlows: () => {},
|
setSavedFlows: () => {},
|
||||||
hasStore: false,
|
hasStore: true,
|
||||||
setHasStore: () => {},
|
setHasStore: () => {},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -15,7 +15,7 @@ export const StoreContext = createContext<storeContextType>(initialValue);
|
||||||
export function StoreProvider({ children }) {
|
export function StoreProvider({ children }) {
|
||||||
const [savedFlows, setSavedFlows] = useState<Set<string>>(new Set());
|
const [savedFlows, setSavedFlows] = useState<Set<string>>(new Set());
|
||||||
|
|
||||||
const [hasStore, setHasStore] = useState(false);
|
const [hasStore, setHasStore] = useState(true);
|
||||||
|
|
||||||
checkHasStore().then((res) => {
|
checkHasStore().then((res) => {
|
||||||
setHasStore(res["enabled"]);
|
setHasStore(res["enabled"]);
|
||||||
|
|
|
||||||
|
|
@ -685,7 +685,7 @@ export async function searchComponent(
|
||||||
|
|
||||||
export async function checkHasStore() {
|
export async function checkHasStore() {
|
||||||
try {
|
try {
|
||||||
const res = await api.get(`${BASE_URL_API}store`);
|
const res = await api.get(`${BASE_URL_API}store/check/`);
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
return res.data;
|
return res.data;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { cloneDeep } from "lodash";
|
import { cloneDeep } from "lodash";
|
||||||
import { Search } from "lucide-react";
|
import { Search } from "lucide-react";
|
||||||
import { useContext, useEffect, useState } from "react";
|
import { useContext, useEffect, useRef, useState } from "react";
|
||||||
import PaginatorComponent from "../../components/PaginatorComponent";
|
import PaginatorComponent from "../../components/PaginatorComponent";
|
||||||
import IconComponent from "../../components/genericIconComponent";
|
import IconComponent from "../../components/genericIconComponent";
|
||||||
import Header from "../../components/headerComponent";
|
import Header from "../../components/headerComponent";
|
||||||
|
|
@ -23,6 +23,7 @@ import {
|
||||||
getNumberOfComponents,
|
getNumberOfComponents,
|
||||||
getStoreComponents,
|
getStoreComponents,
|
||||||
getStoreSavedComponents,
|
getStoreSavedComponents,
|
||||||
|
getStoreTags,
|
||||||
searchComponent,
|
searchComponent,
|
||||||
} from "../../controllers/API";
|
} from "../../controllers/API";
|
||||||
import StoreApiKeyModal from "../../modals/StoreApiKeyModal";
|
import StoreApiKeyModal from "../../modals/StoreApiKeyModal";
|
||||||
|
|
@ -48,6 +49,15 @@ export default function StorePage(): JSX.Element {
|
||||||
const [errorApiKey, setErrorApiKey] = useState(false);
|
const [errorApiKey, setErrorApiKey] = useState(false);
|
||||||
const { setSavedFlows } = useContext(StoreContext);
|
const { setSavedFlows } = useContext(StoreContext);
|
||||||
const [tags, setTags] = useState<string[]>([]);
|
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() {
|
async function getSavedComponents() {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue