feat(google-tasks): add find task action

This commit is contained in:
Rıdvan Akca
2024-01-16 16:27:45 +03:00
parent 7a6aa99840
commit 92a9b096ec
8 changed files with 107 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
import defineAction from '../../../../helpers/define-action.js';
export default defineAction({
name: 'Find task',
key: 'findTask',
description: 'Looking for an incomplete task.',
arguments: [
{
label: 'Task List',
key: 'taskListId',
type: 'dropdown',
required: true,
description: 'The list to be searched.',
variables: true,
source: {
type: 'query',
name: 'getDynamicData',
arguments: [
{
name: 'key',
value: 'listTaskLists',
},
],
},
},
{
label: 'Title',
key: 'title',
type: 'string',
required: true,
description: '',
variables: true,
},
],
async run($) {
const taskListId = $.step.parameters.taskListId;
const title = $.step.parameters.title;
const { data } = await $.http.get(`/tasks/v1/lists/${taskListId}/tasks`);
const filteredTask = data.items?.filter((task) =>
task.title.includes(title)
);
$.setActionItem({
raw: filteredTask[0],
});
},
});