Skip to content

Commit

Permalink
button enable issue fix (#1232)
Browse files Browse the repository at this point in the history
* button enable issue fix

* review changes

* reiview changes
  • Loading branch information
PiranavanShanmugavadivelu authored Apr 5, 2024
1 parent 02c3a58 commit 644bc55
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
9 changes: 6 additions & 3 deletions frontend/marketplace/src/components/BuyButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,21 @@ const handleModalType = (type: CertificateHolderModalTypeEnums) => {
const buttonHandler = computed<(() => void) | undefined>(() => {
switch (buttonState.value) {
case BuyButtonState.ENABLED_CARD:
handleModalType(CertificateHolderModalTypeEnums.AUTHORIZED_USER);
handleModalType(CertificateHolderModalTypeEnums.EMAIL_AUTHORIZED_USER);
tracking.trackEvent(TrackEvents.CLICKED_PAYMENT_BUTTON, {
status: "pay with card",
});
return addModalToHandler(props.handleCardPayment);
case BuyButtonState.ENABLED_WALLET:
handleModalType(
CertificateHolderModalTypeEnums.CRYPTO_WALLET_AUTHORIZED_USER,
);
tracking.trackEvent(TrackEvents.CLICKED_PAYMENT_BUTTON, {
status: "pay with crypto",
});
return addModalToHandler(props.handleBuyCredits);
case BuyButtonState.ENABLED_UNAUTHORIZED:
handleModalType(CertificateHolderModalTypeEnums.UNAUTHORIZED_USER);
handleModalType(CertificateHolderModalTypeEnums.GUEST_USER);
tracking.trackEvent(TrackEvents.CLICKED_PAYMENT_BUTTON, {
status: "unauthorized",
});
Expand All @@ -133,7 +136,7 @@ const isDisabled = computed(
const handleContinue = (name: string, email?: string) => {
if (
modalType.value === CertificateHolderModalTypeEnums.UNAUTHORIZED_USER &&
modalType.value === CertificateHolderModalTypeEnums.GUEST_USER &&
continueUnauthorizedPaymentHandler.value
) {
return continueUnauthorizedPaymentHandler.value(name, email || "");
Expand Down
21 changes: 11 additions & 10 deletions frontend/marketplace/src/components/CertificateHolderModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,17 @@ const isCertificateHolderEmailValid = computed<boolean>(() => {
});
const isButtonDisabled = () => {
if (
(props.modalType === CertificateHolderModalTypeEnums.UNAUTHORIZED_USER &&
isCertificateHolderValid.value &&
isCertificateHolderEmailValid.value) ||
(props.modalType === CertificateHolderModalTypeEnums.AUTHORIZED_USER &&
isCertificateHolderValid.value)
) {
return false;
if (!isCertificateHolderValid.value) {
return true;
}
return true;
return !(
props.modalType === CertificateHolderModalTypeEnums.EMAIL_AUTHORIZED_USER ||
props.modalType ===
CertificateHolderModalTypeEnums.CRYPTO_WALLET_AUTHORIZED_USER ||
(props.modalType === CertificateHolderModalTypeEnums.GUEST_USER &&
isCertificateHolderEmailValid.value)
);
};
const handleOpenModal = () => {
Expand Down Expand Up @@ -74,7 +75,7 @@ defineExpose({
>
</div>
<input
v-if="modalType === CertificateHolderModalTypeEnums.UNAUTHORIZED_USER"
v-if="modalType === CertificateHolderModalTypeEnums.GUEST_USER"
type="email"
placeholder="Certificate holder email"
class="input input-bordered w-full text-white bg-lightGray mt-5"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export enum CertificateHolderModalTypeEnums {
AUTHORIZED_USER = "AUTHORIZED_USER",
UNAUTHORIZED_USER = "UNAUTHORIZED_USER",
EMAIL_AUTHORIZED_USER = "EMAIL_AUTHORIZED_USER",
CRYPTO_WALLET_AUTHORIZED_USER = "CRYPTO_WALLET_AUTHORIZED_USER",
GUEST_USER = "GUEST_USER",
}

0 comments on commit 644bc55

Please sign in to comment.