♻️ (record) time range instead of step recordable

This commit is contained in:
Julien Calixte
2023-04-16 10:16:42 +02:00
parent 81cfab485e
commit d5c616e22b
4 changed files with 7 additions and 11 deletions

View File

@@ -1,14 +1,10 @@
import type { ISODate } from '@/shared/types/date'
import type { StepRecordable } from './step-recordable'
import type { TimeRange } from './time-range'
export interface Recordable {
taskId: string
/**
* @deprecated
* TODO: Compute this data from step records
*/
start: ISODate
end?: ISODate
stepRecords: Record<string, StepRecordable>
stepRecords: Record<string, TimeRange>
notes: string
}

View File

@@ -1,6 +1,6 @@
import type { ISODate } from '@/shared/types/date'
export interface StepRecordable {
export interface TimeRange {
start: ISODate
end?: ISODate
}

View File

@@ -1,11 +1,11 @@
import { toISODate, type ISODate } from '@/shared/types/date'
import type { Recordable } from '../interfaces/recordable'
import type { StepRecordable } from '../interfaces/step-recordable'
import type { TimeRange } from '../interfaces/time-range'
export class TaskRecord implements Recordable {
public start: ISODate = toISODate(new Date())
public end: ISODate | undefined = undefined
public stepRecords: Record<string, StepRecordable> = {}
public stepRecords: Record<string, TimeRange> = {}
public notes = ''
public constructor(public readonly taskId: string) {}

View File

@@ -1,7 +1,7 @@
import { toISODate, type ISODate } from '@/shared/types/date'
import { defineStore } from 'pinia'
import type { Recordable } from '../interfaces/recordable'
import type { StepRecordable } from '../interfaces/step-recordable'
import type { TimeRange } from '../interfaces/time-range'
import { TaskRecord } from '../models/task-record'
export interface TaskRecordStoreState {
@@ -133,7 +133,7 @@ export const useTaskRecordStore = defineStore('task-record-store', {
return (taskId: string): Recordable | null => this.records[taskId] ?? null
},
getStepRecord() {
return (taskId: string, stepId: string): StepRecordable | null =>
return (taskId: string, stepId: string): TimeRange | null =>
this.records[taskId]?.stepRecords[stepId] ?? null
},
getRecordNotes() {