forked from atlassian/react-beautiful-dnd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.js
41 lines (35 loc) · 782 Bytes
/
data.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// @flow
import type { Column, Entities, TaskMap } from './types';
import type { Task, Id } from '../types';
const tasks: Task[] = Array.from({ length: 20 }, (v, k) => k).map(
(val: number): Task => ({
id: `task-${val}`,
content: `Task ${val}`,
}),
);
const taskMap: TaskMap = tasks.reduce(
(previous: TaskMap, current: Task): TaskMap => {
previous[current.id] = current;
return previous;
},
{},
);
const todo: Column = {
id: 'todo',
title: 'To do',
taskIds: tasks.map((task: Task): Id => task.id),
};
const done: Column = {
id: 'done',
title: 'Done',
taskIds: [],
};
const entities: Entities = {
columnOrder: [todo.id, done.id],
columns: {
[todo.id]: todo,
[done.id]: done,
},
tasks: taskMap,
};
export default entities;