-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from merzainc/fix-state-issues
Fix: consolidate gameQuery state using zustand
- Loading branch information
Showing
13 changed files
with
83 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { create } from 'zustand'; | ||
|
||
export interface GameQuery { | ||
genreId?: number; | ||
platformId?: number; | ||
sortOrder?: string; | ||
searchText?: string; | ||
} | ||
|
||
interface GameQueryStore { | ||
gameQuery: GameQuery; | ||
setSearchText: (searchText: string) => void; | ||
setGenreId: (genreId: number) => void; | ||
setPlatformId: (platformId: number) => void; | ||
setSortOrder: (sortOrder: string) => void; | ||
} | ||
|
||
const useGameQueryStore = create<GameQueryStore>((set) => ({ | ||
gameQuery: {}, | ||
setSearchText: (searchText) => set(() => ({ gameQuery: { searchText } })), | ||
setGenreId: (genreId) => | ||
set(({ gameQuery }) => ({ gameQuery: { ...gameQuery, genreId } })), | ||
setPlatformId: (platformId) => | ||
set((store) => ({ gameQuery: { ...store.gameQuery, platformId } })), | ||
setSortOrder: (searchText) => | ||
set((store) => ({ gameQuery: { ...store.gameQuery, searchText } })), | ||
})); | ||
|
||
export default useGameQueryStore; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { defineConfig } from 'vite' | ||
import react from '@vitejs/plugin-react-swc' | ||
import { defineConfig } from 'vite'; | ||
import react from '@vitejs/plugin-react-swc'; | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [react()], | ||
}) | ||
}); |