Skip to content

Commit

Permalink
feat: add Synchronization calendar settings
Browse files Browse the repository at this point in the history
Closes #4066
  • Loading branch information
thaisguigon committed Feb 21, 2024
1 parent 1aa9d33 commit 0f4d8ba
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ const StyledCardMedia = styled.div`
width: ${({ theme }) => theme.spacing(6)};
`;

export { StyledCardMedia as SettingsAccountsInboxSettingsCardMedia };
export { StyledCardMedia as SettingsAccountsCardMedia };
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ const StyledDropdown = styled(SettingsAccountsRowDropdownMenu)`
margin-left: auto;
`;

type SettingsAccountsCardProps = {
type SettingsAccountsConnectedAccountsCardProps = {
accounts: ConnectedAccount[];
onAccountRemove?: (uuid: string) => void;
};

export const SettingsAccountsCard = ({
export const SettingsAccountsConnectedAccountsCard = ({
accounts,
onAccountRemove,
}: SettingsAccountsCardProps) => {
}: SettingsAccountsConnectedAccountsCardProps) => {
const theme = useTheme();
const navigate = useNavigate();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ const StyledBody = styled(CardContent)`
justify-content: center;
`;

type SettingsAccountsEmptyStateCardProps = {
type SettingsAccountsConnectedAccountsEmptyStateCardProps = {
label?: string;
};

export const SettingsAccountsEmptyStateCard = ({
export const SettingsAccountsConnectedAccountsEmptyStateCard = ({
label,
}: SettingsAccountsEmptyStateCardProps) => {
}: SettingsAccountsConnectedAccountsEmptyStateCardProps) => {
const [generateTransientToken] = useGenerateTransientTokenMutation();

const handleGmailLogin = useCallback(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { useDeleteOneRecord } from '@/object-record/hooks/useDeleteOneRecord';
import { H2Title } from '@/ui/display/typography/components/H2Title';
import { Section } from '@/ui/layout/section/components/Section';

import { SettingsAccountsCard } from './SettingsAccountsCard';
import { SettingsAccountsEmptyStateCard } from './SettingsAccountsEmptyStateCard';
import { SettingsAccountsConnectedAccountsCard } from './SettingsAccountsConnectedAccountsCard';
import { SettingsAccountsConnectedAccountsEmptyStateCard } from './SettingsAccountsConnectedAccountsEmptyStateCard';

export const SettingsAccountsConnectedAccountsSection = ({
accounts,
Expand All @@ -25,12 +25,12 @@ export const SettingsAccountsConnectedAccountsSection = ({
description="Manage your internet accounts."
/>
{accounts?.length ? (
<SettingsAccountsCard
<SettingsAccountsConnectedAccountsCard
accounts={accounts}
onAccountRemove={handleAccountRemove}
/>
) : (
<SettingsAccountsEmptyStateCard />
<SettingsAccountsConnectedAccountsEmptyStateCard />
)}
</Section>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { SettingsAccountEmailsSkeletonCard } from '@/settings/accounts/component
import { H2Title } from '@/ui/display/typography/components/H2Title';
import { Section } from '@/ui/layout/section/components/Section';

import { SettingsAccountsConnectedAccountsEmptyStateCard } from './SettingsAccountsConnectedAccountsEmptyStateCard';
import { SettingsAccountsEmailsCard } from './SettingsAccountsEmailsCard';
import { SettingsAccountsEmptyStateCard } from './SettingsAccountsEmptyStateCard';

export const SettingsAccountsEmailsSyncSection = () => {
const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState);
Expand Down Expand Up @@ -57,7 +57,7 @@ export const SettingsAccountsEmailsSyncSection = () => {
messageChannels={messageChannelsWithSyncedEmails}
/>
) : (
<SettingsAccountsEmptyStateCard />
<SettingsAccountsConnectedAccountsEmptyStateCard />
)}
</Section>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useTheme } from '@emotion/react';
import styled from '@emotion/styled';

import { MessageChannel } from '@/accounts/types/MessageChannel';
import { SettingsAccountsInboxSettingsCardMedia } from '@/settings/accounts/components/SettingsAccountsInboxSettingsCardMedia';
import { SettingsAccountsCardMedia } from '@/settings/accounts/components/SettingsAccountsCardMedia';
import { IconUser } from '@/ui/display/icon';
import { H2Title } from '@/ui/display/typography/components/H2Title';
import { Toggle } from '@/ui/input/components/Toggle';
Expand Down Expand Up @@ -42,9 +42,9 @@ export const SettingsAccountsInboxSettingsContactAutoCreateSection = ({
/>
<Card>
<StyledCardContent>
<SettingsAccountsInboxSettingsCardMedia>
<SettingsAccountsCardMedia>
<IconUser size={theme.icon.size.sm} stroke={theme.icon.stroke.lg} />
</SettingsAccountsInboxSettingsCardMedia>
</SettingsAccountsCardMedia>
<StyledTitle>Auto-creation</StyledTitle>
<Toggle
value={messageChannel.isContactAutoCreationEnabled}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styled from '@emotion/styled';

import { SettingsAccountsInboxSettingsCardMedia } from '@/settings/accounts/components/SettingsAccountsInboxSettingsCardMedia';
import { SettingsAccountsCardMedia } from '@/settings/accounts/components/SettingsAccountsCardMedia';
import { H2Title } from '@/ui/display/typography/components/H2Title';
import { Radio } from '@/ui/input/components/Radio';
import { Card } from '@/ui/layout/card/components/Card';
Expand Down Expand Up @@ -29,7 +29,7 @@ const StyledCardContent = styled(CardContent)`
}
`;

const StyledCardMedia = styled(SettingsAccountsInboxSettingsCardMedia)`
const StyledCardMedia = styled(SettingsAccountsCardMedia)`
align-items: stretch;
`;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { useTheme } from '@emotion/react';
import styled from '@emotion/styled';

import { MessageChannel } from '@/accounts/types/MessageChannel';
import { SettingsAccountsInboxSettingsCardMedia } from '@/settings/accounts/components/SettingsAccountsInboxSettingsCardMedia';
import { SettingsAccountsCardMedia } from '@/settings/accounts/components/SettingsAccountsCardMedia';
import { IconRefresh } from '@/ui/display/icon';
import { H2Title } from '@/ui/display/typography/components/H2Title';
import { Toggle } from '@/ui/input/components/Toggle';
Expand All @@ -23,33 +22,34 @@ const StyledTitle = styled.span`
margin-right: auto;
`;

type SettingsAccountsInboxSettingsSynchronizationSectionProps = {
messageChannel: MessageChannel;
type SettingsAccountsSynchronizationSectionProps = {
cardTitle: string;
description: string;
isSynced: boolean;
onToggle: (value: boolean) => void;
};

export const SettingsAccountsInboxSettingsSynchronizationSection = ({
messageChannel,
export const SettingsAccountsSynchronizationSection = ({
cardTitle,
description,
isSynced,
onToggle,
}: SettingsAccountsInboxSettingsSynchronizationSectionProps) => {
}: SettingsAccountsSynchronizationSectionProps) => {
const theme = useTheme();

return (
<Section>
<H2Title
title="Synchronization"
description="Past and future emails will automatically be synced to this workspace"
/>
<H2Title title="Synchronization" description={description} />
<Card>
<StyledCardContent>
<SettingsAccountsInboxSettingsCardMedia>
<SettingsAccountsCardMedia>
<IconRefresh
size={theme.icon.size.sm}
stroke={theme.icon.stroke.lg}
/>
</SettingsAccountsInboxSettingsCardMedia>
<StyledTitle>Sync emails</StyledTitle>
<Toggle value={messageChannel.isSynced} onChange={onToggle} />
</SettingsAccountsCardMedia>
<StyledTitle>{cardTitle}</StyledTitle>
<Toggle value={isSynced} onChange={onToggle} />
</StyledCardContent>
</Card>
</Section>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { H2Title } from '@/ui/display/typography/components/H2Title';
import { Section } from '@/ui/layout/section/components/Section';

import { SettingsAccountsEmptyStateCard } from './SettingsAccountsEmptyStateCard';
import { SettingsAccountsConnectedAccountsEmptyStateCard } from './SettingsAccountsConnectedAccountsEmptyStateCard';

export const SettingsNewAccountSection = () => {
return (
Expand All @@ -10,7 +10,7 @@ export const SettingsNewAccountSection = () => {
title="New account"
description="Connect a new account to your workspace"
/>
<SettingsAccountsEmptyStateCard label="Connect a Google account" />
<SettingsAccountsConnectedAccountsEmptyStateCard label="Connect a Google account" />
</Section>
);
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useParams } from 'react-router-dom';

import { SettingsAccountsSynchronizationSection } from '@/settings/accounts/components/SettingsAccountsSynchronizationSection';
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
import { SettingsPath } from '@/types/SettingsPath';
Expand Down Expand Up @@ -30,6 +31,12 @@ export const SettingsAccountsCalendarsSettings = () => {
{ children: connectedAccount?.handle || '' },
]}
/>
<SettingsAccountsSynchronizationSection
description="Past and future calendar events will automatically be synced to this workspace"
cardTitle="Sync events"
isSynced={false}
onToggle={() => {}}
/>
</SettingsPageContainer>
</SubMenuTopBarContainer>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ export const SettingsAccountsEmailsInboxSettings = () => {
]}
/>
{/* TODO : discuss the desired sync behaviour */}
{/* <SettingsAccountsInboxSettingsSynchronizationSection
messageChannel={messageChannel}
{/* <SettingsAccountsSynchronizationSection
description="Past and future emails will automatically be synced to this workspace"
cardTitle="Sync emails"
isSynced={!!messageChannel?.isSynced}
onToggle={handleSynchronizationToggle}
/> */}
<SettingsAccountsInboxSettingsVisibilitySection
Expand Down

0 comments on commit 0f4d8ba

Please sign in to comment.