Skip to content

Commit

Permalink
fix(default-theme): prevent redirecting to profile page on SSR
Browse files Browse the repository at this point in the history
  • Loading branch information
mkucmus committed Jul 18, 2022
1 parent 78821a7 commit c582f32
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions packages/default-theme/src/pages/account.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@
</template>

<script>
import { computed } from "@vue/composition-api"
import { computed, ref } from "@vue/composition-api"
import { SfContentPages } from "@storefront-ui/vue"
import {
useUser,
useBreadcrumbs,
getApplicationContext,
} from "@shopware-pwa/composables"
import { PAGE_ACCOUNT, PAGE_LOGIN } from "@/helpers/pages"
import authMiddleware from "@/middleware/auth"
Expand All @@ -44,21 +45,32 @@ export default {
middleware: authMiddleware,
setup(props, { root }) {
const { route } = getApplicationContext({
contextName: "account-page",
})
const { logout, user } = useUser()
const { setBreadcrumbs } = useBreadcrumbs()
const ordersCount = computed(() => user.value && user.value.orderCount)
const subPageMap = {
"account-profile": root.$t("My profile"),
"account-addresses": root.$t("My addresses"),
"account-addresses-add-id": root.$t("My addresses"),
"account-orders": root.$tc("Order history", ordersCount.value),
}
const activePage = ref(subPageMap[route?.name])
setBreadcrumbs([
{
name: root.$t("My Account"),
path: PAGE_ACCOUNT,
},
])
const ordersCount = computed(() => user.value && user.value.orderCount)
return { logout, user, ordersCount }
return { logout, user, ordersCount, activePage }
},
data() {
return {
activePage: this.$t("My profile"),
allAddresses: [],
}
},
Expand All @@ -80,10 +92,6 @@ export default {
},
},
mounted() {
this.updateActivePage(this.activePage)
},
methods: {
async updateActivePage(title) {
switch (title) {
Expand Down

0 comments on commit c582f32

Please sign in to comment.