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

MPDX-8492 - Enhance loadSession to Redirect Placeholder _ to Default Account List #1225

Merged
merged 2 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions pages/acceptInvite.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useTranslation } from 'react-i18next';
import { SetupPage } from 'src/components/Setup/SetupPage';
import useGetAppSettings from 'src/hooks/useGetAppSettings';
import { useRequiredSession } from 'src/hooks/useRequiredSession';
import { loadSession } from './api/utils/pagePropsHelpers';
import { ensureSessionAndAccountList } from './api/utils/pagePropsHelpers';

interface FetchAcceptInviteProps {
apiToken: string;
Expand Down Expand Up @@ -149,6 +149,6 @@ const AcceptInvitePage = (): ReactElement => {
);
};

export const getServerSideProps = loadSession;
export const getServerSideProps = ensureSessionAndAccountList;

export default AcceptInvitePage;
13 changes: 12 additions & 1 deletion pages/accountLists/[accountListId].page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
GetDefaultAccountDocument,
GetDefaultAccountQuery,
} from 'pages/api/getDefaultAccount.generated';
import { makeGetServerSideProps } from 'pages/api/utils/pagePropsHelpers';
import {
handleUnderscoreAccountListRedirect,
makeGetServerSideProps,
} from 'pages/api/utils/pagePropsHelpers';
import { logErrorOnRollbar } from 'pages/api/utils/rollBar';
import Dashboard from 'src/components/Dashboard';
import {
Expand Down Expand Up @@ -81,6 +84,14 @@

export const getServerSideProps = makeGetServerSideProps(
async (session, { query, req }) => {
const underscoreRedirect = await handleUnderscoreAccountListRedirect(
session,
req.url,
);
if (underscoreRedirect) {
return underscoreRedirect;

Check warning on line 92 in pages/accountLists/[accountListId].page.tsx

View check run for this annotation

Codecov / codecov/patch

pages/accountLists/[accountListId].page.tsx#L92

Added line #L92 was not covered by tests
}

const ssrClient = makeSsrClient(session.user.apiToken);

try {
Expand Down
4 changes: 2 additions & 2 deletions pages/accountLists/[accountListId]/coaching.page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Head from 'next/head';
import React from 'react';
import { useTranslation } from 'react-i18next';
import { loadSession } from 'pages/api/utils/pagePropsHelpers';
import { ensureSessionAndAccountList } from 'pages/api/utils/pagePropsHelpers';

Check warning on line 4 in pages/accountLists/[accountListId]/coaching.page.tsx

View check run for this annotation

Codecov / codecov/patch

pages/accountLists/[accountListId]/coaching.page.tsx#L4

Added line #L4 was not covered by tests
import { CoachingList } from 'src/components/Coaching/CoachingList';
import Loading from 'src/components/Loading';
import { useAccountListId } from 'src/hooks/useAccountListId';
Expand All @@ -26,6 +26,6 @@
);
};

export const getServerSideProps = loadSession;
export const getServerSideProps = ensureSessionAndAccountList;

Check warning on line 29 in pages/accountLists/[accountListId]/coaching.page.tsx

View check run for this annotation

Codecov / codecov/patch

pages/accountLists/[accountListId]/coaching.page.tsx#L29

Added line #L29 was not covered by tests

export default CoachingPage;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { useRouter } from 'next/router';
import React from 'react';
import { useTranslation } from 'react-i18next';
import { loadSession } from 'pages/api/utils/pagePropsHelpers';
import { ensureSessionAndAccountList } from 'pages/api/utils/pagePropsHelpers';

Check warning on line 5 in pages/accountLists/[accountListId]/coaching/[coachingId].page.tsx

View check run for this annotation

Codecov / codecov/patch

pages/accountLists/[accountListId]/coaching/[coachingId].page.tsx#L5

Added line #L5 was not covered by tests
import {
AccountListTypeEnum,
CoachingDetail,
Expand Down Expand Up @@ -35,6 +35,6 @@
);
};

export const getServerSideProps = loadSession;
export const getServerSideProps = ensureSessionAndAccountList;

Check warning on line 38 in pages/accountLists/[accountListId]/coaching/[coachingId].page.tsx

View check run for this annotation

Codecov / codecov/patch

pages/accountLists/[accountListId]/coaching/[coachingId].page.tsx#L38

Added line #L38 was not covered by tests

export default CoachingPage;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Head from 'next/head';
import React, { useContext } from 'react';
import { useTranslation } from 'react-i18next';
import { loadSession } from 'pages/api/utils/pagePropsHelpers';
import { ensureSessionAndAccountList } from 'pages/api/utils/pagePropsHelpers';
import {
ContactsContext,
ContactsType,
Expand Down Expand Up @@ -72,4 +72,4 @@ const ContactsPage: React.FC = () => (

export default ContactsPage;

export const getServerSideProps = loadSession;
export const getServerSideProps = ensureSessionAndAccountList;
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { HTML5Backend } from 'react-dnd-html5-backend';
import { useTranslation } from 'react-i18next';
import { v4 as uuidv4 } from 'uuid';
import { loadSession } from 'pages/api/utils/pagePropsHelpers';
import { ensureSessionAndAccountList } from 'pages/api/utils/pagePropsHelpers';

Check warning on line 11 in pages/accountLists/[accountListId]/contacts/flows/setup.page.tsx

View check run for this annotation

Codecov / codecov/patch

pages/accountLists/[accountListId]/contacts/flows/setup.page.tsx#L11

Added line #L11 was not covered by tests
import { colorMap } from 'src/components/Contacts/ContactFlow/ContactFlow';
import { ContactFlowSetupColumn } from 'src/components/Contacts/ContactFlow/ContactFlowSetup/Column/ContactFlowSetupColumn';
import { UnusedStatusesColumn } from 'src/components/Contacts/ContactFlow/ContactFlowSetup/Column/UnusedStatusesColumn';
Expand Down Expand Up @@ -228,6 +228,6 @@
);
};

export const getServerSideProps = loadSession;
export const getServerSideProps = ensureSessionAndAccountList;

Check warning on line 231 in pages/accountLists/[accountListId]/contacts/flows/setup.page.tsx

View check run for this annotation

Codecov / codecov/patch

pages/accountLists/[accountListId]/contacts/flows/setup.page.tsx#L231

Added line #L231 was not covered by tests

export default ContactFlowSetupPage;
4 changes: 2 additions & 2 deletions pages/accountLists/[accountListId]/reports/coaching.page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Head from 'next/head';
import React, { ReactElement } from 'react';
import { useTranslation } from 'react-i18next';
import { loadSession } from 'pages/api/utils/pagePropsHelpers';
import { ensureSessionAndAccountList } from 'pages/api/utils/pagePropsHelpers';

Check warning on line 4 in pages/accountLists/[accountListId]/reports/coaching.page.tsx

View check run for this annotation

Codecov / codecov/patch

pages/accountLists/[accountListId]/reports/coaching.page.tsx#L4

Added line #L4 was not covered by tests
import {
AccountListTypeEnum,
CoachingDetail,
Expand Down Expand Up @@ -32,6 +32,6 @@
);
};

export const getServerSideProps = loadSession;
export const getServerSideProps = ensureSessionAndAccountList;

Check warning on line 35 in pages/accountLists/[accountListId]/reports/coaching.page.tsx

View check run for this annotation

Codecov / codecov/patch

pages/accountLists/[accountListId]/reports/coaching.page.tsx#L35

Added line #L35 was not covered by tests

export default CoachingReportPage;
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { Box } from '@mui/material';
import { styled } from '@mui/material/styles';
import { useTranslation } from 'react-i18next';
import { loadSession } from 'pages/api/utils/pagePropsHelpers';
import { ensureSessionAndAccountList } from 'pages/api/utils/pagePropsHelpers';

Check warning on line 6 in pages/accountLists/[accountListId]/reports/designationAccounts.page.tsx

View check run for this annotation

Codecov / codecov/patch

pages/accountLists/[accountListId]/reports/designationAccounts.page.tsx#L6

Added line #L6 was not covered by tests
import { SidePanelsLayout } from 'src/components/Layouts/SidePanelsLayout';
import Loading from 'src/components/Loading';
import { DesignationAccountsReport } from 'src/components/Reports/DesignationAccountsReport/DesignationAccountsReport';
Expand Down Expand Up @@ -67,6 +67,6 @@
);
};

export const getServerSideProps = loadSession;
export const getServerSideProps = ensureSessionAndAccountList;

Check warning on line 70 in pages/accountLists/[accountListId]/reports/designationAccounts.page.tsx

View check run for this annotation

Codecov / codecov/patch

pages/accountLists/[accountListId]/reports/designationAccounts.page.tsx#L70

Added line #L70 was not covered by tests

export default DesignationAccountsReportPage;
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { Box } from '@mui/material';
import { styled } from '@mui/material/styles';
import { useTranslation } from 'react-i18next';
import { loadSession } from 'pages/api/utils/pagePropsHelpers';
import { ensureSessionAndAccountList } from 'pages/api/utils/pagePropsHelpers';

Check warning on line 7 in pages/accountLists/[accountListId]/reports/donations/[[...contactId]].page.tsx

View check run for this annotation

Codecov / codecov/patch

pages/accountLists/[accountListId]/reports/donations/[[...contactId]].page.tsx#L7

Added line #L7 was not covered by tests
import { DynamicContactsRightPanel } from 'src/components/Contacts/ContactsRightPanel/DynamicContactsRightPanel';
import { SidePanelsLayout } from 'src/components/Layouts/SidePanelsLayout';
import Loading from 'src/components/Loading';
Expand Down Expand Up @@ -89,6 +89,6 @@
);
};

export const getServerSideProps = loadSession;
export const getServerSideProps = ensureSessionAndAccountList;

Check warning on line 92 in pages/accountLists/[accountListId]/reports/donations/[[...contactId]].page.tsx

View check run for this annotation

Codecov / codecov/patch

pages/accountLists/[accountListId]/reports/donations/[[...contactId]].page.tsx#L92

Added line #L92 was not covered by tests

export default DonationsReportPage;
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React, { ReactElement, useState } from 'react';
import { Box } from '@mui/material';
import { styled } from '@mui/material/styles';
import { useTranslation } from 'react-i18next';
import { loadSession } from 'pages/api/utils/pagePropsHelpers';
import { ensureSessionAndAccountList } from 'pages/api/utils/pagePropsHelpers';
import { DynamicContactsRightPanel } from 'src/components/Contacts/ContactsRightPanel/DynamicContactsRightPanel';
import { SidePanelsLayout } from 'src/components/Layouts/SidePanelsLayout';
import Loading from 'src/components/Loading';
Expand Down Expand Up @@ -101,6 +101,6 @@ const ExpectedMonthlyTotalReportPage = (): ReactElement => {
);
};

export const getServerSideProps = loadSession;
export const getServerSideProps = ensureSessionAndAccountList;

export default ExpectedMonthlyTotalReportPage;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Head from 'next/head';
import React, { useState } from 'react';
import { Box } from '@mui/material';
import { useTranslation } from 'react-i18next';
import { loadSession } from 'pages/api/utils/pagePropsHelpers';
import { ensureSessionAndAccountList } from 'pages/api/utils/pagePropsHelpers';
import { SidePanelsLayout } from 'src/components/Layouts/SidePanelsLayout';
import Loading from 'src/components/Loading';
import { AccountSummary } from 'src/components/Reports/FinancialAccountsReport/AccountSummary/AccountSummary';
Expand Down Expand Up @@ -61,6 +61,6 @@ const FinancialAccountSummaryPage: React.FC = () => {
);
};

export const getServerSideProps = loadSession;
export const getServerSideProps = ensureSessionAndAccountList;

export default FinancialAccountSummaryPage;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Head from 'next/head';
import React, { ReactElement, useContext, useMemo } from 'react';
import { Box } from '@mui/material';
import { useTranslation } from 'react-i18next';
import { loadSession } from 'pages/api/utils/pagePropsHelpers';
import { ensureSessionAndAccountList } from 'pages/api/utils/pagePropsHelpers';
import { SidePanelsLayout } from 'src/components/Layouts/SidePanelsLayout';
import Loading from 'src/components/Loading';
import { AccountTransactions } from 'src/components/Reports/FinancialAccountsReport/AccountTransactions/AccountTransactions';
Expand Down Expand Up @@ -168,6 +168,6 @@ const FinancialAccountsPage: React.FC = () => (
</FinancialAccountsWrapper>
);

export const getServerSideProps = loadSession;
export const getServerSideProps = ensureSessionAndAccountList;

export default FinancialAccountsPage;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Head from 'next/head';
import React, { useState } from 'react';
import { Box } from '@mui/material';
import { useTranslation } from 'react-i18next';
import { loadSession } from 'pages/api/utils/pagePropsHelpers';
import { ensureSessionAndAccountList } from 'pages/api/utils/pagePropsHelpers';
import { SidePanelsLayout } from 'src/components/Layouts/SidePanelsLayout';
import Loading from 'src/components/Loading';
import { FinancialAccounts } from 'src/components/Reports/FinancialAccountsReport/FinancialAccounts/FinancialAccounts';
Expand Down Expand Up @@ -64,6 +64,6 @@ const FinancialAccountsPage: React.FC = () => {
);
};

export const getServerSideProps = loadSession;
export const getServerSideProps = ensureSessionAndAccountList;

export default FinancialAccountsPage;
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React, { useState } from 'react';
import { Box } from '@mui/material';
import { styled } from '@mui/material/styles';
import { useTranslation } from 'react-i18next';
import { loadSession } from 'pages/api/utils/pagePropsHelpers';
import { ensureSessionAndAccountList } from 'pages/api/utils/pagePropsHelpers';
import { DynamicContactsRightPanel } from 'src/components/Contacts/ContactsRightPanel/DynamicContactsRightPanel';
import { SidePanelsLayout } from 'src/components/Layouts/SidePanelsLayout';
import Loading from 'src/components/Loading';
Expand Down Expand Up @@ -90,6 +90,6 @@ const PartnerCurrencyReportPage: React.FC = () => {
);
};

export const getServerSideProps = loadSession;
export const getServerSideProps = ensureSessionAndAccountList;

export default PartnerCurrencyReportPage;
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React, { useMemo, useRef, useState } from 'react';
import { sortBy } from 'lodash';
import { useTranslation } from 'react-i18next';
import { ReportContactFilterSetInput } from 'pages/api/graphql-rest.page.generated';
import { loadSession } from 'pages/api/utils/pagePropsHelpers';
import { ensureSessionAndAccountList } from 'pages/api/utils/pagePropsHelpers';
import { ContactsProvider } from 'src/components/Contacts/ContactsContext/ContactsContext';
import { DynamicContactsRightPanel } from 'src/components/Contacts/ContactsRightPanel/DynamicContactsRightPanel';
import { SidePanelsLayout } from 'src/components/Layouts/SidePanelsLayout';
Expand Down Expand Up @@ -174,6 +174,6 @@ const PartnerGivingAnalysisReportPage: React.FC = () => {
);
};

export const getServerSideProps = loadSession;
export const getServerSideProps = ensureSessionAndAccountList;

export default PartnerGivingAnalysisReportPage;
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React, { useState } from 'react';
import { Box } from '@mui/material';
import { styled } from '@mui/material/styles';
import { useTranslation } from 'react-i18next';
import { loadSession } from 'pages/api/utils/pagePropsHelpers';
import { ensureSessionAndAccountList } from 'pages/api/utils/pagePropsHelpers';
import { DynamicContactsRightPanel } from 'src/components/Contacts/ContactsRightPanel/DynamicContactsRightPanel';
import { SidePanelsLayout } from 'src/components/Layouts/SidePanelsLayout';
import Loading from 'src/components/Loading';
Expand Down Expand Up @@ -90,6 +90,6 @@ const SalaryCurrencyReportPage: React.FC = () => {
);
};

export const getServerSideProps = loadSession;
export const getServerSideProps = ensureSessionAndAccountList;

export default SalaryCurrencyReportPage;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useRouter } from 'next/router';
import React, { useEffect, useState } from 'react';
import { Button } from '@mui/material';
import { useTranslation } from 'react-i18next';
import { loadSession } from 'pages/api/utils/pagePropsHelpers';
import { ensureSessionAndAccountList } from 'pages/api/utils/pagePropsHelpers';
import { ChalklineAccordion } from 'src/components/Settings/integrations/Chalkline/ChalklineAccordion';
import { GoogleAccordion } from 'src/components/Settings/integrations/Google/GoogleAccordion';
import { TheKeyAccordion } from 'src/components/Settings/integrations/Key/TheKeyAccordion';
Expand Down Expand Up @@ -120,6 +120,6 @@ const Integrations: React.FC = () => {
);
};

export const getServerSideProps = loadSession;
export const getServerSideProps = ensureSessionAndAccountList;

export default Integrations;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useRouter } from 'next/router';
import React, { ReactElement, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { loadSession } from 'pages/api/utils/pagePropsHelpers';
import { ensureSessionAndAccountList } from 'pages/api/utils/pagePropsHelpers';
import { ManageAccountAccessAccordion } from 'src/components/Settings/Accounts/ManageAccountAccess/ManageAccountAccessAccordion';
import { MergeAccountsAccordion } from 'src/components/Settings/Accounts/MergeAccounts/MergeAccountsAccordion';
import { MergeSpouseAccountsAccordion } from 'src/components/Settings/Accounts/MergeSpouseAccounts/MergeSpouseAccountsAccordion';
Expand Down Expand Up @@ -50,6 +50,6 @@ const ManageAccounts = (): ReactElement => {
);
};

export const getServerSideProps = loadSession;
export const getServerSideProps = ensureSessionAndAccountList;

export default ManageAccounts;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useRouter } from 'next/router';
import React, { ReactElement, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { loadSession } from 'pages/api/utils/pagePropsHelpers';
import { ensureSessionAndAccountList } from 'pages/api/utils/pagePropsHelpers';
import { ManageCoachesAccessAccordion } from 'src/components/Settings/Coaches/ManageCoachesAccess/ManageCoachesAccessAccordion';
import { AccordionGroup } from 'src/components/Shared/Forms/Accordions/AccordionGroup';
import { SettingsWrapper } from './Wrapper';
Expand Down Expand Up @@ -36,6 +36,6 @@ const ManageCoaching = (): ReactElement => {
);
};

export const getServerSideProps = loadSession;
export const getServerSideProps = ensureSessionAndAccountList;

export default ManageCoaching;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useRouter } from 'next/router';
import React from 'react';
import { Box, Button } from '@mui/material';
import { useTranslation } from 'react-i18next';
import { loadSession } from 'pages/api/utils/pagePropsHelpers';
import { ensureSessionAndAccountList } from 'pages/api/utils/pagePropsHelpers';
import { NotificationsTable } from 'src/components/Settings/notifications/NotificationsTable';
import { SetupBanner } from 'src/components/Settings/preferences/SetupBanner';
import { useSetupContext } from 'src/components/Setup/SetupProvider';
Expand Down Expand Up @@ -78,6 +78,6 @@ const Notifications: React.FC = () => {
);
};

export const getServerSideProps = loadSession;
export const getServerSideProps = ensureSessionAndAccountList;

export default Notifications;
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { ReactElement, useEffect, useState } from 'react';
import { Autocomplete, Box, Skeleton, TextField } from '@mui/material';
import { styled } from '@mui/material/styles';
import { useTranslation } from 'react-i18next';
import { loadSession } from 'pages/api/utils/pagePropsHelpers';
import { ensureSessionAndAccountList } from 'pages/api/utils/pagePropsHelpers';
import { ImpersonateUserAccordion } from 'src/components/Settings/Organization/ImpersonateUser/ImpersonateUserAccordion';
import { ManageOrganizationAccessAccordion } from 'src/components/Settings/Organization/ManageOrganizationAccess/ManageOrganizationAccessAccordion';
import { AccordionGroup } from 'src/components/Shared/Forms/Accordions/AccordionGroup';
Expand Down Expand Up @@ -139,6 +139,6 @@ const Organizations = (): ReactElement => {
);
};

export const getServerSideProps = loadSession;
export const getServerSideProps = ensureSessionAndAccountList;

export default Organizations;
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import { styled } from '@mui/material/styles';
import useMediaQuery from '@mui/material/useMediaQuery';
import { useTranslation } from 'react-i18next';
import { loadSession } from 'pages/api/utils/pagePropsHelpers';
import { ensureSessionAndAccountList } from 'pages/api/utils/pagePropsHelpers';

Check warning on line 14 in pages/accountLists/[accountListId]/settings/organizations/accountLists.page.tsx

View check run for this annotation

Codecov / codecov/patch

pages/accountLists/[accountListId]/settings/organizations/accountLists.page.tsx#L14

Added line #L14 was not covered by tests
import { AccountLists } from 'src/components/Settings/Organization/AccountLists/AccountLists';
import { useDebouncedValue } from 'src/hooks/useDebounce';
import { SettingsWrapper } from '../Wrapper';
Expand Down Expand Up @@ -143,6 +143,6 @@
);
};

export const getServerSideProps = loadSession;
export const getServerSideProps = ensureSessionAndAccountList;

Check warning on line 146 in pages/accountLists/[accountListId]/settings/organizations/accountLists.page.tsx

View check run for this annotation

Codecov / codecov/patch

pages/accountLists/[accountListId]/settings/organizations/accountLists.page.tsx#L146

Added line #L146 was not covered by tests

export default AccountListsOrganizations;
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import { styled } from '@mui/material/styles';
import useMediaQuery from '@mui/material/useMediaQuery';
import { useTranslation } from 'react-i18next';
import { loadSession } from 'pages/api/utils/pagePropsHelpers';
import { ensureSessionAndAccountList } from 'pages/api/utils/pagePropsHelpers';
import { Contacts } from 'src/components/Settings/Organization/Contacts/Contacts';
import { useDebouncedValue } from 'src/hooks/useDebounce';
import { SettingsWrapper } from '../Wrapper';
Expand Down Expand Up @@ -130,6 +130,6 @@ const OrganizationsContacts = (): ReactElement => {
);
};

export const getServerSideProps = loadSession;
export const getServerSideProps = ensureSessionAndAccountList;

export default OrganizationsContacts;
Loading
Loading