Preselect default task (#22)

This commit is contained in:
Manuel Bouza
2019-09-18 12:54:54 +02:00
committed by Tobias Miesel
parent 5e62e16751
commit 8a72f242f9
4 changed files with 95 additions and 47 deletions

View File

@@ -10,6 +10,8 @@ import {
find,
curry,
pick,
head,
defaultTo,
} from "lodash/fp"
import { format } from "date-fns"
@@ -42,11 +44,19 @@ export const findTask = id =>
get("tasks"),
)
export const defaultTask = tasks =>
compose(
defaultTo(head(tasks)),
find(pathEq("isDefault", true)),
nilToArray,
)(tasks)
function taskOptions(tasks) {
return tasks.map(({ id, name, billable }) => ({
return tasks.map(({ id, name, billable, default: isDefault }) => ({
label: billable ? name : `(${name})`,
value: id,
billable,
isDefault,
}))
}