import { useUserStore } from './user'
import { useCartStore } from './cart'
-import { pinia, CombinedState } from '../../../src/pinia'
+import { pinia } from '../../../src'
// in this file we could import other stores that use one each other while
// avoiding any recursive import
-type S = CombinedState<{
- user: typeof useUserStore
- cart: typeof useCartStore
-}>
+// TODO: not implemented
-let a: S
+const useCartUserStore = pinia(
+ { user: useUserStore, cart: useCartStore },
+ {
+ getters: {
+ combinedGetter: ({ user, cart }) =>
+ `Hi ${user.state.name}, you have ${cart.state.list.length} items in your cart. It costs ${cart.price}.`,
+ },
+ actions: {
+ async orderCart() {
+ try {
+ await apiOrderCart(this.user.state.token, this.cart.state.items)
+ this.cart.emptyCart()
+ } catch (err) {
+ displayError(err)
+ }
+ },
+ },
+ }
+)
+
+const a = useCartUserStore()
a.user.isAdmin = false
a.cart.rawItems.push()
if (serverPrefetch) {
const patchedServerPrefetch = Array.isArray(serverPrefetch)
? serverPrefetch.slice()
- : // serverPrefetch not being an array cannot be triggered due tue options merge
+ : // serverPrefetch not being an array cannot be triggered due to options merge
// https://github.com/vuejs/vue/blob/7912f75c5eb09e0aef3e4bfd8a3bb78cad7540d7/src/core/util/options.js#L149
/* istanbul ignore next */
[serverPrefetch]