Skip to content

Commit

Permalink
fix: add const to storage a delay value
Browse files Browse the repository at this point in the history
  • Loading branch information
Josmar-jr committed Sep 25, 2024
1 parent b528e25 commit 64463c8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion react/components/CostCentersAutocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useIntl } from 'react-intl'

import { messages } from './customers-admin'
import GET_COST_CENTER_BY_ORG from '../queries/costCentersByOrg.gql'
import { SEARCH_TERM_DELAY_MS } from '../constants/debounceDelay'

interface Props {
onChange: (value: { value: string | null; label: string }) => void
Expand Down Expand Up @@ -43,7 +44,7 @@ const CostCenterAutocomplete = ({ onChange, organizationId }: Props) => {
useEffect(() => {
const handler = setTimeout(() => {
setDebouncedSearchTerm(costCenterTextInput)
}, 500) // 500ms delay
}, SEARCH_TERM_DELAY_MS) // 500ms delay

return () => {
clearTimeout(handler)
Expand Down
3 changes: 2 additions & 1 deletion react/components/OrganizationsAutocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useIntl } from 'react-intl'
import { messages } from './customers-admin'
import GET_ORGANIZATIONS from '../queries/listOrganizations.gql'
import GET_ORGANIZATION_BY_ID from '../queries/getOrganization.graphql'
import { SEARCH_TERM_DELAY_MS } from '../constants/debounceDelay'

const initialState = {
status: ['active', 'on-hold', 'inactive'],
Expand Down Expand Up @@ -50,7 +51,7 @@ const OrganizationsAutocomplete = ({ onChange, organizationId }: Props) => {
useEffect(() => {
const handler = setTimeout(() => {
setDebouncedTerm(term)
}, 500) // 500ms delay
}, SEARCH_TERM_DELAY_MS) // 500ms delay

return () => clearTimeout(handler)
}, [term])
Expand Down
1 change: 1 addition & 0 deletions react/constants/debounceDelay.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const SEARCH_TERM_DELAY_MS = 500

0 comments on commit 64463c8

Please sign in to comment.