Skip to content

Commit

Permalink
expensegroup to typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
MikesGlitch committed Nov 11, 2023
1 parent 22efe74 commit 6628f66
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,36 @@
import React from 'react';
import React, { type ComponentProps } from 'react';

import { theme } from '../../style';
import View from '../common/View';
import { useDraggable, useDroppable, DropHighlight } from '../sort';
import {
useDraggable,
useDroppable,
DropHighlight,
type OnDragChangeCallback,
type OnDropCallback,
type DragState,
} from '../sort';
import { Row, ROW_HEIGHT } from '../table';

import RenderMonths from './RenderMonths';
import SidebarGroup from './SidebarGroup';

type ExpenseGroupProps = {
group: ComponentProps<typeof SidebarGroup>['group'];
collapsed: boolean;
editingCell: { id: string; cell: string } | null;
dragState: DragState;
MonthComponent: ComponentProps<typeof RenderMonths>['component'];
onEditName?: ComponentProps<typeof SidebarGroup>['onEdit'];
onSave?: ComponentProps<typeof SidebarGroup>['onSave'];
onDelete?: ComponentProps<typeof SidebarGroup>['onDelete'];
onDragChange: OnDragChangeCallback;
onReorderGroup: OnDropCallback;
onReorderCategory: OnDropCallback;
onToggleCollapse?: ComponentProps<typeof SidebarGroup>['onToggleCollapse'];
onShowNewCategory?: ComponentProps<typeof SidebarGroup>['onShowNewCategory'];
};

function ExpenseGroup({
group,
collapsed,
Expand All @@ -22,7 +45,7 @@ function ExpenseGroup({
onReorderCategory,
onToggleCollapse,
onShowNewCategory,
}) {
}: ExpenseGroupProps) {
let dragging = dragState && dragState.item === group;

let { dragRef } = useDraggable({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type SidebarGroupProps = {
};
editing?: boolean;
collapsed: boolean;
dragPreview?: () => void;
dragPreview?: boolean;
innerRef?: ConnectDragSource;
borderColor?: string;
style?: CSSProperties;
Expand Down
3 changes: 2 additions & 1 deletion packages/desktop-client/src/components/sort.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ import { theme } from '../style';

import View from './common/View';

type DragState = {
export type DragState = {
state: 'start-preview' | 'start' | 'end';
type?: string;
item?: unknown;
preview?: boolean;
};

export type DropPosition = 'top' | 'bottom';
Expand Down

0 comments on commit 6628f66

Please sign in to comment.