Skip to content

Commit

Permalink
fix: correct org id in react samples folded results list page (#2962)
Browse files Browse the repository at this point in the history
* fix org id

https://coveord.atlassian.net/browse/KIT-2525

* fix results image

https://coveord.atlassian.net/browse/KIT-2525

* run atomic build to prevent webpack errors

https://coveord.atlassian.net/browse/KIT-2525

* Revert "fix org id"

This reverts commit a0634e1.

* add aq to point to a different source for folded result list

https://coveord.atlassian.net/browse/KIT-2525

* revert changes to folded result img

https://coveord.atlassian.net/browse/KIT-2525

* use atomic result image with fallback

https://coveord.atlassian.net/browse/KIT-2525

* replace expression prop with a boolean param

https://coveord.atlassian.net/browse/KIT-2525

* add nx config to add dep for dev on parent builds

https://coveord.atlassian.net/browse/KIT-2525

* move search config to inside use memo

https://coveord.atlassian.net/browse/KIT-2525

* refactor to add search config and aq as options

https://coveord.atlassian.net/browse/KIT-2525

* post master merge refactor/fix

https://coveord.atlassian.net/browse/KIT-2525

* add help msg for instant results page

https://coveord.atlassian.net/browse/KIT-2525
  • Loading branch information
mrrajamanickam-coveo authored Aug 29, 2023
1 parent 3e74e77 commit d25ba44
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
3 changes: 3 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
"inputs": ["^production", "production"],
"dependsOn": ["^build"]
},
"dev": {
"dependsOn": ["^build"]
},
"prod": {
"dependsOn": ["build"]
},
Expand Down
16 changes: 14 additions & 2 deletions packages/samples/atomic-react/src/components/AtomicPageWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
getOrganizationEndpoints,
SearchEngineConfiguration,
getSampleSearchEngineConfiguration,
loadAdvancedSearchQueryActions,
} from '@coveo/atomic-react';
import React, {FunctionComponent, useMemo} from 'react';

Expand All @@ -46,11 +47,13 @@ type Sample = 'service' | 'electronics';
type Options = {
instantResults?: boolean;
recentQueries?: boolean;
advancedQuery?: string;
};

type Props = {
sample: Sample;
children: React.ReactNode;
options?: Options;
children: React.ReactNode;
};

function getElectronicsConfiguration(): SearchEngineConfiguration {
Expand All @@ -77,8 +80,8 @@ function getConfigurationForSample(sample: Sample) {

export const AtomicPageWrapper: FunctionComponent<Props> = ({
sample,
children,
options = {},
children,
}) => {
const engine = useMemo(
() =>
Expand All @@ -88,6 +91,15 @@ export const AtomicPageWrapper: FunctionComponent<Props> = ({
[sample]
);

if (options.advancedQuery) {
const action = loadAdvancedSearchQueryActions(
engine
).updateAdvancedSearchQueries({
aq: options.advancedQuery,
});
engine.dispatch(action);
}

return (
<AtomicSearchInterface
engine={engine}
Expand Down
11 changes: 9 additions & 2 deletions packages/samples/atomic-react/src/pages/FoldedResultListPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@ import {
FoldedResult,
AtomicResultSectionChildren,
AtomicFoldedResultList,
AtomicResultImage,
} from '@coveo/atomic-react';
import React, {FunctionComponent} from 'react';
import {AtomicPageWrapper} from '../components/AtomicPageWrapper';

export const FoldedResultListPage: FunctionComponent = () => {
return (
<AtomicPageWrapper sample="service">
<AtomicPageWrapper
sample="service"
options={{advancedQuery: '@source=iNaturalistTaxons'}}
>
<AtomicFoldedResultList imageSize="large" template={MyTemplate} />
</AtomicPageWrapper>
);
Expand Down Expand Up @@ -55,7 +59,10 @@ function MyTemplate(result: FoldedResult) {
)}
</AtomicResultSectionBadges>
<AtomicResultSectionVisual>
<img loading="lazy" src="https://picsum.photos/350" />
<AtomicResultImage
field="ec_images"
fallback="https://picsum.photos/350"
/>
</AtomicResultSectionVisual>
<AtomicResultSectionTitle>
<AtomicResultLink />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const InstantResultsPage: FunctionComponent = () => {
sample="electronics"
options={{recentQueries: true, instantResults: true}}
>
<p>No result list</p>
<i>👆 Focus on search box to see instant results</i>
</AtomicPageWrapper>
);
};

0 comments on commit d25ba44

Please sign in to comment.