update examples in MainPage using zustand
This commit is contained in:
parent
781d2705aa
commit
3b7f1928ff
3 changed files with 4 additions and 6 deletions
|
|
@ -58,10 +58,6 @@ export default function ComponentsComponent({
|
|||
});
|
||||
const start = (pageIndex - 1) * pageSize;
|
||||
const end = start + pageSize;
|
||||
const examples = all.filter(f=>(f.folder===STARTER_FOLDER_NAME && !f.user_id));
|
||||
console.log(examples);
|
||||
setExamples(examples);
|
||||
all = all.filter(f=>!(f.folder===STARTER_FOLDER_NAME && !f.user_id));;
|
||||
setData(all.slice(start, end));
|
||||
}, [flows, isLoading, pageIndex, pageSize]);
|
||||
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ export default function HomePage(): JSX.Element {
|
|||
<div className="flex flex-wrap w-full h-full p-4 gap-3">
|
||||
{examples.map((example, idx) => {
|
||||
return(
|
||||
<ExampleCardComponent flow={example} />)
|
||||
<ExampleCardComponent key={idx} flow={example} />)
|
||||
})}
|
||||
<NewFlowCardComponent/>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import useAlertStore from "./alertStore";
|
|||
import { useDarkStore } from "./darkStore";
|
||||
import useFlowStore from "./flowStore";
|
||||
import { useTypesStore } from "./typesStore";
|
||||
import { STARTER_FOLDER_NAME } from "../constants/constants";
|
||||
|
||||
let saveTimeoutId: NodeJS.Timeout | null = null;
|
||||
|
||||
|
|
@ -66,7 +67,8 @@ const useFlowsManagerStore = create<FlowsManagerStoreType>((set, get) => ({
|
|||
.then((dbData) => {
|
||||
if (dbData) {
|
||||
const { data, flows } = processFlows(dbData, false);
|
||||
get().setFlows(flows);
|
||||
get().setExamples(flows.filter(f=>(f.folder===STARTER_FOLDER_NAME && !f.user_id)));
|
||||
get().setFlows(flows.filter(f=>!(f.folder===STARTER_FOLDER_NAME && !f.user_id)));
|
||||
useTypesStore.setState((state) => ({
|
||||
data: { ...state.data, ["saved_components"]: data },
|
||||
}));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue