From b5df5fdac4e947f6fcf5778fd566061712acc9c3 Mon Sep 17 00:00:00 2001 From: martmull Date: Mon, 7 Oct 2024 14:59:33 +0200 Subject: [PATCH] WIP: add 'Add account' button --- .../modules/ui/input/components/Select.tsx | 22 ++++++++++++++++++- .../WorkflowEditActionFormSendEmail.tsx | 17 +++++++++----- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/packages/twenty-front/src/modules/ui/input/components/Select.tsx b/packages/twenty-front/src/modules/ui/input/components/Select.tsx index f88f3712b2cea..2a73ffd565434 100644 --- a/packages/twenty-front/src/modules/ui/input/components/Select.tsx +++ b/packages/twenty-front/src/modules/ui/input/components/Select.tsx @@ -1,6 +1,6 @@ import { useTheme } from '@emotion/react'; import styled from '@emotion/styled'; -import { useMemo, useRef, useState } from 'react'; +import React, { MouseEvent, useMemo, useRef, useState } from 'react'; import { IconChevronDown, IconComponent } from 'twenty-ui'; import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown'; @@ -18,6 +18,12 @@ export type SelectOption = { Icon?: IconComponent; }; +type CallToActionButton = { + text: string; + onClick: (event: MouseEvent) => void; + Icon?: IconComponent; +}; + export type SelectProps = { className?: string; disabled?: boolean; @@ -32,6 +38,7 @@ export type SelectProps = { options: SelectOption[]; value?: Value; withSearchInput?: boolean; + callToActionButton?: CallToActionButton; }; const StyledContainer = styled.div<{ fullWidth?: boolean }>` @@ -89,6 +96,7 @@ export const Select = ({ options, value, withSearchInput, + callToActionButton, }: SelectProps) => { const selectContainerRef = useRef(null); @@ -177,6 +185,18 @@ export const Select = ({ ))} )} + {!!callToActionButton && !!filteredOptions.length && ( + + )} + {!!callToActionButton && ( + + + + )} } dropdownHotkeyScope={{ scope: SelectHotkeyScope.Select }} diff --git a/packages/twenty-front/src/modules/workflow/components/WorkflowEditActionFormSendEmail.tsx b/packages/twenty-front/src/modules/workflow/components/WorkflowEditActionFormSendEmail.tsx index 9c54a5c12a7b1..c54a713c5d6f5 100644 --- a/packages/twenty-front/src/modules/workflow/components/WorkflowEditActionFormSendEmail.tsx +++ b/packages/twenty-front/src/modules/workflow/components/WorkflowEditActionFormSendEmail.tsx @@ -4,15 +4,15 @@ import { WorkflowEditActionFormBase } from '@/workflow/components/WorkflowEditAc import { WorkflowSendEmailStep } from '@/workflow/types/Workflow'; import { useTheme } from '@emotion/react'; import styled from '@emotion/styled'; -import { useEffect } from 'react'; +import React, { useEffect } from 'react'; import { Controller, useForm } from 'react-hook-form'; -import { IconMail } from 'twenty-ui'; +import { IconMail, IconPlus } from 'twenty-ui'; import { useDebouncedCallback } from 'use-debounce'; import { Select, SelectOption } from '@/ui/input/components/Select'; -import { useFindManyRecords } from 'packages/twenty-front/src/modules/object-record/hooks/useFindManyRecords'; -import { ConnectedAccount } from 'packages/twenty-front/src/modules/accounts/types/ConnectedAccount'; +import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords'; +import { ConnectedAccount } from '@/accounts/types/ConnectedAccount'; import { useRecoilValue } from 'recoil'; -import { currentWorkspaceMemberState } from 'packages/twenty-front/src/modules/auth/states/currentWorkspaceMemberState'; +import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState'; const StyledTriggerSettings = styled.div` padding: ${({ theme }) => theme.spacing(6)}; @@ -133,6 +133,13 @@ export const WorkflowEditActionFormSendEmail = ({ emptyOption={emptyOption} value={field.value} options={connectedAccountOptions} + callToActionButton={{ + onClick: () => { + console.log('click'); + }, + Icon: IconPlus, + text: 'Add account', + }} onChange={(connectedAccountId) => { field.onChange(connectedAccountId);