Skip to content

Commit

Permalink
fix: Role mapping search issue
Browse files Browse the repository at this point in the history
  • Loading branch information
dogukanoksuz committed Jul 5, 2024
1 parent 4d5979a commit 945f4ac
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/components/settings/async-transfer-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ interface ITransferListProps<T extends ITransferListItem> {
onSave?: (items: T[]) => void
onSearch?: (text: string) => void
renderName?: keyof T
defaultSearch?: string
}

const AsyncTransferList = <T extends ITransferListItem>(
Expand All @@ -41,7 +42,9 @@ const AsyncTransferList = <T extends ITransferListItem>(
const [checked, setChecked] = useState<T[]>([])
const [left, setLeft] = useState<T[]>([])
const [right, setRight] = useState<T[]>([])
const [leftSearch, setLeftSearch] = useState<string>("")
const [leftSearch, setLeftSearch] = useState<string>(
props.defaultSearch || ""
)
const [rightSearch, setRightSearch] = useState<string>("")

const handleSelectedProp = () => {
Expand Down
9 changes: 7 additions & 2 deletions src/components/settings/ldap-role-mapping.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { useEffect, useState } from "react"
import { apiService } from "@/services"
import { useTranslation } from "react-i18next"

import { useDebounce } from "@/lib/debounce"

import { SelectRole } from "../selectbox/role-select"
import { Card } from "../ui/card"
import { useToast } from "../ui/use-toast"
Expand All @@ -20,8 +22,9 @@ export default function LdapRoleMapping(props: {
const [roleList, setRoleList] = useState<any>([])
const [selectedRoleList, setSelectedRoleList] = useState<any>([])
const [selectedRole, setSelectedRole] = useState<string>("")
const [searchValue, setSearchValue] = useState<string>("")

const fetchRoleMappingList = (param?: string) => {
const fetchRoleMappingList = useDebounce((param?: string) => {
setRoleListLoading(true)
apiService
.getInstance()
Expand Down Expand Up @@ -54,8 +57,9 @@ export default function LdapRoleMapping(props: {
.finally(() => {
setRoleListLoading(false)
setKey((prev) => prev + 1)
setSearchValue(param || "")
})
}
}, 300)

const [key, setKey] = useState(0)

Expand Down Expand Up @@ -105,6 +109,7 @@ export default function LdapRoleMapping(props: {
onSave={handleRoleMappingSave}
onSearch={(v: string) => fetchRoleMappingList(v)}
key={key}
defaultSearch={searchValue}
/>
)}
</div>
Expand Down

0 comments on commit 945f4ac

Please sign in to comment.