Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer committed May 23, 2022
1 parent 4421942 commit 11ef9b2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/components/Table.vue
Expand Up @@ -87,7 +87,11 @@ const { table, search, colName } = await useTable({
})
// let's run the initial search upon page view/load
// eslint-disable-next-line no-console
console.log('running initial search')
const results = await search()
// eslint-disable-next-line no-console
console.log('initial search complete', results)
if (results)
table.results = results
Expand Down
7 changes: 4 additions & 3 deletions src/composables/table.ts
Expand Up @@ -43,7 +43,7 @@ const searchParams = computed(() => {
return {
offset: (table.currentPage - 1) * table.perPage,
limit: table.perPage,
sort: isString(table.sort) ? [table.sort] : null,
sort: isString(table.sort) ? [table.sort] : undefined,
}
})
const lastColumn = computed(() => {
Expand Down Expand Up @@ -142,9 +142,10 @@ function hasTableLoaded(state?: any): Boolean {
}

// we have to accept the query and searchParams because those params are watched in the watchEffect
async function search(q?: string, searchParams?: object): Promise<void | SearchResponse<Record<string, any>>> {
async function search(q?: string): Promise<void | SearchResponse<Record<string, any>>> {
// eslint-disable-next-line no-console
console.log('searching', q, searchParams)

if (!hasTableLoaded(table))
return

Expand All @@ -158,7 +159,7 @@ async function search(q?: string, searchParams?: object): Promise<void | SearchR
return
}

return await client().index(table.type).search(query, searchParams) // TODO: add search params (filters, sorts, etc)
return await client().index(table.type).search(query, searchParams.value) // TODO: add search params (filters, sorts, etc)
}
catch (error) {
console.error('error when performing search', error)
Expand Down

0 comments on commit 11ef9b2

Please sign in to comment.