Skip to content

Commit 655950f

Browse files
committed
paginate props
1 parent b5a9c78 commit 655950f

File tree

1 file changed

+47
-18
lines changed

1 file changed

+47
-18
lines changed

components/upwave/upwave.app.mjs

Lines changed: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,61 @@ export default {
88
type: "string",
99
label: "Workspace ID",
1010
description: "Description for workspaceId",
11-
async options() {
12-
const response = await this.getWorkspaces();
13-
const workspaces = response.results;
14-
return workspaces.map(({
15-
title, id,
16-
}) => ({
17-
label: title,
18-
value: id,
19-
}));
11+
async options({
12+
prevContext, page,
13+
}) {
14+
const params = prevContext?.next
15+
? {
16+
page: page + 1,
17+
}
18+
: {};
19+
const {
20+
results, next,
21+
} = await this.getWorkspaces({
22+
params,
23+
});
24+
return {
25+
options: results.map(({
26+
title, id,
27+
}) => ({
28+
label: title,
29+
value: id,
30+
})),
31+
context: {
32+
next,
33+
},
34+
};
2035
},
2136
},
2237
boardId: {
2338
type: "string",
2439
label: "Board ID",
2540
description: "Description for boardId",
26-
async options({ workspaceId }) {
27-
const response = await this.getBoards({
41+
async options({
42+
workspaceId, prevContext, page,
43+
}) {
44+
const params = prevContext?.next
45+
? {
46+
page: page + 1,
47+
}
48+
: {};
49+
const {
50+
results, next,
51+
} = await this.getBoards({
2852
workspaceId,
53+
params,
2954
});
30-
const boards = response.results;
31-
return boards.map(({
32-
title, id,
33-
}) => ({
34-
label: title,
35-
value: id,
36-
}));
55+
return {
56+
options: results.map(({
57+
title, id,
58+
}) => ({
59+
label: title,
60+
value: id,
61+
})),
62+
context: {
63+
next,
64+
},
65+
};
3766
},
3867
},
3968
dueDt: {

0 commit comments

Comments
 (0)