Skip to content

Commit

Permalink
Merge pull request #13 from vtex-apps/fix/remove-old-routing
Browse files Browse the repository at this point in the history
Removes old routing
  • Loading branch information
vwraposo authored Oct 15, 2019
2 parents f4a5dea + 227a280 commit 91c50f6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 17 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Refactor
- removes old routing

## [0.6.2] - 2019-10-15
### Fixed
Expand Down
11 changes: 1 addition & 10 deletions node/resolvers/catalog/category.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ function cleanUrl(url: string) {
return url.replace(/https:\/\/[A-z0-9]+\.vtexcommercestable\.com\.br/, '')
}

export const pathToCategoryHref = (path: string) => {
const isDepartment = path.slice(1).indexOf('/') === -1
return isDepartment ? `${path}/d` : path
}

/** This type has to be created because the Catlog API to get category by ID does not return the url or children for now.
* These fields only come if you get the category from the categroy tree api.
*/
Expand All @@ -27,11 +22,7 @@ export const resolvers = {
cacheId: prop('id'),

href: async ({ url }: SafeCategory, _: any) => {
const path = cleanUrl(url)

// If the path is `/clothing`, we know that's a department
// But if it is `/clothing/shirts`, it's not.
return pathToCategoryHref(path)
return cleanUrl(url)
},

metaTagDescription: prop('MetaTagDescription'),
Expand Down
3 changes: 1 addition & 2 deletions node/resolvers/catalog/facets.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { prop, toPairs } from 'ramda'

import { pathToCategoryHref } from './category'
import { zipQueryAndMap } from './utils'

interface EitherFacet extends CatalogFacet {
Expand Down Expand Up @@ -92,7 +91,7 @@ export const resolvers = {

href: ({ Link }: { Link: string }) => {
const [linkPath] = Link.split('?')
return pathToCategoryHref(linkPath)
return linkPath
},

name: prop('Name'),
Expand Down
7 changes: 2 additions & 5 deletions node/resolvers/catalog/searchBreadcrumb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,8 @@ export const resolvers = {
mapUnit,
queryUnit,
}: BreadcrumbParams) => {
if (index === 0 && isCategoryMap(mapUnit)) {
return `/${queryUnit}/d`
}
if (index === 0 && isBrandMap(mapUnit)) {
return `/${queryUnit}/b`
if (index === 0 && (isCategoryMap(mapUnit) || isBrandMap(mapUnit))) {
return `/${queryUnit}`
}
if (mapArray.every(isCategoryMap)) {
return `/${sliceAndJoin(queryArray, index + 1, '/')}`
Expand Down

0 comments on commit 91c50f6

Please sign in to comment.