feat(jotform): add new submissions trigger

This commit is contained in:
Rıdvan Akca
2024-02-05 14:50:48 +03:00
committed by Ali BARIN
parent 42f8e635ed
commit 530a920517
8 changed files with 177 additions and 1 deletions

View File

@@ -0,0 +1,3 @@
import listForms from './list-forms/index.js';
export default [listForms];

View File

@@ -0,0 +1,41 @@
export default {
name: 'List forms',
key: 'listForms',
async run($) {
const forms = {
data: [],
};
let hasMore = false;
const params = {
limit: 1000,
offset: 0,
orderby: 'created_at',
};
do {
const { data } = await $.http.get('/user/forms', { params });
params.offset = params.offset + params.limit;
if (data.content?.length) {
for (const form of data.content) {
if (form.status === 'ENABLED') {
forms.data.push({
value: form.id,
name: form.title,
});
}
}
}
if (data.resultSet.count > data.resultSet.limit) {
hasMore = true;
} else {
hasMore = false;
}
} while (hasMore);
return forms;
},
};