Skip to content

Commit

Permalink
TypeScript migration (partial). (#1660)
Browse files Browse the repository at this point in the history
  • Loading branch information
doggan committed Sep 6, 2023
1 parent 319d196 commit 21d5f11
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ export function SchedulesTable({
<Row
height={ROW_HEIGHT}
inset={15}
backgroundColor="transparent"
onClick={() => onSelect(item.id)}
style={{
cursor: 'pointer',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import CheckCircleHollow from '../../icons/v2/CheckCircleHollow';
import EditSkull1 from '../../icons/v2/EditSkull1';
import FavoriteStar from '../../icons/v2/FavoriteStar';
import ValidationCheck from '../../icons/v2/ValidationCheck';
import { colors } from '../../style';
import { colors, type CSSProperties } from '../../style';
import Text from '../common/Text';
import View from '../common/View';

export function getStatusProps(status) {
export function getStatusProps(status: Status) {
let color, backgroundColor, Icon;

switch (status) {
Expand Down Expand Up @@ -67,7 +67,22 @@ export function getStatusProps(status) {
return { color, backgroundColor, Icon };
}

export function StatusBadge({ status, style }) {
type Status =
| 'missed'
| 'due'
| 'upcoming'
| 'paid'
| 'completed'
| 'pending'
| 'scheduled'
| 'cleared';

type StatusBadgeProps = {
status: Status;
style?: CSSProperties;
};

export function StatusBadge({ status, style }: StatusBadgeProps) {
let { color, backgroundColor, Icon } = getStatusProps(status);
return (
<View
Expand Down
14 changes: 6 additions & 8 deletions packages/desktop-client/src/components/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -858,8 +858,8 @@ type TableProps = {
items: TableItem[];
count?: number;
headers?: ReactNode | TableHeaderProps['headers'];
contentHeader: ReactNode;
loading: boolean;
contentHeader?: ReactNode;
loading?: boolean;
rowHeight?: number;
backgroundColor?: string;
renderItem: (arg: {
Expand All @@ -871,16 +871,15 @@ type TableProps = {
position: number;
}) => ReactNode;
renderEmpty?: ReactNode | (() => ReactNode);
getItemKey: (index: number) => TableItem['id'];
getItemKey?: (index: number) => TableItem['id'];
loadMore?: () => void;
style?: CSSProperties;
navigator: ReturnType<typeof useTableNavigator>;
listRef;
onScroll: () => void;
navigator?: ReturnType<typeof useTableNavigator>;
onScroll?: () => void;
version?: string;
allowPopupsEscape?: boolean;
isSelected?: (id: TableItem['id']) => boolean;
saveScrollWidth: (parent, child) => void;
saveScrollWidth?: (parent, child) => void;
};

export const Table = forwardRef<TableHandleRef, TableProps>(
Expand All @@ -899,7 +898,6 @@ export const Table = forwardRef<TableHandleRef, TableProps>(
loadMore,
style,
navigator,
listRef,
onScroll,
version = 'v1',
allowPopupsEscape,
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/1660.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Maintenance
authors: [doggan]
---

Migrate some components to TypeScript.

0 comments on commit 21d5f11

Please sign in to comment.