trenesky commited on
Commit
3a91c1f
·
verified ·
1 Parent(s): 7062306

MERGE CALENDAR AND NOTES IN ONE - WHEN NOTE IS ADDED - PUT IT IN THE DATE IN CALENDAR WHEN IT IS ADDED (REMAIN THERE) - Follow Up Deployment

Browse files
Files changed (2) hide show
  1. index.html +8 -33
  2. prompts.txt +2 -1
index.html CHANGED
@@ -22,8 +22,7 @@
22
  </div>
23
  <div class="flex mt-4 border-b border-gray-200 dark:border-gray-700">
24
  <button id="tasks-tab" class="tab-button active px-4 py-2 font-medium text-blue-600 dark:text-blue-400 border-b-2 border-blue-500">Tasks</button>
25
- <button id="notes-tab" class="tab-button px-4 py-2 font-medium text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300">Notes</button>
26
- <button id="calendar-tab" class="tab-button px-4 py-2 font-medium text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300">Calendar</button>
27
  </div>
28
  </header>
29
 
@@ -34,12 +33,7 @@
34
  <ul id="tasks-list" class="space-y-3"></ul>
35
  </div>
36
 
37
- <!-- Notes Section -->
38
- <div id="notes-section" class="tab-content hidden">
39
- <ul id="notes-list" class="space-y-3"></ul>
40
- </div>
41
-
42
- <!-- Calendar Section -->
43
  <div id="calendar-section" class="tab-content hidden">
44
  <div class="bg-white dark:bg-gray-800 rounded-lg shadow p-4 mb-4">
45
  <div id="calendar-header" class="flex justify-between items-center mb-4">
@@ -212,25 +206,21 @@
212
  if (!text || !userName) return;
213
 
214
  const activeTab = document.querySelector('.tab-content.active').id.split('-')[0];
 
 
215
 
216
  let noteData = {
217
  text,
218
  userName,
219
- createdAt: serverTimestamp()
 
220
  };
221
 
222
  if (activeTab === 'tasks') {
223
  noteData.type = 'tasks';
224
  noteData.done = false; // tasks start unchecked
225
- } else if (activeTab === 'notes') {
226
- noteData.type = 'notes';
227
- } else if (activeTab === 'calendar') {
228
- if (!window.selectedDateStr) {
229
- alert("Please select a date first!");
230
- return;
231
- }
232
  noteData.type = 'calendar';
233
- noteData.date = window.selectedDateStr;
234
  }
235
 
236
  try {
@@ -287,20 +277,6 @@
287
  feather.replace();
288
  });
289
 
290
- // Notes
291
- const notesQuery = query(collection(db, "notes"), where("type","==","notes"), orderBy("createdAt","asc"));
292
- notesList.innerHTML = '<div class="text-center py-8"><div class="inline-block animate-spin h-8 w-8 border-t-2 border-b-2 border-blue-500 rounded-full"></div><p class="mt-2 text-gray-500">Loading notes...</p></div>';
293
- const unsubscribeNotes = onSnapshot(notesQuery, (snapshot) => {
294
- notesList.innerHTML = "";
295
- if (snapshot.empty) {
296
- notesList.innerHTML = '<div class="text-center py-8"><i data-feather="edit" class="w-12 h-12 mx-auto text-gray-400"></i><p class="mt-2 text-gray-500">No notes yet.</p></div>';
297
- feather.replace();
298
- return;
299
- }
300
- snapshot.forEach(docSnap => renderNoteItem({ id: docSnap.id, ...docSnap.data() }, notesList));
301
- feather.replace();
302
- });
303
-
304
  // Calendar load function
305
  window.loadDateNotes = function(dateStr) {
306
  window.selectedDateStr = dateStr;
@@ -316,7 +292,6 @@
316
 
317
  const q = query(
318
  collection(db, "notes"),
319
- where("type", "==", "calendar"),
320
  where("date", "==", dateStr),
321
  orderBy("createdAt","asc")
322
  );
@@ -335,7 +310,7 @@
335
  });
336
  };
337
 
338
- window.addEventListener('beforeunload', () => { unsubscribeTasks(); unsubscribeNotes(); if(window.unsubscribeCalendar) window.unsubscribeCalendar(); });
339
  </script>
340
 
341
  <style>
 
22
  </div>
23
  <div class="flex mt-4 border-b border-gray-200 dark:border-gray-700">
24
  <button id="tasks-tab" class="tab-button active px-4 py-2 font-medium text-blue-600 dark:text-blue-400 border-b-2 border-blue-500">Tasks</button>
25
+ <button id="calendar-tab" class="tab-button px-4 py-2 font-medium text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300">Calendar Notes</button>
 
26
  </div>
27
  </header>
28
 
 
33
  <ul id="tasks-list" class="space-y-3"></ul>
34
  </div>
35
 
36
+ <!-- Calendar Notes Section -->
 
 
 
 
 
37
  <div id="calendar-section" class="tab-content hidden">
38
  <div class="bg-white dark:bg-gray-800 rounded-lg shadow p-4 mb-4">
39
  <div id="calendar-header" class="flex justify-between items-center mb-4">
 
206
  if (!text || !userName) return;
207
 
208
  const activeTab = document.querySelector('.tab-content.active').id.split('-')[0];
209
+ const currentDate = new Date();
210
+ const dateStr = `${currentDate.getFullYear()}-${(currentDate.getMonth()+1).toString().padStart(2,'0')}-${currentDate.getDate().toString().padStart(2,'0')}`;
211
 
212
  let noteData = {
213
  text,
214
  userName,
215
+ createdAt: serverTimestamp(),
216
+ date: dateStr
217
  };
218
 
219
  if (activeTab === 'tasks') {
220
  noteData.type = 'tasks';
221
  noteData.done = false; // tasks start unchecked
222
+ } else {
 
 
 
 
 
 
223
  noteData.type = 'calendar';
 
224
  }
225
 
226
  try {
 
277
  feather.replace();
278
  });
279
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
280
  // Calendar load function
281
  window.loadDateNotes = function(dateStr) {
282
  window.selectedDateStr = dateStr;
 
292
 
293
  const q = query(
294
  collection(db, "notes"),
 
295
  where("date", "==", dateStr),
296
  orderBy("createdAt","asc")
297
  );
 
310
  });
311
  };
312
 
313
+ window.addEventListener('beforeunload', () => { unsubscribeTasks(); if(window.unsubscribeCalendar) window.unsubscribeCalendar(); });
314
  </script>
315
 
316
  <style>
prompts.txt CHANGED
@@ -16,4 +16,5 @@ calendar and task not working, should work
16
  fix notes and calendar, make them working tabs, same as tasks
17
  fix notes and calendar, make them working tabs, same as tasks
18
  added notes should remain in notes tab, not in tasks tab
19
- when task is added to be in task page, when note is added to be in notes page
 
 
16
  fix notes and calendar, make them working tabs, same as tasks
17
  fix notes and calendar, make them working tabs, same as tasks
18
  added notes should remain in notes tab, not in tasks tab
19
+ when task is added to be in task page, when note is added to be in notes page
20
+ MERGE CALENDAR AND NOTES IN ONE - WHEN NOTE IS ADDED - PUT IT IN THE DATE IN CALENDAR WHEN IT IS ADDED (REMAIN THERE)