Skip to content

Commit

Permalink
Tweak generics
Browse files Browse the repository at this point in the history
  • Loading branch information
jessepinho committed Aug 17, 2024
1 parent f138171 commit eca6373
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions packages/ui/src/AssetSelector/AssetSelectorDialogContent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,25 @@ const OptionsWrapper = styled.div`
gap: ${props => props.theme.spacing(1)};
`;

export interface AssetSelectorDialogContentProps<IncludesBalancesResponses extends boolean> {
export interface AssetSelectorDialogContentProps<
ValueType extends (BalancesResponse | Metadata) | Metadata,
> {
title: string;
layoutId: string;
value?: IncludesBalancesResponses extends true ? BalancesResponse | Metadata : Metadata;
onChange: (
value: IncludesBalancesResponses extends true ? BalancesResponse | Metadata : Metadata,
) => void;
options: IncludesBalancesResponses extends true ? (BalancesResponse | Metadata)[] : Metadata[];
value?: ValueType;
onChange: (value: ValueType) => void;
options: ValueType[];
}

export const AssetSelectorDialogContent = <IncludesBalancesResponses extends boolean>({
export const AssetSelectorDialogContent = <
ValueType extends (BalancesResponse | Metadata) | Metadata,
>({
title,
layoutId,
value,
onChange,
options,
}: AssetSelectorDialogContentProps<IncludesBalancesResponses>) => {
}: AssetSelectorDialogContentProps<ValueType>) => {
const [search, setSearch] = useState('');
const filteredOptions = useMemo(
() => options.filter(filterMetadataOrBalancesResponseByText(search)),
Expand Down

0 comments on commit eca6373

Please sign in to comment.