-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
156 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module.exports = { | ||
description: 'added add to cart error/success handling', | ||
link: 'https://github.com/vuestorefront/vue-storefront/issues/5378', | ||
isBreaking: false, | ||
breakingChanges: [], | ||
author: 'Łukasz Jędrasik', | ||
linkToGitHubAccount: 'https://github.com/lukaszjedrasik' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
packages/core/nuxt-theme-module/theme/assets/notifications/cart.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { useUiNotification } from '../../composables'; | ||
|
||
export const cart = ({ i18n, router }) => { | ||
const addItem = ({ productName, error }) => { | ||
const { send } = useUiNotification(); | ||
|
||
if (error) { | ||
send({ | ||
type: 'danger', | ||
message: error | ||
}); | ||
} else { | ||
send({ | ||
type: 'success', | ||
message: productName ? i18n.t('Successfully added {PRODUCT_NAME} to the cart', { PRODUCT_NAME: productName }) : i18n.t('Successfully added product to the cart'), | ||
persist: true, | ||
action: { | ||
text: i18n.t('Go to Checkout'), | ||
onClick: () => router.push('/checkout/shipping') | ||
} | ||
}); | ||
} | ||
}; | ||
|
||
return { | ||
addItem | ||
}; | ||
}; |
13 changes: 13 additions & 0 deletions
13
packages/core/nuxt-theme-module/theme/assets/notifications/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { cart } from './cart'; | ||
import { useContext } from '@nuxtjs/composition-api'; | ||
|
||
const sendNotification = () => { | ||
const { app } = useContext(); | ||
const { i18n, router } = app; | ||
|
||
return { | ||
cart: cart({ i18n, router }) | ||
}; | ||
}; | ||
|
||
export default sendNotification; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters