@thoughtindustries/catalog
Advanced tools
Comparing version 1.2.0-beta.1 to 1.2.0-beta.3
{ | ||
"name": "@thoughtindustries/catalog", | ||
"version": "1.2.0-beta.1", | ||
"version": "1.2.0-beta.3", | ||
"description": "A base component for catalog", | ||
@@ -26,3 +26,3 @@ "author": "Lu Jiang <lu.jiang@thoughtindustries.com>", | ||
"@apollo/client": "^3.7.0", | ||
"@thoughtindustries/content": "^1.2.0-beta.1", | ||
"@thoughtindustries/content": "^1.2.0-beta.3", | ||
"@thoughtindustries/header": "^1.1.0-beta.1", | ||
@@ -44,3 +44,3 @@ "@thoughtindustries/hooks": "^1.2.0-beta.1", | ||
}, | ||
"gitHead": "2a2644545158ae03285f6541c9b12dc6af8bc365" | ||
"gitHead": "ca817b6146146ebebc05e2f6f27c0fc6ee04e10c" | ||
} |
@@ -28,4 +28,2 @@ # `@thoughtindustries/catalog` | ||
}, | ||
layoutId: 'layout-id', | ||
widgetId: 'widget-id' | ||
} | ||
@@ -39,3 +37,3 @@ | ||
<CatalogProvider config={config}> | ||
<Catalog | ||
<Catalog | ||
onAddedToQueue={(item) => Promise.resolve()} | ||
@@ -54,3 +52,3 @@ pagination={({page, pageSize, total, getPageLink}) => <>...</>} /> | ||
<CatalogProvider config={config}> | ||
<Catalog | ||
<Catalog | ||
onAddedToQueue={(item) => Promise.resolve()} | ||
@@ -57,0 +55,0 @@ priceFormat={priceFormat} /> |
@@ -11,4 +11,2 @@ import { CatalogParams } from '../../utilities/parse-catalog-data'; | ||
export type CatalogProviderConfig = { | ||
layoutId?: string; | ||
widgetId?: string; | ||
parsedUrl: CatalogParsedURL; | ||
@@ -15,0 +13,0 @@ }; |
import { CatalogContentQueryVariables } from '@thoughtindustries/content'; | ||
import { DEFAULT_PAGE } from './constants'; | ||
import parseAggregationFilters from './parse-aggregation-filters'; | ||
import serializeSort from './serialize-sort'; | ||
import { CatalogParams } from './types'; | ||
@@ -18,3 +17,4 @@ | ||
} = params; | ||
const sortParam = sort && serializeSort(sort); | ||
const sortColumn = sort?.field; | ||
const sortDirection = sort?.direction; | ||
const displayTypeParam = displayType || resultsDisplayType; | ||
@@ -24,3 +24,4 @@ const transformedFilters = parseAggregationFilters(aggregationFilters); | ||
page, | ||
sort: sortParam, | ||
sortColumn, | ||
sortDirection, | ||
resultsDisplayType: displayTypeParam, | ||
@@ -27,0 +28,0 @@ token, |
import { GlobalTypes, CatalogContentQuery } from '@thoughtindustries/content'; | ||
import { CatalogParams, Sort, SortDirection, SortField } from './types'; | ||
import { SortColumn, SortDirection } from '@thoughtindustries/content/src/graphql/global-types'; | ||
import { CatalogParams, Sort } from './types'; | ||
@@ -19,20 +20,32 @@ const toEnabledSorts = ({ | ||
}): Sort[] => { | ||
const sorts = []; | ||
const sorts: Sort[] = []; | ||
if (sortUpdatedAtEnabled) { | ||
sorts.push({ field: SortField.UpdatedAt, direction: SortDirection.Desc }); | ||
sorts.push({ | ||
field: SortColumn.UpdatedAt, | ||
direction: SortDirection.Desc | ||
}); | ||
} | ||
if (sortCreatedAtEnabled) { | ||
sorts.push({ field: SortField.CreatedAt, direction: SortDirection.Desc }); | ||
sorts.push({ | ||
field: SortColumn.CreatedAt, | ||
direction: SortDirection.Desc | ||
}); | ||
} | ||
if (sortTitleEnabled) { | ||
sorts.push({ field: SortField.Title, direction: SortDirection.Asc }); | ||
sorts.push({ field: SortColumn.Title, direction: SortDirection.Asc }); | ||
} | ||
if (sortPublishDateEnabled) { | ||
sorts.push({ field: SortField.PublishedDate, direction: SortDirection.Desc }); | ||
sorts.push({ | ||
field: SortColumn.PublishDate, | ||
direction: SortDirection.Desc | ||
}); | ||
} | ||
if (sortCourseStartDateEnabled) { | ||
sorts.push({ field: SortField.CourseStartDate, direction: SortDirection.Asc }); | ||
sorts.push({ | ||
field: SortColumn.CourseStartDate, | ||
direction: SortDirection.Asc | ||
}); | ||
} | ||
if (sortRelevanceEnabled) { | ||
sorts.push({ field: SortField.Relevance }); | ||
sorts.push({ field: SortColumn.Relevance }); | ||
} | ||
@@ -39,0 +52,0 @@ return sorts; |
@@ -1,4 +0,4 @@ | ||
import { SortDirection } from '../..'; | ||
import { SortDirection, SortField } from '../..'; | ||
import { SORT_DELIMITER } from './constants'; | ||
import { Sort, SortField } from './types'; | ||
import { Sort } from './types'; | ||
@@ -5,0 +5,0 @@ const parseSort = (sort: string): Sort | undefined => { |
@@ -8,15 +8,11 @@ import { GlobalTypes } from '@thoughtindustries/content'; | ||
export enum SortField { | ||
UpdatedAt = 'updatedAt', | ||
CreatedAt = 'createdAt', | ||
Title = 'title', | ||
PublishedDate = 'publishDate', | ||
CourseStartDate = 'courseStartDate', | ||
Relevance = 'relevance' | ||
} | ||
export type SortField = | ||
| GlobalTypes.SortColumn.UpdatedAt | ||
| GlobalTypes.SortColumn.CreatedAt | ||
| GlobalTypes.SortColumn.Title | ||
| GlobalTypes.SortColumn.PublishDate | ||
| GlobalTypes.SortColumn.CourseStartDate | ||
| GlobalTypes.SortColumn.Relevance; | ||
export enum SortDirection { | ||
Desc = 'desc', | ||
Asc = 'asc' | ||
} | ||
export type SortDirection = GlobalTypes.SortDirection.Desc | GlobalTypes.SortDirection.Asc; | ||
@@ -23,0 +19,0 @@ export type Sort = { |
import { SortField } from '../../core'; | ||
import { GlobalTypes } from '@thoughtindustries/content'; | ||
export const localizedSortMapping: { [key in SortField]: string } = { | ||
[SortField.UpdatedAt]: 'catalog.sort-updated', | ||
[SortField.CreatedAt]: 'catalog.sort-created', | ||
[SortField.Title]: 'catalog.sort-title', | ||
[SortField.PublishedDate]: 'catalog.sort-publish-date', | ||
[SortField.CourseStartDate]: 'catalog.sort-course-start-date', | ||
[SortField.Relevance]: 'catalog.sort-relevance' | ||
[GlobalTypes.SortColumn.UpdatedAt]: 'catalog.sort-updated', | ||
[GlobalTypes.SortColumn.CreatedAt]: 'catalog.sort-created', | ||
[GlobalTypes.SortColumn.Title]: 'catalog.sort-title', | ||
[GlobalTypes.SortColumn.PublishDate]: 'catalog.sort-publish-date', | ||
[GlobalTypes.SortColumn.CourseStartDate]: 'catalog.sort-course-start-date', | ||
[GlobalTypes.SortColumn.Relevance]: 'catalog.sort-relevance' | ||
}; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
107457
3012
55