-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cards.js
46 lines (42 loc) · 1.21 KB
/
Cards.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
42
43
44
45
46
function updateCardDescription(card, updateFields) {
let description = card.desc;
for (const [key, value] of Object.entries(updateFields)) {
description = description.replace(`{{${key}}}`, value);
}
return makeRequest({
method: 'PUT',
endpoint: `/cards/${card.id}`,
payload: {
desc: description,
},
errorMessage: "Failed to update card's description.",
});
}
function createFunctionalitiesChecklist(cardID, functionalities) {
const checklistName = 'What the website needs';
const checklist = createCardChecklist(cardID, checklistName);
for (const functionality of functionalities) {
createChecklistItem(checklist.id, functionality);
}
}
function createCardChecklist(cardID, checklistName) {
return makeRequest({
method: 'POST',
endpoint: '/checklists',
payload: {
idCard: cardID,
name: checklistName,
},
errorMessage: 'Failed to create Functionalities checklist.',
});
}
function createChecklistItem(checklistID, itemDescription) {
return makeRequest({
method: 'POST',
endpoint: `/checklists/${checklistID}/checkItems`,
payload: {
name: itemDescription,
},
errorMessage: 'Failed to add item to checklist.',
});
}