diff --git a/src/components/abstractions/Combobox.tsx b/src/components/abstractions/Combobox.tsx index bcc6f009ce..262de02227 100644 --- a/src/components/abstractions/Combobox.tsx +++ b/src/components/abstractions/Combobox.tsx @@ -29,6 +29,7 @@ import { Text, } from "@ndla/primitives"; import { Flex, styled } from "@ndla/styled-system/jsx"; +import { ContentTypeBadge } from "@ndla/ui"; interface GenericComboboxItemIndicatorProps extends ComboboxItemIndicatorProps { ref?: Ref; @@ -109,6 +110,7 @@ interface GenericComboboxItemCustomProps { description?: string; fallbackImageElement?: ReactNode; useFallbackImage?: boolean; + contentType?: string; image?: { url?: string; alt?: string; @@ -122,6 +124,7 @@ export const GenericComboboxItemContent = ({ image, description, fallbackImageElement, + contentType, useFallbackImage, ...props }: GenericComboboxItemProps) => ( @@ -142,6 +145,7 @@ export const GenericComboboxItemContent = ({ )} + {contentType ? : undefined} diff --git a/src/containers/StructurePage/plannedResource/AddExistingResource.tsx b/src/containers/StructurePage/plannedResource/AddExistingResource.tsx index bd50714763..eb92d47100 100644 --- a/src/containers/StructurePage/plannedResource/AddExistingResource.tsx +++ b/src/containers/StructurePage/plannedResource/AddExistingResource.tsx @@ -27,6 +27,7 @@ import { IArticleV2DTO } from "@ndla/types-backend/article-api"; import { ILearningPathSummaryV2DTO, ILearningPathV2DTO } from "@ndla/types-backend/learningpath-api"; import { IApiTaxonomyContextDTO, IMultiSearchSummaryDTO } from "@ndla/types-backend/search-api"; import { ResourceType } from "@ndla/types-taxonomy"; +import { ContentTypeBadge } from "@ndla/ui"; import { GenericComboboxInput, GenericComboboxItemContent } from "../../../components/abstractions/Combobox"; import { GenericSearchCombobox } from "../../../components/Form/GenericSearchCombobox"; import { FormActionsContainer, FormContent } from "../../../components/FormikForm"; @@ -280,11 +281,11 @@ const AddExistingResource = ({ onClose, resourceTypes, existingResourceIds, node )} {!pastedUrl && ( setPreview(toPreview(details.items[0]))} items={searchQuery.data?.results ?? []} itemToString={(item) => item.title.title} - itemToValue={(item) => item.id.toString()} + itemToValue={(item) => `${item.learningResourceType}_${item.id.toString()}`} inputValue={query} onInputValueChange={(details) => setQuery(details.inputValue)} isSuccess={searchQuery.isSuccess} @@ -295,6 +296,7 @@ const AddExistingResource = ({ onClose, resourceTypes, existingResourceIds, node title={item.title.title} description={item.metaDescription.metaDescription} image={item.metaImage} + contentType={item.learningResourceType === "learningpath" ? item.learningResourceType : undefined} useFallbackImage /> )} @@ -316,6 +318,9 @@ const AddExistingResource = ({ onClose, resourceTypes, existingResourceIds, node {preview.title.title} {preview.metaDescription?.metaDescription} + {preview.learningResourceType === "learningpath" && ( + + )} ) )}