@ -1,18 +1,31 @@
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import styled from '@emotion/styled';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
|
||||
import { ConnectedAccount } from '@/accounts/types/ConnectedAccount';
|
||||
import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState';
|
||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||
import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords';
|
||||
import { SettingsAccountsListEmptyStateCard } from '@/settings/accounts/components/SettingsAccountsListEmptyStateCard';
|
||||
import { SettingsAccountsListSkeletonCard } from '@/settings/accounts/components/SettingsAccountsListSkeletonCard';
|
||||
import { SettingsAccountsListCard } from '@/settings/accounts/components/SettingsAccountsListCard';
|
||||
import { SettingsAccountsSynchronizationStatus } from '@/settings/accounts/components/SettingsAccountsSynchronizationStatus';
|
||||
import { IconChevronRight } from '@/ui/display/icon';
|
||||
import { IconGoogleCalendar } from '@/ui/display/icon/components/IconGoogleCalendar';
|
||||
import { H2Title } from '@/ui/display/typography/components/H2Title';
|
||||
import { LightIconButton } from '@/ui/input/button/components/LightIconButton';
|
||||
import { Section } from '@/ui/layout/section/components/Section';
|
||||
import { mockedConnectedAccounts } from '~/testing/mock-data/accounts';
|
||||
|
||||
const StyledRowRightContainer = styled.div`
|
||||
align-items: center;
|
||||
display: flex;
|
||||
gap: ${({ theme }) => theme.spacing(1)};
|
||||
`;
|
||||
|
||||
export const SettingsAccountsCalendarSettingsSection = () => {
|
||||
const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState);
|
||||
const navigate = useNavigate();
|
||||
|
||||
const { records: accounts, loading } = useFindManyRecords<ConnectedAccount>({
|
||||
const { records: _accounts, loading } = useFindManyRecords<ConnectedAccount>({
|
||||
objectNameSingular: CoreObjectNameSingular.ConnectedAccount,
|
||||
filter: {
|
||||
accountOwnerId: {
|
||||
@ -27,12 +40,20 @@ export const SettingsAccountsCalendarSettingsSection = () => {
|
||||
title="Calendar settings"
|
||||
description="Sync your calendars and set your preferences"
|
||||
/>
|
||||
|
||||
{loading ? (
|
||||
<SettingsAccountsListSkeletonCard />
|
||||
) : !accounts.length ? (
|
||||
<SettingsAccountsListEmptyStateCard />
|
||||
) : null}
|
||||
<SettingsAccountsListCard
|
||||
accounts={mockedConnectedAccounts}
|
||||
isLoading={loading}
|
||||
onRowClick={(account) =>
|
||||
navigate(`/settings/accounts/calendars/${account.id}`)
|
||||
}
|
||||
RowIcon={IconGoogleCalendar}
|
||||
RowRightComponent={({ account: _account }) => (
|
||||
<StyledRowRightContainer>
|
||||
<SettingsAccountsSynchronizationStatus synced />
|
||||
<LightIconButton Icon={IconChevronRight} accent="tertiary" />
|
||||
</StyledRowRightContainer>
|
||||
)}
|
||||
/>
|
||||
</Section>
|
||||
);
|
||||
};
|
||||
|
||||
@ -1,69 +0,0 @@
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useTheme } from '@emotion/react';
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
import { ConnectedAccount } from '@/accounts/types/ConnectedAccount';
|
||||
import { SettingsAccountsRowDropdownMenu } from '@/settings/accounts/components/SettingsAccountsRowDropdownMenu';
|
||||
import { IconAt, IconPlus } from '@/ui/display/icon';
|
||||
import { IconGoogle } from '@/ui/display/icon/components/IconGoogle';
|
||||
import { LightIconButton } from '@/ui/input/button/components/LightIconButton';
|
||||
import { Card } from '@/ui/layout/card/components/Card';
|
||||
import { CardFooter } from '@/ui/layout/card/components/CardFooter';
|
||||
|
||||
import { SettingsAccountRow } from './SettingsAccountsRow';
|
||||
|
||||
const StyledFooter = styled(CardFooter)`
|
||||
align-items: center;
|
||||
color: ${({ theme }) => theme.font.color.tertiary};
|
||||
display: flex;
|
||||
gap: ${({ theme }) => theme.spacing(2)};
|
||||
height: ${({ theme }) => theme.spacing(6)};
|
||||
padding: ${({ theme }) => theme.spacing(2)};
|
||||
padding-left: ${({ theme }) => theme.spacing(4)};
|
||||
`;
|
||||
|
||||
const StyledIconButton = styled(LightIconButton)`
|
||||
margin-left: auto;
|
||||
`;
|
||||
|
||||
const StyledDropdown = styled(SettingsAccountsRowDropdownMenu)`
|
||||
margin-left: auto;
|
||||
`;
|
||||
|
||||
type SettingsAccountsCardProps = {
|
||||
accounts: ConnectedAccount[];
|
||||
onAccountRemove?: (uuid: string) => void;
|
||||
};
|
||||
|
||||
export const SettingsAccountsCard = ({
|
||||
accounts,
|
||||
onAccountRemove,
|
||||
}: SettingsAccountsCardProps) => {
|
||||
const theme = useTheme();
|
||||
const navigate = useNavigate();
|
||||
|
||||
return (
|
||||
<Card>
|
||||
{accounts.map((account, index) => (
|
||||
<SettingsAccountRow
|
||||
key={account.id}
|
||||
LeftIcon={IconGoogle}
|
||||
account={account}
|
||||
rightComponent={
|
||||
<StyledDropdown account={account} onRemove={onAccountRemove} />
|
||||
}
|
||||
divider={index < accounts.length - 1}
|
||||
/>
|
||||
))}
|
||||
<StyledFooter>
|
||||
<IconAt size={theme.icon.size.sm} />
|
||||
Add account
|
||||
<StyledIconButton
|
||||
Icon={IconPlus}
|
||||
accent="tertiary"
|
||||
onClick={() => navigate('/settings/accounts/new')}
|
||||
/>
|
||||
</StyledFooter>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
@ -1,37 +1,27 @@
|
||||
import { ConnectedAccount } from '@/accounts/types/ConnectedAccount';
|
||||
import { useDeleteOneRecord } from '@/object-record/hooks/useDeleteOneRecord';
|
||||
import { SettingsAccountsRowDropdownMenu } from '@/settings/accounts/components/SettingsAccountsRowDropdownMenu';
|
||||
import { H2Title } from '@/ui/display/typography/components/H2Title';
|
||||
import { Section } from '@/ui/layout/section/components/Section';
|
||||
|
||||
import { SettingsAccountsCard } from './SettingsAccountsCard';
|
||||
import { SettingsAccountsListEmptyStateCard } from './SettingsAccountsListEmptyStateCard';
|
||||
import { SettingsAccountsListCard } from './SettingsAccountsListCard';
|
||||
|
||||
export const SettingsAccountsConnectedAccountsSection = ({
|
||||
accounts,
|
||||
loading,
|
||||
}: {
|
||||
accounts: ConnectedAccount[];
|
||||
}) => {
|
||||
const { deleteOneRecord } = useDeleteOneRecord({
|
||||
objectNameSingular: 'connectedAccount',
|
||||
});
|
||||
|
||||
const handleAccountRemove = (idToRemove: string) =>
|
||||
deleteOneRecord(idToRemove);
|
||||
|
||||
return (
|
||||
<Section>
|
||||
<H2Title
|
||||
title="Connected accounts"
|
||||
description="Manage your internet accounts."
|
||||
/>
|
||||
{accounts?.length ? (
|
||||
<SettingsAccountsCard
|
||||
accounts={accounts}
|
||||
onAccountRemove={handleAccountRemove}
|
||||
/>
|
||||
) : (
|
||||
<SettingsAccountsListEmptyStateCard />
|
||||
)}
|
||||
</Section>
|
||||
);
|
||||
};
|
||||
loading?: boolean;
|
||||
}) => (
|
||||
<Section>
|
||||
<H2Title
|
||||
title="Connected accounts"
|
||||
description="Manage your internet accounts."
|
||||
/>
|
||||
<SettingsAccountsListCard
|
||||
accounts={accounts}
|
||||
isLoading={loading}
|
||||
RowRightComponent={SettingsAccountsRowDropdownMenu}
|
||||
hasFooter
|
||||
/>
|
||||
</Section>
|
||||
);
|
||||
|
||||
@ -1,54 +0,0 @@
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
import { MessageChannel } from '@/accounts/types/MessageChannel';
|
||||
import { IconChevronRight } from '@/ui/display/icon';
|
||||
import { IconGmail } from '@/ui/display/icon/components/IconGmail';
|
||||
import { Status } from '@/ui/display/status/components/Status';
|
||||
import { LightIconButton } from '@/ui/input/button/components/LightIconButton';
|
||||
import { Card } from '@/ui/layout/card/components/Card';
|
||||
|
||||
import { SettingsAccountRow } from './SettingsAccountsRow';
|
||||
|
||||
const StyledRightContainer = styled.div`
|
||||
align-items: center;
|
||||
display: flex;
|
||||
gap: ${({ theme }) => theme.spacing(1)};
|
||||
margin-left: auto;
|
||||
`;
|
||||
|
||||
type SettingsAccountsEmailsCardProps = {
|
||||
messageChannels: MessageChannel[];
|
||||
};
|
||||
|
||||
export const SettingsAccountsEmailsCard = ({
|
||||
messageChannels,
|
||||
}: SettingsAccountsEmailsCardProps) => {
|
||||
const navigate = useNavigate();
|
||||
|
||||
return (
|
||||
<Card>
|
||||
{messageChannels.map((messageChannel, index) => (
|
||||
<SettingsAccountRow
|
||||
key={messageChannel.id}
|
||||
LeftIcon={IconGmail}
|
||||
account={messageChannel}
|
||||
rightComponent={
|
||||
<StyledRightContainer>
|
||||
{messageChannel.isSynced ? (
|
||||
<Status color="green" text="Synced" weight="medium" />
|
||||
) : (
|
||||
<Status color="gray" text="Not Synced" weight="medium" />
|
||||
)}
|
||||
<LightIconButton Icon={IconChevronRight} accent="tertiary" />
|
||||
</StyledRightContainer>
|
||||
}
|
||||
onClick={() =>
|
||||
navigate(`/settings/accounts/emails/${messageChannel.id}`)
|
||||
}
|
||||
divider={index < messageChannels.length - 1}
|
||||
/>
|
||||
))}
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
@ -1,18 +1,29 @@
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import styled from '@emotion/styled';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { LightIconButton } from 'tsup.ui.index';
|
||||
|
||||
import { ConnectedAccount } from '@/accounts/types/ConnectedAccount';
|
||||
import { MessageChannel } from '@/accounts/types/MessageChannel';
|
||||
import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState';
|
||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||
import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords';
|
||||
import { SettingsAccountsEmailsCard } from '@/settings/accounts/components/SettingsAccountsEmailsCard';
|
||||
import { SettingsAccountsListEmptyStateCard } from '@/settings/accounts/components/SettingsAccountsListEmptyStateCard';
|
||||
import { SettingsAccountsListSkeletonCard } from '@/settings/accounts/components/SettingsAccountsListSkeletonCard';
|
||||
import { SettingsAccountsListCard } from '@/settings/accounts/components/SettingsAccountsListCard';
|
||||
import { SettingsAccountsSynchronizationStatus } from '@/settings/accounts/components/SettingsAccountsSynchronizationStatus';
|
||||
import { IconChevronRight } from '@/ui/display/icon';
|
||||
import { IconGmail } from '@/ui/display/icon/components/IconGmail';
|
||||
import { H2Title } from '@/ui/display/typography/components/H2Title';
|
||||
import { Section } from '@/ui/layout/section/components/Section';
|
||||
|
||||
const StyledRowRightContainer = styled.div`
|
||||
align-items: center;
|
||||
display: flex;
|
||||
gap: ${({ theme }) => theme.spacing(1)};
|
||||
`;
|
||||
|
||||
export const SettingsAccountsEmailsSyncSection = () => {
|
||||
const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState);
|
||||
const navigate = useNavigate();
|
||||
|
||||
const { records: accounts, loading: accountsLoading } =
|
||||
useFindManyRecords<ConnectedAccount>({
|
||||
@ -26,7 +37,7 @@ export const SettingsAccountsEmailsSyncSection = () => {
|
||||
|
||||
const { records: messageChannels, loading: messageChannelsLoading } =
|
||||
useFindManyRecords<MessageChannel>({
|
||||
objectNameSingular: 'messageChannel',
|
||||
objectNameSingular: CoreObjectNameSingular.MessageChannel,
|
||||
filter: {
|
||||
connectedAccountId: {
|
||||
in: accounts.map((account) => account.id),
|
||||
@ -41,24 +52,28 @@ export const SettingsAccountsEmailsSyncSection = () => {
|
||||
}),
|
||||
);
|
||||
|
||||
const loading = accountsLoading || messageChannelsLoading;
|
||||
|
||||
return (
|
||||
<Section>
|
||||
<H2Title
|
||||
title="Emails sync"
|
||||
description="Sync your inboxes and set your privacy settings"
|
||||
/>
|
||||
|
||||
{loading ? (
|
||||
<SettingsAccountsListSkeletonCard />
|
||||
) : accounts.length ? (
|
||||
<SettingsAccountsEmailsCard
|
||||
messageChannels={messageChannelsWithSyncedEmails}
|
||||
/>
|
||||
) : (
|
||||
<SettingsAccountsListEmptyStateCard />
|
||||
)}
|
||||
<SettingsAccountsListCard
|
||||
accounts={messageChannelsWithSyncedEmails}
|
||||
isLoading={accountsLoading || messageChannelsLoading}
|
||||
onRowClick={(messageChannel) =>
|
||||
navigate(`/settings/accounts/emails/${messageChannel.id}`)
|
||||
}
|
||||
RowIcon={IconGmail}
|
||||
RowRightComponent={({ account: messageChannel }) => (
|
||||
<StyledRowRightContainer>
|
||||
<SettingsAccountsSynchronizationStatus
|
||||
synced={messageChannel.isSynced}
|
||||
/>
|
||||
<LightIconButton Icon={IconChevronRight} accent="tertiary" />
|
||||
</StyledRowRightContainer>
|
||||
)}
|
||||
/>
|
||||
</Section>
|
||||
);
|
||||
};
|
||||
|
||||
@ -0,0 +1,89 @@
|
||||
import { ReactNode } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useTheme } from '@emotion/react';
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
import { ConnectedAccount } from '@/accounts/types/ConnectedAccount';
|
||||
import { SettingsAccountsListEmptyStateCard } from '@/settings/accounts/components/SettingsAccountsListEmptyStateCard';
|
||||
import { SettingsAccountsListSkeletonCard } from '@/settings/accounts/components/SettingsAccountsListSkeletonCard';
|
||||
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
|
||||
import { SettingsPath } from '@/types/SettingsPath';
|
||||
import { IconAt, IconPlus } from '@/ui/display/icon';
|
||||
import { IconGoogle } from '@/ui/display/icon/components/IconGoogle';
|
||||
import { IconComponent } from '@/ui/display/icon/types/IconComponent';
|
||||
import { LightIconButton } from '@/ui/input/button/components/LightIconButton';
|
||||
import { Card } from '@/ui/layout/card/components/Card';
|
||||
import { CardFooter } from '@/ui/layout/card/components/CardFooter';
|
||||
|
||||
import { SettingsAccountRow } from './SettingsAccountsRow';
|
||||
|
||||
const StyledFooter = styled(CardFooter)`
|
||||
align-items: center;
|
||||
color: ${({ theme }) => theme.font.color.tertiary};
|
||||
display: flex;
|
||||
gap: ${({ theme }) => theme.spacing(2)};
|
||||
height: ${({ theme }) => theme.spacing(6)};
|
||||
padding: ${({ theme }) => theme.spacing(2)};
|
||||
padding-left: ${({ theme }) => theme.spacing(4)};
|
||||
`;
|
||||
|
||||
const StyledIconButton = styled(LightIconButton)`
|
||||
margin-left: auto;
|
||||
`;
|
||||
|
||||
type SettingsAccountsListCardProps<
|
||||
Account extends Pick<ConnectedAccount, 'handle' | 'id'>,
|
||||
> = {
|
||||
accounts: Account[];
|
||||
hasFooter?: boolean;
|
||||
isLoading?: boolean;
|
||||
onRowClick?: (account: Account) => void;
|
||||
RowIcon?: IconComponent;
|
||||
RowRightComponent: ({ account }: { account: Account }) => ReactNode;
|
||||
};
|
||||
|
||||
export const SettingsAccountsListCard = <
|
||||
Account extends Pick<ConnectedAccount, 'handle' | 'id'> = ConnectedAccount,
|
||||
>({
|
||||
accounts,
|
||||
hasFooter,
|
||||
isLoading,
|
||||
onRowClick,
|
||||
RowIcon = IconGoogle,
|
||||
RowRightComponent,
|
||||
}: SettingsAccountsListCardProps<Account>) => {
|
||||
const theme = useTheme();
|
||||
const navigate = useNavigate();
|
||||
|
||||
if (isLoading) return <SettingsAccountsListSkeletonCard />;
|
||||
|
||||
if (!accounts.length) return <SettingsAccountsListEmptyStateCard />;
|
||||
|
||||
return (
|
||||
<Card>
|
||||
{accounts.map((account, index) => (
|
||||
<SettingsAccountRow
|
||||
key={account.id}
|
||||
LeftIcon={RowIcon}
|
||||
account={account}
|
||||
rightComponent={<RowRightComponent account={account} />}
|
||||
divider={index < accounts.length - 1}
|
||||
onClick={() => onRowClick?.(account)}
|
||||
/>
|
||||
))}
|
||||
{hasFooter && (
|
||||
<StyledFooter>
|
||||
<IconAt size={theme.icon.size.sm} />
|
||||
Add account
|
||||
<StyledIconButton
|
||||
Icon={IconPlus}
|
||||
accent="tertiary"
|
||||
onClick={() =>
|
||||
navigate(getSettingsPagePath(SettingsPath.NewAccount))
|
||||
}
|
||||
/>
|
||||
</StyledFooter>
|
||||
)}
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
@ -3,7 +3,6 @@ import { useTheme } from '@emotion/react';
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
import { ConnectedAccount } from '@/accounts/types/ConnectedAccount';
|
||||
import { MessageChannel } from '@/accounts/types/MessageChannel';
|
||||
import { IconComponent } from '@/ui/display/icon/types/IconComponent';
|
||||
import { CardContent } from '@/ui/layout/card/components/CardContent';
|
||||
|
||||
@ -18,8 +17,12 @@ const StyledRow = styled(CardContent)`
|
||||
padding-left: ${({ theme }) => theme.spacing(4)};
|
||||
`;
|
||||
|
||||
const StyledAccountHandle = styled.span`
|
||||
flex: 1 0 auto;
|
||||
`;
|
||||
|
||||
type SettingsAccountRowProps = {
|
||||
account: ConnectedAccount | MessageChannel;
|
||||
account: Pick<ConnectedAccount, 'handle'>;
|
||||
divider?: boolean;
|
||||
LeftIcon: IconComponent;
|
||||
onClick?: () => void;
|
||||
@ -37,8 +40,8 @@ export const SettingsAccountRow = ({
|
||||
|
||||
return (
|
||||
<StyledRow onClick={onClick} divider={divider}>
|
||||
<LeftIcon size={theme.icon.size.sm} />
|
||||
{account.handle}
|
||||
<LeftIcon size={theme.icon.size.md} />
|
||||
<StyledAccountHandle>{account.handle}</StyledAccountHandle>
|
||||
{rightComponent}
|
||||
</StyledRow>
|
||||
);
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
import { ConnectedAccount } from '@/accounts/types/ConnectedAccount';
|
||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||
import { useDeleteOneRecord } from '@/object-record/hooks/useDeleteOneRecord';
|
||||
import { IconDotsVertical, IconMail, IconTrash } from '@/ui/display/icon';
|
||||
import { LightIconButton } from '@/ui/input/button/components/LightIconButton';
|
||||
import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';
|
||||
@ -10,21 +12,23 @@ import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown';
|
||||
import { MenuItem } from '@/ui/navigation/menu-item/components/MenuItem';
|
||||
|
||||
type SettingsAccountsRowDropdownMenuProps = {
|
||||
account: ConnectedAccount;
|
||||
account: Pick<ConnectedAccount, 'id' | 'messageChannels'>;
|
||||
className?: string;
|
||||
onRemove?: (uuid: string) => void;
|
||||
};
|
||||
|
||||
export const SettingsAccountsRowDropdownMenu = ({
|
||||
account,
|
||||
className,
|
||||
onRemove,
|
||||
}: SettingsAccountsRowDropdownMenuProps) => {
|
||||
const dropdownId = `settings-account-row-${account.id}`;
|
||||
|
||||
const navigate = useNavigate();
|
||||
const { closeDropdown } = useDropdown(dropdownId);
|
||||
|
||||
const { deleteOneRecord } = useDeleteOneRecord({
|
||||
objectNameSingular: CoreObjectNameSingular.ConnectedAccount,
|
||||
});
|
||||
|
||||
return (
|
||||
<Dropdown
|
||||
dropdownId={dropdownId}
|
||||
@ -47,17 +51,15 @@ export const SettingsAccountsRowDropdownMenu = ({
|
||||
closeDropdown();
|
||||
}}
|
||||
/>
|
||||
{!!onRemove && (
|
||||
<MenuItem
|
||||
accent="danger"
|
||||
LeftIcon={IconTrash}
|
||||
text="Remove account"
|
||||
onClick={() => {
|
||||
onRemove(account.id);
|
||||
closeDropdown();
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<MenuItem
|
||||
accent="danger"
|
||||
LeftIcon={IconTrash}
|
||||
text="Remove account"
|
||||
onClick={() => {
|
||||
deleteOneRecord(account.id);
|
||||
closeDropdown();
|
||||
}}
|
||||
/>
|
||||
</DropdownMenuItemsContainer>
|
||||
</DropdownMenu>
|
||||
}
|
||||
|
||||
@ -0,0 +1,15 @@
|
||||
import { Status } from '@/ui/display/status/components/Status';
|
||||
|
||||
type SettingsAccountsSynchronizationStatusProps = {
|
||||
synced: boolean;
|
||||
};
|
||||
|
||||
export const SettingsAccountsSynchronizationStatus = ({
|
||||
synced,
|
||||
}: SettingsAccountsSynchronizationStatusProps) => (
|
||||
<Status
|
||||
color={synced ? 'green' : 'gray'}
|
||||
text={synced ? 'Synced' : 'Not Synced'}
|
||||
weight="medium"
|
||||
/>
|
||||
);
|
||||
Reference in New Issue
Block a user