Set up contributor and detail scene
This commit is contained in:
parent
18850e9fb8
commit
e6536ca7c8
8 changed files with 73 additions and 3 deletions
18
src/store.ts
18
src/store.ts
|
|
@ -2,12 +2,19 @@ import create from 'zustand/vanilla';
|
|||
import { devtools } from 'zustand/middleware';
|
||||
import { Scenes } from './scenes/scenes';
|
||||
import { CompanionMessage, CompanionState } from './ui/companion';
|
||||
import project from '../metadata/project.json';
|
||||
import { getSubproject } from './helpers';
|
||||
import { SubProject } from './types';
|
||||
|
||||
export interface State {
|
||||
currentScene: Scenes;
|
||||
companionState: CompanionState;
|
||||
userMessages: CompanionMessage[];
|
||||
addUserMessage: (newMessage: CompanionMessage) => void;
|
||||
currContributors: any;
|
||||
currLegacy: any;
|
||||
currPackages: any;
|
||||
setDetailScene: (packageName: string) => void;
|
||||
}
|
||||
|
||||
const store = create<State>(
|
||||
|
|
@ -17,6 +24,17 @@ const store = create<State>(
|
|||
userMessages: [],
|
||||
addUserMessage: (newMessage) =>
|
||||
set((state) => ({ userMessages: [...state.userMessages, newMessage] })),
|
||||
currContributors: [],
|
||||
currLegacy: [],
|
||||
currPackages: [],
|
||||
setDetailScene: (packageName) =>
|
||||
set(() => ({
|
||||
currContributors: getSubproject(packageName, project.subprojects as SubProject[]).contents
|
||||
.contributors,
|
||||
currLegacy: getSubproject(packageName, project.subprojects as SubProject[]).contents.legacy,
|
||||
currPackages: getSubproject(packageName, project.subprojects as SubProject[]).contents
|
||||
.packages,
|
||||
})),
|
||||
}))
|
||||
);
|
||||
|
||||
|
|
|
|||
Reference in a new issue