Skip to content

Commit

Permalink
Add support for updated_title_roles (#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
vvillait88 authored Dec 17, 2024
1 parent 619e22b commit bc7a9d7
Show file tree
Hide file tree
Showing 3 changed files with 444 additions and 440 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pdl-react-autocomplete",
"version": "1.2.7",
"version": "1.3.0",
"description": "A react component for the People Data Labs Autocomplete API",
"source": "src/index.ts",
"module": "dist/index.mjs",
Expand Down Expand Up @@ -38,9 +38,9 @@
"url": "https://github.com/peopledatalabs/pdl-react-autocomplete/issues"
},
"devDependencies": {
"@parcel/packager-ts": "^2.13.2",
"@parcel/transformer-react-refresh-wrap": "^2.13.2",
"@parcel/transformer-typescript-types": "^2.13.2",
"@parcel/packager-ts": "^2.13.3",
"@parcel/transformer-react-refresh-wrap": "^2.13.3",
"@parcel/transformer-typescript-types": "^2.13.3",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@typescript-eslint/eslint-plugin": "^7.18.0",
Expand All @@ -55,7 +55,7 @@
"eslint-plugin-simple-import-sort": "^12.1.1",
"eslint-plugin-typescript-sort-keys": "^3.3.0",
"eslint-plugin-unused-imports": "^3.2.0",
"parcel": "^2.13.2",
"parcel": "^2.13.3",
"typescript": "^5.7.2"
},
"peerDependencies": {
Expand Down
6 changes: 5 additions & 1 deletion src/Autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ interface AutocompleteProps {
placeholder: string,
size?: number,
titlecase?: boolean,
updated_title_roles?: boolean,
}

function Autocomplete({
field, size, onTermSelected, apiKey, placeholder, titlecase,
field, size, onTermSelected, apiKey, placeholder, titlecase, updated_title_roles,
}: AutocompleteProps) {
const [searchTerm, setSearchTerm] = useState('');
const [searchResults, setSearchResults] = useState < { count: number, name: string }[] >([]);
Expand Down Expand Up @@ -48,6 +49,7 @@ function Autocomplete({
let reqURL = `https://api.peopledatalabs.com/v5/autocomplete?field=${field}&text=${searchTerm}`;
if (size !== undefined) reqURL += `&size=${size}`;
if (titlecase) reqURL += '&titlecase=true';
if (updated_title_roles) reqURL += '&updated_title_roles=true';

const response = await fetch(reqURL, {
headers: {
Expand Down Expand Up @@ -177,6 +179,8 @@ function Autocomplete({

const placeholderText = () => {
switch (field) {
case 'class':
return 'IE: sales_and_marketing';
case 'company':
return 'IE: people data labs';
case 'country':
Expand Down
Loading

0 comments on commit bc7a9d7

Please sign in to comment.