Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locale as root path #198

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion apps/vtex-my-subscriptions-3/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"store": "0.x"
},
"mustUpdateAt": "2019-04-02",
"registries": ["smartcheckout"],
"registries": [
"smartcheckout"
],
"scripts": {
"postreleasy": "vtex publish --verbose"
},
Expand Down
2 changes: 1 addition & 1 deletion apps/vtex-my-subscriptions-3/messages/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"subscription.notFound.title": "Encara no teniu cap subscripció",
"subscription.notFound.text": "Afegiu els vostres productes preferits a la subscripció i trobeu-los sempre aquí",
"subscription.list.display": "Visualització",
"subscription.list.display.active_filter": "Actives",
"subscription.list.display.active_filter": "Active",
"subscription.list.display.canceled_filter": "Cancel·lades",
"subscription.list.button.seeDetails": "Mostra'n els detalls",
"subscription.list.button.reactivate": "Reactiva la subscripció",
Expand Down
2 changes: 1 addition & 1 deletion apps/vtex-my-subscriptions-3/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"subscription.notFound.title": "You don't have subscriptions yet",
"subscription.notFound.text": "Subscribe your favorite products and always find them here",
"subscription.list.display": "Display",
"subscription.list.display.active_filter": "Actives",
"subscription.list.display.active_filter": "Active",
"subscription.list.display.canceled_filter": "Canceled",
"subscription.list.button.seeDetails": "View details",
"subscription.list.button.reactivate": "Reactivate Subscription",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { graphql, MutationResult } from 'react-apollo'
import { ApolloError } from 'apollo-client'
import { withRouter, RouteComponentProps } from 'vtex.my-account-commons/Router'
import { SubscriptionStatus } from 'vtex.subscriptions-graphql'
import pathUrl from '../../utils/pathUrl'

import DETAILS_PAGE_QUERY, {
Subscription,
Expand Down Expand Up @@ -158,7 +159,7 @@ class SubscriptionsDetailsContainer extends Component<Props, State> {
}

return orderNow({ variables })
.then(() => (window.location.href = '/checkout/'))
.then(() => (window.location.href = `${pathUrl()}/checkout/`))
.catch((error: ApolloError) => {
logGraphQLError({
error,
Expand Down
14 changes: 14 additions & 0 deletions apps/vtex-my-subscriptions-3/react/utils/pathUrl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const pathUrl = () => {
let frontPart = ''
const { pathname } = window.location
const canonicalValues: string[] = ["af-ZA","sq-AL","ar-DZ","ar-BH","ar-EG","ar-IQ","ar-JO","ar-LB","ar-LY","ar-MA","ar-OM","ar-QA","ar-SA","ar-SY","ar-TN","ar-AE","ar-YE","hy-AM","az-AZ","eu-ES","be-BY","bn-IN","bs-BA","bg-BG","ca-ES","zh-CN","zh-HK","zh-MO","zh-SG","zh-TW","hr-HR","cs-CZ","da-DK","nl-BE","nl-NL","en-AU","en-BZ","en-CA","en-IE","en-JM","en-NZ","en-PH","en-ZA","en-TT","en-VI","en-GB","en-US","en-ZW","et-EE","fo-FO","fi-FI","fr-BE","fr-CA","fr-FR","fr-LU","fr-MC","fr-CH","gl-ES","ka-GE","de-AT","de-DE","de-LI","de-LU","de-CH","el-GR","gu-IN","he-IL","hi-IN","hu-HU","is-IS","id-ID","it-IT","it-CH","ja-JP","kn-IN","kk-KZ","kok-IN","ko-KR","lv-LV","lt-LT","mk-MK","ms-BN","ms-MY","ml-IN","mt-MT","mr-IN","mn-MN","se-NO","nb-NO","nn-NO","fa-IR","pl-PL","pt-BR","pt-PT","pa-IN","ro-RO","ru-RU","sr-BA","sr-CS","sk-SK","sl-SI","es-AR","es-BO","es-CL","es-CO","es-CR","es-DO","es-EC","es-SV","es-GT","es-HN","es-MX","es-NI","es-PA","es-PY","es-PE","es-PR","es-ES","es-UY","es-VE","sw-KE","sv-FI","sv-SE","ta-IN","te-IN","th-TH","tn-ZA","tr-TR","uk-UA","uz-UZ","vi-VN","cy-GB","xh-ZA"]
for (let i = 0; i < canonicalValues.length; i++) {
if (pathname?.includes(`/${canonicalValues[i]}`.toLowerCase())) {
frontPart = `/${canonicalValues[i].toLowerCase()}`
}
}
return frontPart

}

export default pathUrl