Skip to content

Commit

Permalink
Preload contacts right panel links
Browse files Browse the repository at this point in the history
  • Loading branch information
canac committed Apr 29, 2024
1 parent 9f40496 commit da17fb4
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
8 changes: 7 additions & 1 deletion src/components/Contacts/ContactRow/ContactRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
import { CelebrationIcons } from '../CelebrationIcons/CelebrationIcons';
import { ContactPartnershipStatus } from '../ContactPartnershipStatus/ContactPartnershipStatus';
import { ContactUncompletedTasksCount } from '../ContactUncompletedTasksCount/ContactUncompletedTasksCount';
import { preloadContactsRightPanel } from '../ContactsRightPanel/DynamicContactsRightPanel';
import { StarContactIconButton } from '../StarContactIconButton/StarContactIconButton';
import { ContactRowFragment } from './ContactRow.generated';

Expand Down Expand Up @@ -75,7 +76,12 @@ export const ContactRow: React.FC<Props> = ({ contact, useTopMargin }) => {
} = contact;

return (
<ListItemButton focusRipple onClick={onClick} data-testid="rowButton">
<ListItemButton
focusRipple
onClick={onClick}
onMouseEnter={preloadContactsRightPanel}
data-testid="rowButton"
>
<Hidden xsDown>
<ListItemIcon>
<StyledCheckbox
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import dynamic from 'next/dynamic';
import { DynamicComponentPlaceholder } from 'src/components/DynamicPlaceholders/DynamicComponentPlaceholder';

export const DynamicContactsRightPanel = dynamic(
() =>
import(
/* webpackChunkName: "ContactsRightPanel" */ './ContactsRightPanel'
).then(({ ContactsRightPanel }) => ContactsRightPanel),
{ loading: DynamicComponentPlaceholder },
);
export const preloadContactsRightPanel = () =>
import(
/* webpackChunkName: "ContactsRightPanel" */ './ContactsRightPanel'
).then(({ ContactsRightPanel }) => ContactsRightPanel);

export const DynamicContactsRightPanel = dynamic(preloadContactsRightPanel, {
loading: DynamicComponentPlaceholder,
});
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { styled } from '@mui/material/styles';
import { DataGrid, GridColDef, GridSortModel } from '@mui/x-data-grid';
import { DateTime } from 'luxon';
import { useTranslation } from 'react-i18next';
import { preloadContactsRightPanel } from 'src/components/Contacts/ContactsRightPanel/DynamicContactsRightPanel';
import {
DynamicEditDonationModal,
preloadEditDonationModal,
Expand Down Expand Up @@ -190,6 +191,7 @@ export const DonationsReportTable: React.FC<DonationReportTableProps> = ({
<Link
underline="hover"
onClick={() => row.contactId && onSelectContact(row.contactId)}
onMouseEnter={preloadContactsRightPanel}
>
{row.donorAccountName}
</Link>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from '@mui/material';
import { styled } from '@mui/material/styles';
import { useTranslation } from 'react-i18next';
import { preloadContactsRightPanel } from 'src/components/Contacts/ContactsRightPanel/DynamicContactsRightPanel';
import { useLocale } from 'src/hooks/useLocale';
import theme from 'src/theme';
import { numberFormat } from '../../../../../lib/intlFormat';
Expand Down Expand Up @@ -120,6 +121,7 @@ export const FourteenMonthReportTable: React.FC<
<NameTypography variant="body1" expanded={isExpanded}>
<Link
onClick={() => onSelectContact(contact.id)}
onMouseEnter={preloadContactsRightPanel}
underline="hover"
>
{contact.name}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import { styled } from '@mui/material/styles';
import { DateTime } from 'luxon';
import { useTranslation } from 'react-i18next';
import { preloadContactsRightPanel } from 'src/components/Contacts/ContactsRightPanel/DynamicContactsRightPanel';
import { useLocale } from 'src/hooks/useLocale';
import { currencyFormat, dateFormatShort } from 'src/lib/intlFormat';
import { PartnerGivingAnalysisReportTableHead as TableHead } from './TableHead/TableHead';
Expand Down Expand Up @@ -125,7 +126,10 @@ export const PartnerGivingAnalysisReportTable: FC<
/>
</TableCell>
<TableCell>
<ContactName onClick={() => onClick(contact.id)}>
<ContactName
onClick={() => onClick(contact.id)}
onMouseEnter={preloadContactsRightPanel}
>
{contact.name}
</ContactName>
</TableCell>
Expand Down

0 comments on commit da17fb4

Please sign in to comment.