Skip to content

Commit a7d6383

Browse files
authored
Merge pull request #746 from reactioncommerce/fix-742-akarshit-empty-cart
Don't get shop to pre-render page
2 parents 03ee174 + b64722e commit a7d6383

File tree

4 files changed

+5
-18
lines changed

4 files changed

+5
-18
lines changed

pages/[lang]/cart.js

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import Router from "translations/i18nRouter";
1616
import PageLoading from "components/PageLoading";
1717
import { withApollo } from "lib/apollo/withApollo";
1818

19-
import { locales } from "translations/config";
2019
import fetchPrimaryShop from "staticUtils/shop/fetchPrimaryShop";
2120
import fetchTranslations from "staticUtils/translations/fetchTranslations";
2221

@@ -177,12 +176,12 @@ class CartPage extends Component {
177176
}
178177

179178
/**
180-
* Static props for the cart route
179+
* Server props for the cart route
181180
*
182181
* @param {String} lang - the shop's language
183182
* @returns {Object} props
184183
*/
185-
export async function getStaticProps({ params: { lang } }) {
184+
export async function getServerSideProps({ params: { lang } }) {
186185
return {
187186
props: {
188187
...await fetchPrimaryShop(lang),
@@ -191,16 +190,4 @@ export async function getStaticProps({ params: { lang } }) {
191190
};
192191
}
193192

194-
/**
195-
* Static paths for the cart route
196-
*
197-
* @returns {Object} paths
198-
*/
199-
export async function getStaticPaths() {
200-
return {
201-
paths: locales.map((locale) => ({ params: { lang: locale } })),
202-
fallback: false
203-
};
204-
}
205-
206193
export default withApollo()(withStyles(styles)(withCart(inject("uiStore")(CartPage))));

pages/[lang]/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export async function getStaticProps({ params: { lang } }) {
9898
const primaryShop = await fetchPrimaryShop(lang);
9999
const translations = await fetchTranslations(lang, ["common"]);
100100

101-
if (!primaryShop) {
101+
if (!primaryShop?.shop) {
102102
return {
103103
props: {
104104
shop: null,

pages/[lang]/product/[...slugOrId].js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export async function getStaticProps({ params: { slugOrId, lang } }) {
134134
const productSlug = slugOrId && slugOrId[0];
135135
const primaryShop = await fetchPrimaryShop(lang);
136136

137-
if (!primaryShop) {
137+
if (!primaryShop?.shop) {
138138
return {
139139
props: {
140140
shop: null,

pages/[lang]/tag/[slug].js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class TagGridPage extends Component {
161161
export async function getStaticProps({ params: { lang, slug } }) {
162162
const primaryShop = await fetchPrimaryShop(lang);
163163

164-
if (!primaryShop) {
164+
if (!primaryShop?.shop) {
165165
return {
166166
props: {
167167
shop: null,

0 commit comments

Comments
 (0)