Skip to content

Commit

Permalink
chore: add propsOnUpdate correct type
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanVor committed Feb 9, 2024
1 parent f7204ad commit a70ee5e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type {
RenderDndContainer,
} from '../../../../TreeSelect/DndTreeSelect';
import {block} from '../../../../utils/cn';
import type {TableColumnSetupItem} from '../withTableSettings';
import type {TableColumnSetupItem, TableSetting} from '../withTableSettings';

import i18n from './i18n';

Expand All @@ -37,7 +37,7 @@ export interface TableColumnSetupProps {
items: TableColumnSetupItem[];
sortable?: boolean;

onUpdate: (updated: TableColumnSetupItem[]) => void;
onUpdate: (newSettings: TableSetting[]) => void;
popupWidth?: DndTreeSelectProps<any>['popupWidth'];
popupPlacement?: PopperPlacement;
}
Expand Down Expand Up @@ -74,7 +74,8 @@ export const TableColumnSetup = (props: TableColumnSetupProps) => {
}, [propsItems]);

const onApply = () => {
propsOnUpdate(items);
const newSettings = items.map<TableSetting>(({id, isSelected}) => ({id, isSelected}));
propsOnUpdate(newSettings);
setOpen(false);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import userEvent from '@testing-library/user-event';
import {render, screen} from '../../../../../../test-utils/utils';
import type {TableColumnConfig} from '../../../Table';
import {Table} from '../../../Table';
import type {TableSettingsData} from '../withTableSettings';
import type {TableSetting} from '../withTableSettings';
import {withTableSettings} from '../withTableSettings';

const item = {name: 'John Doe', occupation: 'Worker'};
Expand All @@ -23,7 +23,7 @@ const columns: TableColumnConfig<typeof item>[] = [

const data = [item];

const settings: TableSettingsData = columns.map((column) => ({id: column.id, isSelected: true}));
const settings = columns.map<TableSetting>((column) => ({id: column.id, isSelected: true}));

test('should change table columns', async () => {
const updateSettings = jest.fn();
Expand Down

0 comments on commit a70ee5e

Please sign in to comment.