1 | |
2 | type Clickup = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Create Folder View |
7 | * Add a List, Board, Calendar, Table, Timeline, Workload, Activity, Map, Chat, or Gantt view to a Folder. |
8 | */ |
9 | export async function main( |
10 | auth: Clickup, |
11 | folder_id: string, |
12 | body: { |
13 | name: string; |
14 | type: string; |
15 | grouping: { |
16 | field: string; |
17 | dir: number; |
18 | collapsed: string[]; |
19 | ignore: false | true; |
20 | }; |
21 | divide: { field?: null; dir?: null; collapsed: false | true }; |
22 | sorting: { fields: string[] }; |
23 | filters: { |
24 | op: string; |
25 | fields: string[]; |
26 | search: string; |
27 | show_closed: false | true; |
28 | }; |
29 | columns: { fields: string[] }; |
30 | team_sidebar: { |
31 | assignees: string[]; |
32 | assigned_comments: false | true; |
33 | unassigned_tasks: false | true; |
34 | }; |
35 | settings: { |
36 | show_task_locations: false | true; |
37 | show_subtasks: number; |
38 | show_subtask_parent_names: false | true; |
39 | show_closed_subtasks: false | true; |
40 | show_assignees: false | true; |
41 | show_images: false | true; |
42 | collapse_empty_columns: string; |
43 | me_comments: false | true; |
44 | me_subtasks: false | true; |
45 | me_checklists: false | true; |
46 | }; |
47 | }, |
48 | ) { |
49 | const url = new URL( |
50 | `https://api.clickup.com/api/v2/folder/${folder_id}/view`, |
51 | ); |
52 |
|
53 | const response = await fetch(url, { |
54 | method: "POST", |
55 | headers: { |
56 | "Content-Type": "application/json", |
57 | Authorization: auth.token, |
58 | }, |
59 | body: JSON.stringify(body), |
60 | }); |
61 | if (!response.ok) { |
62 | const text = await response.text(); |
63 | throw new Error(`${response.status} ${text}`); |
64 | } |
65 | return await response.json(); |
66 | } |
67 |
|