guesstimate/client/src/models/task.ts

46 lines
983 B
TypeScript
Raw Normal View History

2020-04-23 08:45:22 +02:00
import { uuidV4, base58UUID } from "../util/uuid"
2020-04-22 22:48:47 +02:00
import { defaults } from "./params";
2020-04-20 11:14:46 +02:00
export type TaskID = string
export enum EstimationConfidence {
Optimistic = "optimistic",
Likely = "likely",
Pessimistic = "pessimistic"
}
export interface Task {
id: TaskID
label: string
2020-04-21 20:45:47 +02:00
category: TaskCategoryID
2020-04-20 11:14:46 +02:00
estimations: { [confidence in EstimationConfidence]: number }
}
2020-04-21 20:45:47 +02:00
export type TaskCategoryID = string
2020-04-20 11:14:46 +02:00
export interface TaskCategory {
2020-04-21 20:45:47 +02:00
id: TaskCategoryID
2020-04-20 11:14:46 +02:00
label: string
costPerTimeUnit: number
2020-04-20 11:14:46 +02:00
}
2020-04-21 20:45:47 +02:00
export function newTask(label: string, category: TaskCategoryID): Task {
2020-04-22 22:48:47 +02:00
return {
2020-04-23 08:45:22 +02:00
id: base58UUID(),
2020-04-22 22:48:47 +02:00
label,
category,
estimations: {
[EstimationConfidence.Optimistic]: 0,
[EstimationConfidence.Likely]: 0,
[EstimationConfidence.Pessimistic]: 0,
}
};
}
export function createTaskCategory(): TaskCategory {
return {
2020-04-23 08:45:22 +02:00
id: base58UUID(),
2020-04-22 22:48:47 +02:00
costPerTimeUnit: defaults.costPerTimeUnit,
label: ""
};
2020-04-20 11:14:46 +02:00
}