From eb9c93a635191ef9ec842592c4a85262811cf108 Mon Sep 17 00:00:00 2001
From: Skitty1238 <157652284+Skitty1238@users.noreply.github.com>
Date: Wed, 4 Jun 2025 21:05:47 -0400
Subject: allowed for incomplete tasks + fix for all day tasks not being added
 correctly + button styling

---
 src/client/views/nodes/TaskBox.tsx | 130 ++++++++++++-------------------------
 1 file changed, 42 insertions(+), 88 deletions(-)

(limited to 'src/client/views/nodes/TaskBox.tsx')

diff --git a/src/client/views/nodes/TaskBox.tsx b/src/client/views/nodes/TaskBox.tsx
index 8855e43c8..0d4fb622b 100644
--- a/src/client/views/nodes/TaskBox.tsx
+++ b/src/client/views/nodes/TaskBox.tsx
@@ -255,6 +255,48 @@ export class TaskBox extends React.Component<TaskBoxProps> {
                         <input type="checkbox" checked={isCompleted} onChange={this.toggleComplete} />
                         Complete
                     </label>
+
+                    <button
+                        className="task-manager-google"
+                        onClick={async event => {
+                            event.preventDefault();
+
+                            console.log('GT button clicked');
+                            try {
+                                const token = await GoogleAuthenticationManager.Instance.fetchOrGenerateAccessToken();
+                                console.log('Got token', token);
+
+                                const response = await fetch('/googleTasks/create', {
+                                    method: 'POST',
+                                    credentials: 'include',
+                                    headers: {
+                                        'Content-Type': 'application/json',
+                                        Authorization: `Bearer ${token}`,
+                                    },
+                                    body: JSON.stringify({
+                                        title: taskTitle || 'Untitled Task',
+                                        notes: taskDesc,
+                                        due: allDay ? new Date(String(doc.$task_dateRange)?.split('|')[0]).toISOString() : (doc.$task_endTime instanceof DateField && doc.$task_endTime.date?.toISOString()) || undefined,
+                                        status: doc.$task_completed ? 'completed' : 'needsAction',
+                                        completed: doc.$task_completed ? new Date().toISOString() : undefined,
+                                    }),
+                                });
+
+                                const result = await response.json();
+                                console.log('Google Task result:', result);
+
+                                if (result?.id) {
+                                    alert('✅ Task sent to Google Tasks!');
+                                } else {
+                                    alert(`❌ Failed: ${result?.error?.message || 'Unknown error'}`);
+                                }
+                            } catch (err) {
+                                console.error('Fetch error:', err);
+                                alert('❌ Task creation failed.');
+                            }
+                        }}>
+                        Add to Google
+                    </button>
                 </div>
 
                 {!allDay && (
@@ -269,94 +311,6 @@ export class TaskBox extends React.Component<TaskBoxProps> {
                         </label>
                     </div>
                 )}
-
-                {/** test button */}
-                {/* <button
-                    className="task-manager-google"
-                    onClick={async () => {
-                        console.log('GT button clicked');
-                        const token = await GoogleAuthenticationManager.Instance.fetchOrGenerateAccessToken();
-                        console.log('Got token', token);
-
-                        try {
-                            const response = await fetch('/googleTasks/create', {
-                                method: 'POST',
-                                credentials: 'include',
-                                headers: {
-                                    'Content-Type': 'application/json',
-                                    Authorization: `Bearer ${token}`,
-                                },
-                                body: JSON.stringify({
-                                    title: taskTitle || 'Untitled Task',
-                                    notes: taskDesc,
-                                    due: allDay ? String(doc.$task_dateRange)?.split('|')[0] + 'T23:59:00Z' : (doc.$task_endTime instanceof DateField && doc.$task_endTime.date?.toISOString()) || undefined,
-                                }),
-                            });
-
-                            const result = await response.text();
-                            console.log('Google Task result:', result);
-                            alert(result?.id ? 'Task sent to Google Tasks!' : `Failed: ${result?.error?.message || 'Unknown error'}`);
-                        } catch (err) {
-                            console.error('Fetch error:', err);
-                            alert('Fetch failed: ');
-                        }
-                    }}>
-                    GT
-                </button> */}
-
-                {/* <button
-                className="task-manager-google"
-                onClick={async () => {
-                    console.log('GT button clicked');
-                    const url = await Networking.FetchFromServer('/readGoogleAccessToken');
-                    console.log('🔗 Redirecting to Google auth:', url);
-                    window.location.href = url; // Redirect user to authenticate
-                }}
-                >
-                GT
-                </button> */}
-
-                <button
-                    className="task-manager-google"
-                    onClick={async event => {
-                        event.preventDefault();
-
-                        console.log('GT button clicked');
-                        try {
-                            const token = await GoogleAuthenticationManager.Instance.fetchOrGenerateAccessToken();
-                            console.log('Got token', token);
-
-                            const response = await fetch('/googleTasks/create', {
-                                method: 'POST',
-                                credentials: 'include',
-                                headers: {
-                                    'Content-Type': 'application/json',
-                                    Authorization: `Bearer ${token}`,
-                                },
-                                body: JSON.stringify({
-                                    title: taskTitle || 'Untitled Task',
-                                    notes: taskDesc,
-                                    due: allDay ? String(doc.$task_dateRange)?.split('|')[0] + 'T23:59:00Z' : (doc.$task_endTime instanceof DateField && doc.$task_endTime.date?.toISOString()) || undefined,
-                                    status: doc.$task_completed ? 'completed' : 'needsAction',
-                                    completed: doc.$task_completed ? new Date().toISOString() : undefined,
-                                }),
-                            });
-
-                            const result = await response.json();
-                            console.log('Google Task result:', result);
-
-                            if (result?.id) {
-                                alert('✅ Task sent to Google Tasks!');
-                            } else {
-                                alert(`❌ Failed: ${result?.error?.message || 'Unknown error'}`);
-                            }
-                        } catch (err) {
-                            console.error('Fetch error:', err);
-                            alert('❌ Task creation failed.');
-                        }
-                    }}>
-                    GT
-                </button>
             </div>
         );
     }
-- 
cgit v1.2.3-70-g09d2

