Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preferences - Connect Services Page #820

Merged
merged 55 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
722be7b
Adding shared forms that we use on the Preferences
dr-bizz Nov 10, 2023
6f8940c
Fixing small errors and combining tests
dr-bizz Nov 13, 2023
7728d54
Merge branch 'main' into preferences-connect-services
dr-bizz Nov 13, 2023
55165f8
Creating page and context
dr-bizz Nov 13, 2023
2881f90
Helper functions also added variables to helpscout
dr-bizz Nov 13, 2023
4fda0ee
GraphQL Proxys needed for functionailty.
dr-bizz Nov 13, 2023
d4ae985
The Key Integration
dr-bizz Nov 13, 2023
878959d
Previously changed integrations page. Now fixing URL issue.
dr-bizz Nov 13, 2023
0a32381
The Oragnization integration
dr-bizz Nov 13, 2023
aac4426
Organization Helper functions
dr-bizz Nov 13, 2023
4c860f6
The key Image
dr-bizz Nov 13, 2023
212c0ef
The Google Integration
dr-bizz Nov 13, 2023
e9e3b98
The Mailchimp Integration
dr-bizz Nov 13, 2023
815beef
The PrayerLetter Integration
dr-bizz Nov 13, 2023
0a4b9e9
The Chalkline Integration
dr-bizz Nov 13, 2023
6f63002
2 test broke on Github but worked on local. Hoping this will fix them
dr-bizz Nov 14, 2023
6d7f3a0
Ensure sync test is working
dr-bizz Nov 14, 2023
60c57fd
Capitlaized IntegrationsContext
dr-bizz Nov 15, 2023
27c88ca
Renaming to something random so GIT picks up on the case change
dr-bizz Nov 15, 2023
8f2fd59
Capitial I in IntegrationsContext.tsx
dr-bizz Nov 15, 2023
4fcec99
Moving query.selectTab into the component.
dr-bizz Nov 15, 2023
c1613ad
Removing unused type
dr-bizz Nov 15, 2023
04e1d2d
Switching accountListID to accountListId
dr-bizz Nov 15, 2023
afb2cd5
Removing 'get' from GraphQL name
dr-bizz Nov 15, 2023
35c4d3e
.map to .forEach
dr-bizz Nov 15, 2023
03ff6c4
getMailchimpAccount - to - mailchimpAccount
dr-bizz Nov 15, 2023
e3978b4
getPrayerlettersAccount - to - PrayerlettersAccount
dr-bizz Nov 15, 2023
aa016f2
forEach
dr-bizz Nov 15, 2023
e811a0d
Google amendments
dr-bizz Nov 16, 2023
34af2d7
Fixing Lint issue with previous MailChimp change
dr-bizz Nov 16, 2023
26ed75b
MailChimp amendments
dr-bizz Nov 16, 2023
cbafc02
Changing Accordian to Accordion
dr-bizz Nov 16, 2023
70e4243
Fixing MailChimp lint issue
dr-bizz Nov 16, 2023
71a5e7d
Switching mpdx to appName
dr-bizz Nov 16, 2023
7fc1c62
Organization amendments
dr-bizz Nov 16, 2023
f3dfcfd
PrayerLetter amendments
dr-bizz Nov 16, 2023
05d2fd8
Odd amendments that I previously missed
dr-bizz Nov 16, 2023
6c46a67
Adding tests to Organization data sync upload file - Needed more tests
dr-bizz Nov 17, 2023
d26c6a6
simplifing code
dr-bizz Nov 20, 2023
f39f9b8
Adding tests for helpscout and env var to globalSetup for test
dr-bizz Nov 20, 2023
bd4919f
Adding tests to sync google integration
dr-bizz Nov 20, 2023
eee6562
Removing leftover code
dr-bizz Nov 28, 2023
bb2837a
Removing Components()
dr-bizz Nov 28, 2023
9e640d1
Localized edits
dr-bizz Nov 28, 2023
8ba9cb9
Small fixes
dr-bizz Nov 28, 2023
ae2ee65
Test fixes
dr-bizz Nov 28, 2023
3526957
Added Id for graphQL cache
dr-bizz Nov 28, 2023
cf204bb
Button styles and margins
dr-bizz Nov 29, 2023
82dff5c
Lint fixes
dr-bizz Nov 29, 2023
74a4712
Helpscout test fixes
dr-bizz Nov 29, 2023
3fef441
Making Helpscout changes so it's easier to merge with Caleb C's PRs
dr-bizz Nov 29, 2023
a6f5572
Helpscout - Fixing test errors
dr-bizz Nov 29, 2023
74ad75b
Merge branch 'main' into preferences-connect-services-2
dr-bizz Nov 30, 2023
006d4b7
Testing Chalkline opens new tab
dr-bizz Nov 30, 2023
a09a6c6
Added article export after merge
dr-bizz Nov 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,31 @@ import React, { ReactElement, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { GetServerSideProps } from 'next';
import { getToken } from 'next-auth/jwt';
import { useRouter } from 'next/router';
import { suggestArticles } from 'src/lib/helpScout';
import { AccordionGroup } from 'src/components/Shared/Forms/Accordions/AccordionGroup';
import { TheKeyAccordian } from 'src/components/Settings/integrations/Key/TheKeyAccordian';
import { OrganizationAccordian } from 'src/components/Settings/integrations/Organization/OrganizationAccordian';
import { GoogleAccordian } from 'src/components/Settings/integrations/Google/GoogleAccordian';
import { MailchimpAccordian } from 'src/components/Settings/integrations/Mailchimp/MailchimpAccordian';
import { PrayerlettersAccordian } from 'src/components/Settings/integrations/Prayerletters/PrayerlettersAccordian';
import { ChalklineAccordian } from 'src/components/Settings/integrations/Chalkline/ChalklineAccordian';
import { TheKeyAccordion } from 'src/components/Settings/integrations/Key/TheKeyAccordion';
import { OrganizationAccordion } from 'src/components/Settings/integrations/Organization/OrganizationAccordion';
import { GoogleAccordion } from 'src/components/Settings/integrations/Google/GoogleAccordion';
import { MailchimpAccordion } from 'src/components/Settings/integrations/Mailchimp/MailchimpAccordion';
import { PrayerlettersAccordion } from 'src/components/Settings/integrations/Prayerletters/PrayerlettersAccordion';
import { ChalklineAccordion } from 'src/components/Settings/integrations/Chalkline/ChalklineAccordion';
import { SettingsWrapper } from '../wrapper';
import { IntegrationsContextProvider } from './integrationsContext';
import { IntegrationsContextProvider } from './IntegrationsContext';

interface Props {
apiToken: string;
selectedTab: string;
}

const Integrations = ({ apiToken, selectedTab }: Props): ReactElement => {
const Integrations = ({ apiToken }: Props): ReactElement => {
const { t } = useTranslation();
const [expandedPanel, setExpandedPanel] = useState('');
const { query } = useRouter();
const [expandedPanel, setExpandedPanel] = useState(
(query?.selectedTab as string) || '',
);

useEffect(() => {
suggestArticles('HS_SETTINGS_SERVICES_SUGGESTIONS');
setExpandedPanel(selectedTab);
}, []);

const handleAccordionChange = (panel: string) => {
Expand All @@ -39,29 +41,29 @@ const Integrations = ({ apiToken, selectedTab }: Props): ReactElement => {
>
<IntegrationsContextProvider apiToken={apiToken}>
<AccordionGroup title="">
<TheKeyAccordian
<TheKeyAccordion
handleAccordionChange={handleAccordionChange}
expandedPanel={expandedPanel}
/>
<OrganizationAccordian
<OrganizationAccordion
handleAccordionChange={handleAccordionChange}
expandedPanel={expandedPanel}
/>
</AccordionGroup>
<AccordionGroup title={t('External Services')}>
<GoogleAccordian
<GoogleAccordion
handleAccordionChange={handleAccordionChange}
expandedPanel={expandedPanel}
/>
<MailchimpAccordian
<MailchimpAccordion
handleAccordionChange={handleAccordionChange}
expandedPanel={expandedPanel}
/>
<PrayerlettersAccordian
<PrayerlettersAccordion
handleAccordionChange={handleAccordionChange}
expandedPanel={expandedPanel}
/>
<ChalklineAccordian
<ChalklineAccordion
handleAccordionChange={handleAccordionChange}
expandedPanel={expandedPanel}
/>
Expand All @@ -71,22 +73,16 @@ const Integrations = ({ apiToken, selectedTab }: Props): ReactElement => {
);
};

export const getServerSideProps: GetServerSideProps = async ({
query,
req,
}) => {
export const getServerSideProps: GetServerSideProps = async ({ req }) => {
const jwtToken = (await getToken({
req,
secret: process.env.JWT_SECRET as string,
})) as { apiToken: string } | null;

const apiToken = jwtToken?.apiToken;
const selectedTab = query?.selectedTab ?? '';

return {
props: {
apiToken,
selectedTab,
},
};
};
Expand Down
2 changes: 1 addition & 1 deletion pages/accountLists/[accountListId]/settings/wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const SettingsWrapper: React.FC<SettingsWrapperProps> = ({
children,
}) => {
const { appName } = useGetAppSettings();
const [isNavListOpen, setNavListOpen] = useState<boolean>(false);
const [isNavListOpen, setNavListOpen] = useState(false);
const handleNavListToggle = () => {
setNavListOpen(!isNavListOpen);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ extend type Mutation {
input CreateGoogleIntegrationInput {
googleAccountId: ID!
googleIntegration: GoogleAccountIntegrationInput
accountListID: String!
accountListId: String!
}

input GoogleAccountIntegrationInput {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const CreateGoogleIntegration = (
data: CreateGoogleIntegrationResponse,
): CreateGoogleIntegrationAttributesCamel => {
const attributes = {} as Omit<CreateGoogleIntegrationAttributesCamel, 'id'>;
Object.keys(data.attributes).map((key) => {
Object.keys(data.attributes).forEach((key) => {
attributes[snakeToCamel(key)] = data.attributes[key];
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ const CreateGoogleIntegrationResolvers: Resolvers = {
Mutation: {
createGoogleIntegration: async (
_source,
{ input: { googleAccountId, googleIntegration, accountListID } },
{ input: { googleAccountId, googleIntegration, accountListId } },
{ dataSources },
) => {
return dataSources.mpdxRestApi.createGoogleIntegration(
googleAccountId,
googleIntegration,
accountListID,
accountListId,
);
},
},
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { snakeToCamel } from 'src/lib/snakeToCamel';

export interface GoogleAccountIntegrationsResponse {
id: string;
type: string;
attributes: Omit<GoogleAccountIntegrationAttributes, 'id'>;
relationships: relationships;
}
type relationships = {
account_list: object[];
google_account: object[];
};
export interface GoogleAccountIntegrationAttributes {
calendar_id: string;
calendar_integration: boolean;
calendar_integrations: string[];
calendar_name: string;
calendars: calendars[];
created_at: string;
updated_at: string;
id: string;
updated_in_db_at: string;
}
interface GoogleAccountIntegrationAttributesCamel {
calendarId: string;
calendarIntegration: boolean;
calendarIntegrations: string[];
calendarName: string;
calendars: calendars[];
createdAt: string;
updatedAt: string;
id: string;
updatedInDbAt: string;
}
type calendars = {
id: string;
name: string;
};

export const GoogleAccountIntegrations = (
data: GoogleAccountIntegrationsResponse[],
): GoogleAccountIntegrationAttributesCamel[] => {
return data.map((integrations) => {
const attributes = {} as Omit<
GoogleAccountIntegrationAttributesCamel,
'id'
>;
Object.keys(integrations.attributes).forEach((key) => {
attributes[snakeToCamel(key)] = integrations.attributes[key];
});
return { id: integrations.id, ...attributes };
}, []);
dr-bizz marked this conversation as resolved.
Show resolved Hide resolved
};
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
extend type Query {
getGoogleAccountIntegrations(
input: GetGoogleAccountIntegrationsInput!
googleAccountIntegrations(
input: GoogleAccountIntegrationsInput!
): [GoogleAccountIntegration]!
}

input GetGoogleAccountIntegrationsInput {
input GoogleAccountIntegrationsInput {
googleAccountId: ID!
accountListId: ID!
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { Resolvers } from '../../../../../../graphql-rest.page.generated';

const GetGoogleAccountIntegrationsResolvers: Resolvers = {
const GoogleAccountIntegrationsResolvers: Resolvers = {
Query: {
getGoogleAccountIntegrations: async (
googleAccountIntegrations: async (
_source,
{ input: { googleAccountId, accountListId } },
{ dataSources },
) => {
return dataSources.mpdxRestApi.getGoogleAccountIntegrations(
return dataSources.mpdxRestApi.googleAccountIntegrations(
googleAccountId,
accountListId,
);
},
},
};

export { GetGoogleAccountIntegrationsResolvers };
export { GoogleAccountIntegrationsResolvers };
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { snakeToCamel } from 'src/lib/snakeToCamel';

export interface GetGoogleAccountsResponse {
attributes: Omit<GetGoogleAccountAttributes, 'id'>;
export interface GoogleAccountsResponse {
attributes: Omit<GoogleAccountAttributes, 'id'>;
id: string;
relationships: {
contact_groups: {
Expand All @@ -11,7 +11,7 @@ export interface GetGoogleAccountsResponse {
type: string;
}

export interface GetGoogleAccountAttributes {
export interface GoogleAccountAttributes {
id: string;
created_at: string;
email: string;
Expand All @@ -25,7 +25,7 @@ export interface GetGoogleAccountAttributes {
updated_in_db_at: string;
}

interface GetGoogleAccountAttributesCamel {
interface GoogleAccountAttributesCamel {
id: string;
createdAt: string;
email: string;
Expand All @@ -39,15 +39,15 @@ interface GetGoogleAccountAttributesCamel {
updatedInDbAt: string;
}

export const GetGoogleAccounts = (
data: GetGoogleAccountsResponse[],
): GetGoogleAccountAttributesCamel[] => {
return data.reduce((prev: GetGoogleAccountAttributesCamel[], current) => {
const attributes = {} as Omit<GetGoogleAccountAttributesCamel, 'id'>;
Object.keys(current.attributes).map((key) => {
attributes[snakeToCamel(key)] = current.attributes[key];
export const GoogleAccounts = (
data: GoogleAccountsResponse[],
): GoogleAccountAttributesCamel[] => {
return data.map((accounts) => {
const attributes = {} as Omit<GoogleAccountAttributesCamel, 'id'>;
Object.keys(accounts.attributes).map((key) => {
attributes[snakeToCamel(key)] = accounts.attributes[key];
});

return prev.concat([{ id: current.id, ...attributes }]);
return { id: accounts.id, ...attributes };
}, []);
dr-bizz marked this conversation as resolved.
Show resolved Hide resolved
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
extend type Query {
getGoogleAccounts: [GoogleAccountAttributes]!
googleAccounts: [GoogleAccountAttributes]!
}

type GoogleAccountAttributes {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Resolvers } from '../../../../../../graphql-rest.page.generated';

const GoogleAccountsResolvers: Resolvers = {
Query: {
googleAccounts: async (_source, {}, { dataSources }) => {
return dataSources.mpdxRestApi.googleAccounts();
},
},
};

export { GoogleAccountsResolvers };
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const UpdateGoogleIntegration = (
GetGoogleAccountIntegrationAttributesCamel,
'id'
>;
Object.keys(data.attributes).map((key) => {
Object.keys(data.attributes).forEach((key) => {
attributes[snakeToCamel(key)] = data.attributes[key];
});

Expand Down
Loading
Loading