Skip to content

Commit 55cca6d

Browse files
committed
#3845 Prettier Check
1 parent bbe02a1 commit 55cca6d

1 file changed

Lines changed: 22 additions & 25 deletions

File tree

src/frontend/src/pages/GanttPage/GanttChart/GanttChartComponents/GanttTaskBar/GanttTaskBarEditView.tsx

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { ArcherElement } from 'react-archer';
1616
import { v4 as uuidv4 } from 'uuid';
1717

1818
const CELL_SIZE_PX = 38 + 2; // 38px cell + 2px for borders (1px each side)
19-
const GAP_SIZE_PX = 10; // empirically determined, see note above
19+
const GAP_SIZE_PX = 10; // empirically determined, see note above
2020
const WIDTH_PER_DAY = 7.2; //width per day to use for resizing calculations, kind of arbitrary,
2121

2222
interface GanttTaskBarEditProps<T> {
@@ -72,14 +72,11 @@ export const GanttTaskBarEditView = <T,>({
7272
right: '-10'
7373
};
7474

75-
const getCorrectWidth = useCallback(
76-
(rawWidth: number) => {
77-
const newEventLengthInDays = floorToMultipleOf7(rawWidth / WIDTH_PER_DAY);
78-
const displayWeeks = newEventLengthInDays / 7 + 1;
79-
return displayWeeks * CELL_SIZE_PX + (displayWeeks - 1) * GAP_SIZE_PX;
80-
},
81-
[]
82-
);
75+
const getCorrectWidth = useCallback((rawWidth: number) => {
76+
const newEventLengthInDays = floorToMultipleOf7(rawWidth / WIDTH_PER_DAY);
77+
const displayWeeks = newEventLengthInDays / 7 + 1;
78+
return displayWeeks * CELL_SIZE_PX + (displayWeeks - 1) * GAP_SIZE_PX;
79+
}, []);
8380

8481
useEffect(() => {
8582
if (!hasMeasuredRef.current && bounds.width > 0) {
@@ -101,7 +98,7 @@ export const GanttTaskBarEditView = <T,>({
10198
};
10299

103100
const handleMouseDown = (e: MouseEvent<HTMLElement>) => {
104-
const bar = (e.currentTarget as HTMLElement).closest('[data-gantt-bar]')
101+
const bar = (e.currentTarget as HTMLElement).closest('[data-gantt-bar]');
105102
if (!bar) return;
106103

107104
boxRef.current = (e.currentTarget as HTMLElement).closest('[data-gantt-bar]') as HTMLDivElement;
@@ -118,21 +115,21 @@ export const GanttTaskBarEditView = <T,>({
118115
};
119116

120117
const handleMouseUp = () => {
121-
if (isResizing) {
122-
setIsResizing(false);
123-
const newEventLengthInDays = floorToMultipleOf7(width / WIDTH_PER_DAY);
124-
const displayWeeks = newEventLengthInDays / 7 + 1;
125-
const correctWidth = displayWeeks * 40 + (displayWeeks - 1) * 10;
126-
setWidth(correctWidth);
127-
createChange({
128-
id: uuidv4(),
129-
element: task.element,
130-
type: 'change-end-date',
131-
originalEnd: task.end,
132-
newEnd: addDaysToDate(task.start, newEventLengthInDays)
133-
});
134-
}
135-
};
118+
if (isResizing) {
119+
setIsResizing(false);
120+
const newEventLengthInDays = floorToMultipleOf7(width / WIDTH_PER_DAY);
121+
const displayWeeks = newEventLengthInDays / 7 + 1;
122+
const correctWidth = displayWeeks * 40 + (displayWeeks - 1) * 10;
123+
setWidth(correctWidth);
124+
createChange({
125+
id: uuidv4(),
126+
element: task.element,
127+
type: 'change-end-date',
128+
originalEnd: task.end,
129+
newEnd: addDaysToDate(task.start, newEventLengthInDays)
130+
});
131+
}
132+
};
136133

137134
const onDragStart = () => {
138135
setShowDropPoints(true);

0 commit comments

Comments
 (0)