Added a type for the sorting direction of SortMenu component (#19062)

refs https://github.com/TryGhost/Product/issues/4162
This commit is contained in:
Sodbileg Gansukh 2023-11-21 11:52:12 +08:00 committed by GitHub
parent ccd1e355e1
commit f3aadab613
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View File

@ -3,6 +3,8 @@ import Button, {ButtonProps} from './Button';
import Popover, {PopoverPosition} from './Popover';
import {Icon} from '..';
export type SortDirection = 'asc' | 'desc';
export type SortItem = {
id: string,
label: string;
@ -11,7 +13,7 @@ export type SortItem = {
export interface SortMenuProps {
items: SortItem[];
direction: string;
direction: SortDirection;
onSortChange: (selectedOption: string) => void;
onDirectionChange: (selectedDirection: string) => void;
trigger?: React.ReactNode;

View File

@ -244,8 +244,14 @@ export const OffersIndexModal = () => {
{id: 'redemptions', label: 'Redemptions'}
]}
position='right'
onDirectionChange={() => {}}
onSortChange={() => {}}
onDirectionChange={(selectedDirection) => {
// eslint-disable-next-line no-console
console.log(`Sorting direction: ${selectedDirection}`);
}}
onSortChange={(selectedOption) => {
// eslint-disable-next-line no-console
console.log(`Sorting option: ${selectedOption}`);
}}
/>
<div className='flex gap-3'>
<Button icon='layout-module-1' iconColorClass={selectedLayout === 'card' ? 'text-black' : 'text-grey-500'} link={true} size='sm' onClick={() => setSelectedLayout('card')} />