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-8472] Generate URLs with current accountListId #1208

Merged
merged 1 commit into from
Nov 22, 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
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const ContactsWrapper: React.FC<Props> = ({
}) => {
const router = useRouter();
const { query, replace, pathname } = router;
const { accountListId } = query;

// Extract the initial contact id from the URL
const [contactId, setContactId] = useState<string | undefined>(() =>
Expand Down Expand Up @@ -92,7 +93,7 @@ export const ContactsWrapper: React.FC<Props> = ({
}, [viewMode, activeFiltersRaw]);

const getContactHrefObject: GetContactHrefObject = useCallback(
(contactId) => {
(contactId?: string) => {
// Omit the filters and searchTerm from the previous query because we don't want them in the URL
// if they are empty and Next.js will still add them to the URL query even if they are undefined.
// i.e. { filters: undefined, searchTerm: '' } results in a querystring of ?filters=&searchTerm
Expand Down Expand Up @@ -120,12 +121,12 @@ export const ContactsWrapper: React.FC<Props> = ({
query: newQuery,
};
},
[viewMode, activeFilters, searchTerm, pathname],
[accountListId, viewMode, activeFilters, searchTerm, pathname],
);

const urlQuery = useMemo(() => {
return getContactHrefObject(contactId).query;
}, [contactId, viewMode, activeFilters, searchTerm]);
}, [contactId, getContactHrefObject]);

useEffect(() => {
replace({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const useTasksContactContext = (): ContactsContextProps => {

const urlQuery = useMemo(() => {
return getContactHrefObject(contactId).query;
}, [accountListId, contactId, activeFilters, searchTerm]);
}, [contactId, getContactHrefObject]);

useEffect(() => {
replace({
Expand Down
Loading