Skip to content

Commit

Permalink
Fix matcher logic when referrer is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
WRadoslaw committed Aug 1, 2023
1 parent 43efd50 commit fd54591
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,19 @@ export const YppAuthorizationDetailsFormStep: FC = () => {
notFoundLabel="Channel with this title not found, please check spelling and try again."
documentQuery={GetExtendedBasicChannelsDocument}
queryVariablesFactory={queryVariablesFactory}
perfectMatcher={(res, val) =>
res.extendedChannels.find((extendedChannel) => extendedChannel.channel.title === val)
}
perfectMatcher={(res, val) => {
const initialResults = res.extendedChannels.filter(
(extendedChannel) => extendedChannel.channel.title === val
)
if (initialResults.length === 1 || !referrerId) {
return initialResults[0]
}

return (
initialResults.find((extendedChannel) => extendedChannel.channel.id === referrerId) ??
initialResults[0]
)
}}
renderItem={(result) =>
result.extendedChannels.map((extendedChannel) => ({
...extendedChannel,
Expand Down

0 comments on commit fd54591

Please sign in to comment.