1
0
Fork 0
mirror of synced 2024-10-05 12:34:50 +13:00

Send search term to api call

This commit is contained in:
Adria Navarro 2023-05-08 14:54:43 +02:00
parent 8bbfa7e0ab
commit d33a06c89c
3 changed files with 25 additions and 4 deletions

View file

@ -1,7 +1,7 @@
<script>
import EditUserPicker from "./EditUserPicker.svelte"
import { Heading, Pagination, Table } from "@budibase/bbui"
import { Heading, Pagination, Table, Search } from "@budibase/bbui"
import { fetchData } from "@budibase/frontend-core"
import { goto } from "@roxi/routify"
import { API } from "api"
@ -12,7 +12,9 @@
export let groupId
const fetchGroupUsers = fetchData({
let searchTerm
let fetchGroupUsers
$: fetchGroupUsers = fetchData({
API,
datasource: {
type: "groupUser",
@ -20,6 +22,7 @@
options: {
query: {
groupId,
searchTerm,
},
},
})
@ -67,6 +70,9 @@
{/if}
</div>
<div class="controls-right">
<Search bind:value={searchTerm} placeholder="Search" />
</div>
<Table
schema={userSchema}
data={$fetchGroupUsers?.rows}
@ -109,4 +115,15 @@
width: 100%;
text-align: center;
}
.controls-right {
display: flex;
flex-direction: row;
justify-content: flex-end;
align-items: center;
gap: var(--spacing-xl);
}
.controls-right :global(.spectrum-Search) {
width: 200px;
}
</style>

View file

@ -55,10 +55,13 @@ export const buildGroupsEndpoints = API => {
/**
* Gets a group users by the group id
*/
getGroupUsers: async ({ id, bookmark }) => {
getGroupUsers: async ({ id, bookmark, searchTerm }) => {
let url = `/api/global/groups/${id}/users?`
if (bookmark) {
url += `bookmark=${bookmark}`
url += `bookmark=${bookmark}&`
}
if (searchTerm) {
url += `searchTerm=${searchTerm}&`
}
return await API.get({

View file

@ -31,6 +31,7 @@ export default class GroupUserFetch extends DataFetch {
try {
const res = await this.API.getGroupUsers({
id: query.groupId,
searchTerm: query.searchTerm,
bookmark: cursor,
})