Skip to content

Commit 8ef26db

Browse files
patch: remove unused comments and fix project structure
1 parent 8681347 commit 8ef26db

4 files changed

Lines changed: 4 additions & 38 deletions

File tree

frontend/src/components/HomeComponents/Navbar/NavbarDesktop.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import { url } from '@/components/utils/URLs';
3838
import { exportTasksAsJSON, exportTasksAsTXT } from '@/exports-tasks';
3939
import { useState } from 'react';
4040
import { DevLogs } from '../DevLogs/DevLogs';
41-
import { useTaskAutoSync } from '@/Task-AutoSync';
41+
import { useTaskAutoSync } from '@/components/utils/Task-AutoSync';
4242
import { Label } from '@/components/ui/label';
4343

4444
export const NavbarDesktop = (

frontend/src/components/HomeComponents/Navbar/NavbarMobile.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import {
3737
import { Button } from '@/components/ui/button';
3838
import { exportTasksAsJSON, exportTasksAsTXT } from '@/exports-tasks';
3939
import { DevLogs } from '../DevLogs/DevLogs';
40-
import { useTaskAutoSync } from '@/Task-AutoSync';
40+
import { useTaskAutoSync } from '@/components/utils/Task-AutoSync';
4141
import { Label } from '@/components/ui/label';
4242
import { Switch } from '@/components/ui/switch';
4343
import { Slider } from '@/components/ui/slider';

frontend/src/components/HomeComponents/Tasks/report-download-utils.ts

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,29 @@
11
import html2canvas from 'html2canvas';
22
import { toast } from 'react-toastify';
33

4-
/**
5-
* Interface for report data structure
6-
*/
74
export interface ReportData {
85
name: string;
96
completed: number;
107
ongoing: number;
118
}
129

13-
/**
14-
* Generates and downloads a CSV file from report data
15-
* @param data - Array of report data objects
16-
* @param reportType - Type of report (e.g., "Daily", "Weekly", "Monthly")
17-
*/
1810
export const exportReportToCSV = (
1911
data: ReportData[],
2012
reportType: string
2113
): void => {
2214
try {
23-
// Create CSV header
2415
const headers = ['Report Type', 'Completed', 'Ongoing'];
25-
26-
// Create CSV rows
2716
const rows = data.map((item) => [
2817
item.name,
2918
item.completed.toString(),
3019
item.ongoing.toString(),
3120
]);
3221

33-
// Combine headers and rows
3422
const csvContent = [
3523
headers.join(','),
3624
...rows.map((row) => row.join(',')),
3725
].join('\n');
3826

39-
// Create blob and download
4027
const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
4128
const filename = generateFileName(reportType, 'csv');
4229
downloadFile(blob, filename);
@@ -54,12 +41,6 @@ export const exportReportToCSV = (
5441
}
5542
};
5643

57-
/**
58-
* Captures a chart element as PNG and downloads it
59-
* @param elementId - DOM element ID of the chart container
60-
* @param reportType - Type of report (e.g., "Daily", "Weekly", "Monthly")
61-
* @returns Promise that resolves when download is complete
62-
*/
6344
export const exportChartToPNG = async (
6445
elementId: string,
6546
reportType: string
@@ -71,15 +52,13 @@ export const exportChartToPNG = async (
7152
throw new Error(`Element with ID "${elementId}" not found`);
7253
}
7354

74-
// Create canvas from the element
7555
const canvas = await html2canvas(element, {
7656
backgroundColor: '#1c1c1c',
7757
scale: 2, // Higher quality
7858
logging: false,
7959
useCORS: true,
8060
});
8161

82-
// Convert canvas to blob
8362
const blob = await new Promise<Blob>((resolve, reject) => {
8463
canvas.toBlob((blob) => {
8564
if (blob) {
@@ -106,11 +85,6 @@ export const exportChartToPNG = async (
10685
}
10786
};
10887

109-
/**
110-
* Triggers a file download in the browser
111-
* @param blob - File blob to download
112-
* @param filename - Name of the file to save
113-
*/
11488
const downloadFile = (blob: Blob, filename: string): void => {
11589
const url = URL.createObjectURL(blob);
11690
const link = document.createElement('a');
@@ -121,17 +95,10 @@ const downloadFile = (blob: Blob, filename: string): void => {
12195
document.body.appendChild(link);
12296
link.click();
12397

124-
// Cleanup
12598
document.body.removeChild(link);
12699
URL.revokeObjectURL(url);
127100
};
128101

129-
/**
130-
* Generates a standardized filename for downloads
131-
* @param reportType - Type of report (e.g., "Daily", "Weekly", "Monthly")
132-
* @param extension - File extension (csv or png)
133-
* @returns Formatted filename string
134-
*/
135102
const generateFileName = (reportType: string, extension: string): string => {
136103
const date = new Date();
137104
const dateStr = date.toISOString().split('T')[0]; // YYYY-MM-DD format

frontend/src/Task-AutoSync.tsx renamed to frontend/src/components/utils/Task-AutoSync.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { useCallback, useEffect } from 'react';
2-
// We still don't need 'Props'
3-
import { syncTasksWithTwAndDb } from './components/HomeComponents/Tasks/Tasks';
4-
import { AutoSyncProps } from './components/utils/types';
2+
import { syncTasksWithTwAndDb } from '../HomeComponents/Tasks/Tasks';
3+
import { AutoSyncProps } from './types';
54

65
export const useTaskAutoSync = (props: AutoSyncProps) => {
76
const { isLoading, setIsLoading, isAutoSyncEnabled, syncInterval } = props;

0 commit comments

Comments
 (0)