feat: extend getInstanceWithSteps query to include notes metadata

- Added new fields for tracking who updated notes, their names, and the timestamp of the update.
- Refactored the retrieval of the updater's name to improve code clarity and efficiency.
- Enhanced the data structure returned by the query to support additional notes-related information.
This commit is contained in:
2025-11-26 10:21:13 -03:00
parent 6128c20da0
commit daee99191c
3 changed files with 93 additions and 1 deletions

View File

@@ -891,6 +891,9 @@ export const getInstanceWithSteps = query({
startedAt: number | undefined;
finishedAt: number | undefined;
notes: string | undefined;
notesUpdatedBy: Id<'usuarios'> | undefined;
notesUpdatedByName: string | undefined;
notesUpdatedAt: number | undefined;
dueDate: number | undefined;
position: number;
expectedDuration: number;
@@ -929,6 +932,7 @@ export const getInstanceWithSteps = query({
});
}
const notesUpdater = step.notesUpdatedBy ? await ctx.db.get(step.notesUpdatedBy) : null;
stepsWithDetails.push({
_id: step._id,
_creationTime: step._creationTime,
@@ -945,7 +949,7 @@ export const getInstanceWithSteps = query({
finishedAt: step.finishedAt,
notes: step.notes,
notesUpdatedBy: step.notesUpdatedBy,
notesUpdatedByName: step.notesUpdatedBy ? (await ctx.db.get(step.notesUpdatedBy))?.nome : undefined,
notesUpdatedByName: notesUpdater?.nome,
notesUpdatedAt: step.notesUpdatedAt,
dueDate: step.dueDate,
position: flowStep?.position ?? 0,