added image support and horizontal line support

This commit is contained in:
2026-02-20 15:23:14 -06:00
parent 9d8e80a2bf
commit e0cf9aa122
6 changed files with 289 additions and 10 deletions
+26 -1
View File
@@ -41,6 +41,7 @@ export interface Task {
};
size?: number; // 0-10, task complexity/size
sharedWith?: Array<{ userId: string; access: 'view' | 'edit' }>; // Users this task is shared with
attachments?: string[]; // Array of filenames from PocketBase
}
export const checkRecurringTasks = () => {
@@ -423,10 +424,34 @@ const mapRecordToTask = (r: any): Task => {
updated: r.updated,
recurrence: r.recurrence,
size: (r.size === null || r.size === undefined) ? undefined : r.size,
sharedWith: r.sharedWith
sharedWith: r.sharedWith,
attachments: r.attachments || []
};
};
export const uploadTaskAttachment = async (taskId: string, file: File): Promise<string> => {
try {
const formData = new FormData();
formData.append('attachments', file);
const record = await pb.collection(TASGRID_COLLECTION).update(taskId, formData);
// Return the URL for the newly uploaded file. PocketBase appends new files to the array.
// We need to find the specific filename that was just uploaded to get its URL.
// Since we don't know the exact generated filename, we can return the URL of the last file in the array.
if (record.attachments && record.attachments.length > 0) {
const latestFilename = record.attachments[record.attachments.length - 1];
return pb.files.getURL(record, latestFilename);
}
throw new Error("File uploaded but no attachment returned");
} catch (err: any) {
console.error("Error uploading attachment:", err);
toast.error("Failed to upload image.");
throw err;
}
};
const mapRecordToShareRule = (r: any): ShareRule => {
return {
id: r.id,