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-7891 - Allow contact search on Organization Accounts without organization selected #937

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 @@ -64,26 +64,24 @@ const AccountListsOrganizations = (): ReactElement => {
{organizations?.length && (
<HeaderAndDropdown>
<Box>
{selectedOrganization && (
<TextField
label={t('Search Account Lists')}
value={search}
onChange={(e) => setSearch(e.target.value)}
fullWidth
multiline
inputProps={{ 'aria-label': 'Search Account Lists' }}
style={{
width: matches ? '150px' : '250px',
}}
InputProps={{
startAdornment: (
<InputAdornment position="start">
<PersonSearchIcon />
</InputAdornment>
),
}}
/>
)}
<TextField
label={t('Search Account Lists')}
value={search}
onChange={(e) => setSearch(e.target.value)}
fullWidth
multiline
inputProps={{ 'aria-label': 'Search Account Lists' }}
style={{
width: matches ? '150px' : '250px',
}}
InputProps={{
startAdornment: (
<InputAdornment position="start">
<PersonSearchIcon />
</InputAdornment>
),
}}
/>
</Box>
<Box>
<Autocomplete
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ extend type Query {
}

input SearchOrganizationsAccountListsInput {
organizationId: ID!
organizationId: ID
search: String!
pageNumber: Int
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ const SearchOrganizationsAccountListsResolvers: Resolvers = {
{ dataSources },
) => {
return dataSources.mpdxRestApi.searchOrganizationsAccountLists(
organizationId,
search,
pageNumber || 1,
organizationId || '',
);
},
},
Expand Down
9 changes: 5 additions & 4 deletions pages/api/graphql-rest.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1221,18 +1221,19 @@ class MpdxRestApi extends RESTDataSource {
//

async searchOrganizationsAccountLists(
organizationId: string,
search: string,
pageNumber = 1,
organizationId?: string,
) {
const include =
'account_list_users,account_list_coaches,account_list_users.user_email_addresses,' +
'account_list_coaches.coach_email_addresses,designation_accounts,' +
'designation_accounts.organization,account_list_invites,' +
'account_list_invites.invited_by_user';
const filters =
`filter[organization_id]=${organizationId}` +
`&filter[wildcard_search]=${search}`;
const organizationIdFilter = organizationId
? `&filter[organization_id]=${organizationId}`
: '';
const filters = `filter[wildcard_search]=${search}` + organizationIdFilter;
const fields =
'fields[account_lists]=name,account_list_coaches,account_list_users,account_list_invites,designation_accounts' +
'&fields[account_list_coaches]=coach_first_name,coach_last_name,coach_email_addresses' +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const AccountLists: React.FC = () => {
search: search,
},
},
skip: !selectedOrganizationId,
skip: !selectedOrganizationId && !search,
});

const accountLists = data?.searchOrganizationsAccountLists.accountLists;
Expand Down
Loading