Skip to content

Commit

Permalink
fix(search-filter): connect Search filter and endpoint request
Browse files Browse the repository at this point in the history
  • Loading branch information
MirzaHanan committed Sep 24, 2024
1 parent 77985bb commit 35c4429
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/stores/useDataStore/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export type FetchNodeParams = {
skip_cache?: string
free?: string
media_type?: string
node_type?: string
limit?: string
depth?: string
top_node_count?: string
}

export type SidebarFilterWithCount = {
Expand Down Expand Up @@ -136,7 +140,7 @@ export const useDataStore = create<DataStore>()(
devtools((set, get) => ({
...defaultData,

fetchData: async (setBudget, setAbortRequests, AISearchQuery = '') => {
fetchData: async (setBudget, setAbortRequests, AISearchQuery = '', params: FetchNodeParams = {}) => {
const { dataInitial: existingData, filters } = get()
const currentPage = filters.skip
const itemsPerPage = filters.limit
Expand Down Expand Up @@ -174,6 +178,7 @@ export const useDataStore = create<DataStore>()(

const updatedParams = {
...withoutNodeType,
...params,
...ai,
skip: currentPage === 0 ? String(currentPage * itemsPerPage) : String(currentPage * itemsPerPage + 1),
limit: word ? '25' : String(itemsPerPage),
Expand Down

0 comments on commit 35c4429

Please sign in to comment.