[ui][companies typeahead] Add isLabelHidden and placeHolder props (#361)

* [ui][companies typeahead] add isLabelHidden and placeHolder props

* [ui][companies typeahead] add isLabelHidden and placeHolder props
This commit is contained in:
Ai Ling
2022-10-11 19:53:21 +08:00
committed by GitHub
parent 73e1f76570
commit 325a2d1f7c
2 changed files with 13 additions and 1 deletions

View File

@ -6,10 +6,17 @@ import { trpc } from '~/utils/trpc';
type Props = Readonly<{
disabled?: boolean;
isLabelHidden?: boolean;
onSelect: (option: TypeaheadOption) => void;
placeHolder?: string;
}>;
export default function CompaniesTypeahead({ disabled, onSelect }: Props) {
export default function CompaniesTypeahead({
disabled,
onSelect,
isLabelHidden,
placeHolder,
}: Props) {
const [query, setQuery] = useState('');
const companies = trpc.useQuery([
'companies.list',
@ -23,6 +30,7 @@ export default function CompaniesTypeahead({ disabled, onSelect }: Props) {
return (
<Typeahead
disabled={disabled}
isLabelHidden={isLabelHidden}
label="Company"
noResultsMessage="No companies found"
nullable={true}
@ -33,6 +41,7 @@ export default function CompaniesTypeahead({ disabled, onSelect }: Props) {
value: id,
})) ?? []
}
placeholder={placeHolder}
onQueryChange={setQuery}
onSelect={onSelect}
/>