refactor: add 'stores' folder and move challenges store

This commit is contained in:
Tom (plebeius.eth)
2024-05-31 10:28:57 +02:00
parent 531be45dd7
commit cd6e56a704
4 changed files with 5 additions and 5 deletions
-24
View File
@@ -1,24 +0,0 @@
import { create } from 'zustand';
import { Challenge } from '@plebbit/plebbit-react-hooks';
interface State {
challenges: Challenge[];
addChallenge: (challenge: Challenge) => void;
removeChallenge: () => void;
}
const useChallengesStore = create<State>((set) => ({
challenges: [],
addChallenge: (challenge: Challenge) => {
set((state) => ({ challenges: [...state.challenges, challenge] }));
},
removeChallenge: () => {
set((state) => {
const challenges = [...state.challenges];
challenges.shift();
return { challenges };
});
},
}));
export default useChallengesStore;
+1 -1
View File
@@ -1,8 +1,8 @@
import { useMemo } from 'react';
import { ChallengeVerification, Comment, PublishCommentOptions, usePublishComment } from '@plebbit/plebbit-react-hooks';
import { create } from 'zustand';
import useChallengesStore from './use-challenges';
import { alertChallengeVerificationFailed } from '../lib/utils/challenge-utils';
import useChallengesStore from '../stores/use-challenges-store';
type SetReplyStoreData = {
subplebbitAddress: string;