Skip to content

Commit

Permalink
Merge pull request #319 from kiva/payment-error-message
Browse files Browse the repository at this point in the history
feat(KvPaymentSelect): emit error instead of using broken local toast
  • Loading branch information
emuvente authored Nov 21, 2023
2 parents d6d10fe + df13434 commit 6376b4b
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions @kiva/kv-shop/src/components/KvPaymentSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
v-if="updatingPaymentWrapper"
class="tw-mb-2"
/>
<kv-toast :ref="errorToast" />
</div>
</template>

Expand All @@ -18,15 +17,13 @@ import {
defineComponent, onMounted, ref, toRefs, watch,
} from 'vue-demi';
import KvLoadingSpinner from '@kiva/kv-components/vue/KvLoadingSpinner.vue';
import KvToast from '@kiva/kv-components/vue/KvToast.vue';
import type { PropType } from 'vue-demi';
import useBraintreeDropIn, { defaultPaymentTypes } from '../useBraintreeDropIn';
import type { PayPalFlowType, PaymentType } from '../useBraintreeDropIn';
export default defineComponent({
components: {
KvLoadingSpinner,
KvToast,
},
props: {
amount: {
Expand Down Expand Up @@ -82,7 +79,7 @@ export default defineComponent({
default: true,
},
},
emits: ['transactions-enabled'],
emits: ['transactions-enabled', 'error'],
setup(props, { emit }) {
const {
amount,
Expand All @@ -101,11 +98,6 @@ export default defineComponent({
updateAmount,
} = useBraintreeDropIn(props.dropInName);
const errorToast = ref();
const showError = (message: string) => {
errorToast.value?.show(message, 'error', true);
};
watch(amount, (newValue) => {
updateAmount(newValue);
});
Expand All @@ -130,9 +122,9 @@ export default defineComponent({
});
} catch (e) {
if (e instanceof Error) {
showError(e?.message);
emit('error', e?.message);
} else {
showError('An Error has occured. Please refresh the page and try again.');
emit('error', 'An error has occured. Please refresh the page and try again.');
}
} finally {
updatingPaymentWrapper.value = false;
Expand Down

0 comments on commit 6376b4b

Please sign in to comment.