From 4b92eb020945e25ca1752b86facae1dc8d185cc6 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Mon, 10 Feb 2025 10:54:52 -0800 Subject: [PATCH] Added gmail tool to send/reach/search gmail, added condition display of sub-blocks. Need to integrate oauth2 credentials for gmail --- .../sub-block/components/dropdown.tsx | 20 ++- .../components/sub-block/sub-block.tsx | 13 ++ blocks/blocks/gmail.ts | 128 ++++++++++++++++++ blocks/blocks/notion.ts | 8 +- blocks/index.ts | 3 + blocks/types.ts | 4 + tools/gmail/read.ts | 88 ++++++++++++ tools/gmail/search.ts | 82 +++++++++++ tools/gmail/send.ts | 93 +++++++++++++ tools/gmail/types.ts | 78 +++++++++++ tools/index.ts | 6 + 11 files changed, 516 insertions(+), 7 deletions(-) create mode 100644 blocks/blocks/gmail.ts create mode 100644 tools/gmail/read.ts create mode 100644 tools/gmail/search.ts create mode 100644 tools/gmail/send.ts create mode 100644 tools/gmail/types.ts diff --git a/app/w/[id]/components/workflow-block/components/sub-block/components/dropdown.tsx b/app/w/[id]/components/workflow-block/components/sub-block/components/dropdown.tsx index b3fdc352cc..10bb122da2 100644 --- a/app/w/[id]/components/workflow-block/components/sub-block/components/dropdown.tsx +++ b/app/w/[id]/components/workflow-block/components/sub-block/components/dropdown.tsx @@ -9,7 +9,7 @@ import { import { useSubBlockValue } from '../hooks/use-sub-block-value' interface DropdownProps { - options: string[] + options: Array defaultValue?: string blockId: string subBlockId: string @@ -21,14 +21,24 @@ export function Dropdown({ options, defaultValue, blockId, subBlockId }: Dropdow // Set the value to the first option if it's not set useEffect(() => { if (!value && options.length > 0) { - setValue(defaultValue ?? options[0]) + const firstOption = options[0] + const firstValue = typeof firstOption === 'string' ? firstOption : firstOption.id + setValue(firstValue) } }, [value, options, defaultValue, setValue]) + const getOptionValue = (option: string | { label: string; id: string }) => { + return typeof option === 'string' ? option : option.id + } + + const getOptionLabel = (option: string | { label: string; id: string }) => { + return typeof option === 'string' ? option : option.label + } + return (