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 4f4ca5c commit 37fde02
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ 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 { SettingsAccountsListSkeletonCard } from '@/settings/accounts/components/SettingsAccountsSkeletonCard';
import { SettingsAccountsListEmptyStateCard } from '@/settings/accounts/components/SettingsAccountsListEmptyStateCard';
import { SettingsAccountsListSkeletonCard } from '@/settings/accounts/components/SettingsAccountsListSkeletonCard';
import { H2Title } from '@/ui/display/typography/components/H2Title';
import { Section } from '@/ui/layout/section/components/Section';

import { SettingsAccountsListEmptyStateCard } from './SettingsAccountsEmptyStateCard';

export const SettingsAccountsCalendarSettingsSection = () => {
const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState);

Expand Down
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 @@ -3,7 +3,7 @@ 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 { SettingsAccountsListCard } from './SettingsAccountsListCard';
import { SettingsAccountsListEmptyStateCard } from './SettingsAccountsListEmptyStateCard';

export const SettingsAccountsConnectedAccountsSection = ({
Expand All @@ -25,7 +25,7 @@ export const SettingsAccountsConnectedAccountsSection = ({
description="Manage your internet accounts."
/>
{accounts?.length ? (
<SettingsAccountsCard
<SettingsAccountsListCard
accounts={accounts}
onAccountRemove={handleAccountRemove}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ 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 { SettingsAccountsListSkeletonCard } from '@/settings/accounts/components/SettingsAccountsSkeletonCard';
import { SettingsAccountsEmailsCard } from '@/settings/accounts/components/SettingsAccountsEmailsCard';
import { SettingsAccountsListEmptyStateCard } from '@/settings/accounts/components/SettingsAccountsListEmptyStateCard';
import { SettingsAccountsListSkeletonCard } from '@/settings/accounts/components/SettingsAccountsListSkeletonCard';
import { H2Title } from '@/ui/display/typography/components/H2Title';
import { Section } from '@/ui/layout/section/components/Section';

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

export const SettingsAccountsEmailsSyncSection = () => {
const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState);

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
Expand Up @@ -4,6 +4,8 @@ import styled from '@emotion/styled';

import { ConnectedAccount } from '@/accounts/types/ConnectedAccount';
import { SettingsAccountsRowDropdownMenu } from '@/settings/accounts/components/SettingsAccountsRowDropdownMenu';
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 { LightIconButton } from '@/ui/input/button/components/LightIconButton';
Expand All @@ -30,15 +32,15 @@ const StyledDropdown = styled(SettingsAccountsRowDropdownMenu)`
margin-left: auto;
`;

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

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

Expand All @@ -61,7 +63,7 @@ export const SettingsAccountsCard = ({
<StyledIconButton
Icon={IconPlus}
accent="tertiary"
onClick={() => navigate('/settings/accounts/new')}
onClick={() => navigate(getSettingsPagePath(SettingsPath.NewAccount))}
/>
</StyledFooter>
</Card>
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,8 +1,7 @@
import { SettingsAccountsListEmptyStateCard } from '@/settings/accounts/components/SettingsAccountsListEmptyStateCard';
import { H2Title } from '@/ui/display/typography/components/H2Title';
import { Section } from '@/ui/layout/section/components/Section';

import { SettingsAccountsListEmptyStateCard } from './SettingsAccountsEmptyStateCard';

export const SettingsNewAccountSection = () => {
return (
<Section>
Expand Down
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 37fde02

Please sign in to comment.