@educabot/educablocks-boards 0.2.35 → 0.2.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,118 +0,0 @@
1
- import { Board } from './types'
2
-
3
- type ExcludeProp = {
4
- prop: string
5
- value: string
6
- }
7
-
8
- type GetAllBoards = {
9
- boards: Board[],
10
- type?: string
11
- premium?: boolean
12
- disabled?: boolean
13
- hidden?: boolean
14
- exclude?: ExcludeProp
15
- include?: number[]
16
- }
17
-
18
- export const getAllBoards = ({
19
- boards,
20
- type = 'all',
21
- premium = true,
22
- disabled = true,
23
- hidden = false,
24
- exclude = {
25
- prop: '',
26
- value: ''
27
- },
28
- include = [],
29
- }: GetAllBoards): Board[] => {
30
- switch (type) {
31
- case 'machineLearning':
32
- return boards.filter(b =>
33
- b.type === 'machineLearning' &&
34
- (hidden || b.show === 1) &&
35
- (premium || !b.premium) &&
36
- (disabled || b.enabled) &&
37
- (!b[exclude.prop] || b[exclude.prop] !== exclude.value) &&
38
- (include.length === 0 || include.includes(b.id))
39
- )
40
- case 'senior':
41
- return boards.filter(b =>
42
- b.type === 'senior' &&
43
- (hidden || b.show === 1) &&
44
- (premium || !b.premium) &&
45
- (disabled || b.enabled) &&
46
- (!b[exclude.prop] || b[exclude.prop] !== exclude.value) &&
47
- (include.length === 0 || include.includes(b.id))
48
- )
49
- case 'junior':
50
- return boards.filter(b =>
51
- b.type === 'junior' &&
52
- (hidden || b.show === 1) &&
53
- (premium || !b.premium) &&
54
- (disabled || b.enabled) &&
55
- (!b[exclude.prop] || b[exclude.prop] !== exclude.value) &&
56
- (include.length === 0 || include.includes(b.id))
57
- )
58
- case 'code':
59
- return boards.filter(b =>
60
- b.type === 'senior' &&
61
- b.enabledForCode > 0 &&
62
- (hidden || b.show === 1) &&
63
- (premium || !b.premium) &&
64
- (disabled || b.enabled) &&
65
- (!b[exclude.prop] || b[exclude.prop] !== exclude.value) &&
66
- (include.length === 0 || include.includes(b.id))
67
- )
68
- case 'aula':
69
- return boards.filter(b =>
70
- (hidden || b.showOnAula === 1) &&
71
- (disabled || b.enabled) &&
72
- (!b[exclude.prop] || b[exclude.prop] !== exclude.value) &&
73
- (include.length === 0 || include.includes(b.id))
74
- )
75
- case 'all':
76
- default:
77
- return boards.filter(b =>
78
- (hidden || b.show === 1) &&
79
- (premium || !b.premium) &&
80
- (disabled || b.enabled) &&
81
- (!b[exclude.prop] || b[exclude.prop] !== exclude.value) &&
82
- (include.length === 0 || include.includes(b.id))
83
- )
84
- }
85
- }
86
-
87
- export const getBoardById = (boards: Board[], id: number | string) => boards
88
- .find((board) => {
89
- const boardId = typeof id === 'string' ? parseInt(id, 10) : id
90
- return board.id === boardId
91
- })
92
-
93
- /**
94
- * Get all filtered boards
95
- * legacy support
96
- *
97
- * @param boards all boards
98
- * @param [type='all'] type of board
99
- * @param [premium=true] include premium boards
100
- * @param [disabled=true] include disabled boards
101
- * @param [hidden=false] include hidden boards
102
- * @param [exclude={
103
- * prop: '',
104
- * value: ''
105
- * }] exclude boards by property name and value
106
- */
107
- export const getBoards = (
108
- boards: Board[],
109
- type = 'all',
110
- premium = true,
111
- disabled = true,
112
- hidden = false,
113
- exclude = {
114
- prop: '',
115
- value: ''
116
- },
117
- include = [],
118
- ): Board[] => getAllBoards({ boards, type, premium, disabled, hidden, exclude, include })