Skip to content

Commit

Permalink
WIP: add 'Add account' button
Browse files Browse the repository at this point in the history
  • Loading branch information
martmull committed Oct 7, 2024
1 parent fd46298 commit b5df5fd
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
22 changes: 21 additions & 1 deletion packages/twenty-front/src/modules/ui/input/components/Select.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -18,6 +18,12 @@ export type SelectOption<Value extends string | number | null> = {
Icon?: IconComponent;
};

type CallToActionButton = {
text: string;
onClick: (event: MouseEvent<HTMLDivElement>) => void;
Icon?: IconComponent;
};

export type SelectProps<Value extends string | number | null> = {
className?: string;
disabled?: boolean;
Expand All @@ -32,6 +38,7 @@ export type SelectProps<Value extends string | number | null> = {
options: SelectOption<Value>[];
value?: Value;
withSearchInput?: boolean;
callToActionButton?: CallToActionButton;
};

const StyledContainer = styled.div<{ fullWidth?: boolean }>`
Expand Down Expand Up @@ -89,6 +96,7 @@ export const Select = <Value extends string | number | null>({
options,
value,
withSearchInput,
callToActionButton,
}: SelectProps<Value>) => {
const selectContainerRef = useRef<HTMLDivElement>(null);

Expand Down Expand Up @@ -177,6 +185,18 @@ export const Select = <Value extends string | number | null>({
))}
</DropdownMenuItemsContainer>
)}
{!!callToActionButton && !!filteredOptions.length && (
<DropdownMenuSeparator />
)}
{!!callToActionButton && (
<DropdownMenuItemsContainer hasMaxHeight>
<MenuItem
onClick={callToActionButton.onClick}
LeftIcon={callToActionButton.Icon}
text={callToActionButton.text}
/>
</DropdownMenuItemsContainer>
)}
</>
}
dropdownHotkeyScope={{ scope: SelectHotkeyScope.Select }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)};
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit b5df5fd

Please sign in to comment.