Skip to content

Commit

Permalink
Merge pull request #721 from amansinghbais/#716
Browse files Browse the repository at this point in the history
Implemented: added support for gift card activation (#716)
  • Loading branch information
ravilodhi authored Sep 2, 2024
2 parents da0f0ac + 9dace4e commit 2200c32
Show file tree
Hide file tree
Showing 10 changed files with 502 additions and 3 deletions.
184 changes: 184 additions & 0 deletions src/components/GiftCardActivationModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
<template>
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-button @click="closeModal()">
<ion-icon slot="icon-only" :icon="closeOutline" />
</ion-button>
</ion-buttons>
<ion-title>{{ translate("Gift card activation") }}</ion-title>
</ion-toolbar>
</ion-header>

<ion-content>
<div v-if="isLoading" class="empty-state">
<ion-spinner name="crescent" />
<ion-label>{{ translate("Fetching gift card info.") }}</ion-label>
</div>
<ion-list v-else>
<ion-item lines="none" v-if="!item.isGCActivated">
<ion-input :label="translate('Activation code')" :placeholder="translate('serial number')" :helper-text="translate('Scan or enter the unique code on the gift card')" v-model="activationCode" />
</ion-item>

<ion-item v-else>
<ion-icon :icon="cardOutline" slot="start" />
<ion-label>{{ item.gcInfo.cardNumber }}</ion-label>
<ion-note slot="end">{{ getCreatedDateTime() }}</ion-note>
</ion-item>

<ion-item lines="none">
<ion-icon :icon="giftOutline" slot="start" />
<ion-label>
{{ getProductIdentificationValue(productIdentificationPref.primaryId, getProduct(item.productId)) ? getProductIdentificationValue(productIdentificationPref.primaryId, getProduct(item.productId)) : item.productName }}
<p>{{ getProductIdentificationValue(productIdentificationPref.secondaryId, getProduct(item.productId)) }}</p>
</ion-label>
<ion-label slot="end">{{ formatCurrency(itemPriceInfo.unitPrice, itemPriceInfo.currencyUom) }}</ion-label>
</ion-item>
</ion-list>
</ion-content>

<ion-fab v-if="!item.isGCActivated" vertical="bottom" horizontal="end" slot="fixed">
<ion-fab-button @click="confirmSave()">
<ion-icon :icon="cardOutline" />
</ion-fab-button>
</ion-fab>
</template>

<script lang="ts">
import {
IonButton,
IonButtons,
IonContent,
IonFab,
IonFabButton,
IonHeader,
IonIcon,
IonInput,
IonItem,
IonLabel,
IonList,
IonNote,
IonSpinner,
IonTitle,
IonToolbar,
alertController,
modalController
} from "@ionic/vue";
import { computed, defineComponent } from "vue";
import { mapGetters, useStore } from "vuex";
import { cardOutline, closeOutline, giftOutline, saveOutline } from "ionicons/icons";
import { getProductIdentificationValue, translate, useProductIdentificationStore } from '@hotwax/dxp-components'
import { UtilService } from "@/services/UtilService";
import { formatCurrency, formatUtcDate, hasError, showToast } from '@/utils';
import logger from "@/logger";
import { DateTime } from 'luxon';
export default defineComponent({
name: "GiftCardActivationModal",
components: {
IonButton,
IonButtons,
IonContent,
IonFab,
IonFabButton,
IonHeader,
IonIcon,
IonInput,
IonItem,
IonLabel,
IonList,
IonNote,
IonSpinner,
IonTitle,
IonToolbar
},
computed: {
...mapGetters({
getProduct: 'product/getProduct',
}),
},
data() {
return {
isLoading: false,
itemPriceInfo: {} as any,
activationCode: ""
}
},
props: ["item"],
async mounted() {
this.isLoading = true;
this.itemPriceInfo = await UtilService.fetchGiftCardItemPriceInfo({ orderId: this.item.orderId, orderItemSeqId: this.item.orderItemSeqId })
this.isLoading = false;
},
methods: {
closeModal(payload = {}) {
modalController.dismiss({ dismissed: true, ...payload })
},
async confirmSave() {
if(!this.activationCode.trim()) {
showToast(translate("Please enter a activation code."))
return;
}
const alert = await alertController.create({
header: translate("Activate gift card"),
message: translate("This gift card code will be activated. The customer may also receive a notification about this activation. Please verify all information is entered correctly. This cannot be edited after activation.", { space: "<br /><br />" }),
buttons: [
{
text: translate("Cancel"),
},
{
text: translate("Activate"),
handler: async () => {
await this.activateGitCard()
}
}
],
});
return alert.present();
},
async activateGitCard() {
try {
const resp = await UtilService.activateGiftCard({
orderId: this.item.orderId,
orderItemSeqId: this.item.orderItemSeqId,
amount: this.itemPriceInfo.unitPrice,
typeEnumId: "GC_ACTIVATE",
cardNumber: this.activationCode.trim()
})
if(!hasError(resp)) {
showToast(translate("Gift card activated successfully."))
this.closeModal({ isGCActivated: true, item: this.item })
} else {
throw resp.data;
}
} catch(error: any) {
showToast(translate("Failed to activate gift card."))
logger.error(error);
}
},
getCreatedDateTime() {
return DateTime.fromMillis(this.item.gcInfo.fulfillmentDate).toFormat("dd MMMM yyyy t a ZZZZ");
}
},
setup() {
const store = useStore()
const productIdentificationStore = useProductIdentificationStore();
let productIdentificationPref = computed(() => productIdentificationStore.getProductIdentificationPref)
return {
cardOutline,
closeOutline,
formatCurrency,
formatUtcDate,
getProductIdentificationValue,
giftOutline,
productIdentificationPref,
saveOutline,
store,
translate
};
},
});
</script>
12 changes: 12 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"Activate": "Activate",
"Activate gift card": "Activate gift card",
"Activation code": "Activation code",
"Add": "Add",
"All": "All",
"App": "App",
Expand Down Expand Up @@ -165,6 +168,7 @@
"Facility ID": "Facility ID",
"Facility updated successfully": "Facility updated successfully",
"Facilities": "Facilities",
"Failed to activate gift card.": "Failed to activate gift card.",
"Failed to add box": "Failed to add box",
"Failed to create picklist for orders": "Failed to create picklist for orders",
"Failed to create rejection reason.": "Failed to create rejection reason.",
Expand Down Expand Up @@ -197,6 +201,7 @@
"Failed to update shipment method detail.": "Failed to update shipment method detail.",
"Failed to update tracking code settings.": "Failed to update tracking code settings.",
"Failed to update variance type.": "Failed to update variance type.",
"Fetching gift card info.": "Fetching gift card info.",
"Fetching time zones": "Fetching time zones",
"Fetching order information...": "Fetching order information...",
"Fetching pickers": "Fetching pickers",
Expand All @@ -218,6 +223,9 @@
"Generate packing slip": "Generate packing slip",
"Generate QR code": "Generate QR code",
"Generate shipping label": "Generate shipping label",
"Gift card": "Gift card",
"Gift card activated successfully.": "Gift card activated successfully.",
"Gift card activation": "Gift card activation",
"Go to OMS": "Go to OMS",
"Go to Launchpad": "Go to Launchpad",
"Ground": "Ground",
Expand Down Expand Up @@ -372,6 +380,7 @@
"Picklist Size": "Picklist Size",
"Pick All": "Pick All",
"pieces in stock": "pieces in stock",
"Please enter a activation code.": "Please enter a activation code.",
"Please enter a unique key": "Please enter a unique key",
"Please enter a valid key": "Please enter a valid key",
"Please provide a value": "Please provide a value",
Expand Down Expand Up @@ -440,6 +449,7 @@
"Scan barcodes to receive them": "Scan barcodes to receive them",
"Scan items": "Scan items",
"Scan order items": "Scan order items",
"Scan or enter the unique code on the gift card": "Scan or enter the unique code on the gift card",
"Scanned item is not present within the shipment:": "Scanned item is not present within the shipment: {itemName}",
"Search": "Search",
"Search orders": "Search orders",
Expand All @@ -465,6 +475,7 @@
"Sequence for rejection reasons updated successfully.": "Sequence for rejection reasons updated successfully.",
"Sequence for shipment methods updated successfully.": "Sequence for shipment methods updated successfully.",
"Sequence methods": "Sequence methods",
"serial number": "serial number",
"Settled": "Settled",
"Setting fulfillment capacity to 0 disables new order from being allocated to this facility. Leave this empty if this facility's fulfillment capacity is unrestricted.": "Setting fulfillment capacity to 0 disables new order from being allocated to this facility. Leave this empty if this facility's fulfillment capacity is unrestricted.",
"Settings": "Settings",
Expand Down Expand Up @@ -535,6 +546,7 @@
"There are no saved CSV mappings to show. Create a new mapping from a file upload screen": "There are no saved CSV mappings to show. Create a new mapping from a file upload screen",
"This CSV mapping has been deleted.": "This CSV mapping has been deleted.",
"This CSV mapping has been saved.": "This CSV mapping has been saved.",
"This gift card code will be activated. The customer may also receive a notification about this activation. Please verify all information is entered correctly. This cannot be edited after activation.": "This gift card code will be activated. The customer may also receive a notification about this activation. Please verify all information is entered correctly.{space} This cannot be edited after activation.",
"This is the name of the OMS you are connected to right now. Make sure that you are connected to the right instance before proceeding.": "This is the name of the OMS you are connected to right now. Make sure that you are connected to the right instance before proceeding.",
"Timeline": "Timeline",
"Timezone": "Timezone",
Expand Down
12 changes: 12 additions & 0 deletions src/locales/es.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"Activate": "Activate",
"Activate gift card": "Activate gift card",
"Activation code": "Activation code",
"Add": "Add",
"All": "Todo",
"App": "Aplicación",
Expand Down Expand Up @@ -163,6 +166,7 @@
"Facility ID": "ID de la instalación",
"Facility updated successfully": "Instalación actualizada exitosamente",
"Facilities": "Facilities",
"Failed to activate gift card.": "Failed to activate gift card.",
"Failed to add box": "Error al agregar la caja",
"Failed to create picklist for orders": "Error al crear la lista de selección para los pedidos",
"Failed to create rejection reason.": "Failed to create rejection reason.",
Expand Down Expand Up @@ -194,6 +198,7 @@
"Failed to update shipment method detail.": "Failed to update shipment method detail.",
"Failed to update tracking code settings.": "Failed to update tracking code settings.",
"Failed to update variance type.": "Failed to update variance type.",
"Fetching gift card info.": "Fetching gift card info.",
"Fetching order information...": "Obteniendo información del pedido...",
"Fetching pickers": "Fetching pickers",
"Field mapping name": "Nombre del mapeo de campos",
Expand All @@ -214,6 +219,9 @@
"Generate packing slip": "Generar documento de embalaje",
"Generate QR code": "Generar código QR",
"Generate shipping label": "Generar etiqueta de envío",
"Gift card": "Gift card",
"Gift card activated successfully.": "Gift card activated successfully.",
"Gift card activation": "Gift card activation",
"Go to OMS": "Ir a OMS",
"Go to Launchpad": "Ir a Launchpad",
"Ground": "Suelo",
Expand Down Expand Up @@ -369,6 +377,7 @@
"Picklist Size": "Tamaño de la Lista de Selección",
"Pick All": "Escoger todo",
"pieces in stock": "cantidad en stock",
"Please enter a activation code.": "Please enter a activation code.",
"Please enter a unique key": "Por favor, introduce una clave única",
"Please enter a valid key": "Por favor, introduce una clave válida",
"Please provide a value": "Por favor, proporciona un valor",
Expand Down Expand Up @@ -438,6 +447,7 @@
"Scan barcodes to receive them": "Scan barcodes to receive them",
"Scan items": "Escanear artículos",
"Scan order items": "Scan order items",
"Scan or enter the unique code on the gift card": "Scan or enter the unique code on the gift card",
"Scanned item is not present within the shipment:": "Scanned item is not present within the shipment: {itemName}",
"Search": "Buscar",
"Search time zones": "Buscar zonas horarias",
Expand All @@ -462,6 +472,7 @@
"Sequence methods": "Sequence methods",
"Sequence for rejection reasons updated successfully.": "Sequence for rejection reasons updated successfully.",
"Sequence for shipment methods updated successfully.": "Sequence for shipment methods updated successfully.",
"serial number": "serial number",
"Settled": "Pagado",
"Setting fulfillment capacity to 0 disables new order from being allocated to this facility. Leave this empty if this facility's fulfillment capacity is unrestricted.": "Establecer la capacidad de cumplimiento en 0 inhabilita la asignación de nuevos pedidos a esta instalación. Déjelo vacío si la capacidad de cumplimiento de esta instalación no tiene restricciones.",
"Settings": "Configuraciones",
Expand Down Expand Up @@ -532,6 +543,7 @@
"There are no saved CSV mappings to show. Create a new mapping from a file upload screen": "No hay asignaciones CSV guardadas para mostrar. Crear una nueva asignación desde una pantalla de carga de archivos",
"This CSV mapping has been deleted.": "Esta asignación CSV ha sido eliminada.",
"This CSV mapping has been saved.": "Esta asignación CSV se ha guardado.",
"This gift card code will be activated. The customer may also receive a notification about this activation. Please verify all information is entered correctly. This cannot be edited after activation.": "This gift card code will be activated. The customer may also receive a notification about this activation. Please verify all information is entered correctly.{space} This cannot be edited after activation.",
"This is the name of the OMS you are connected to right now. Make sure that you are connected to the right instance before proceeding.": "Este es el nombre del OMS al que está conectado en este momento. Asegúrese de estar conectado a la instancia correcta antes de continuar.",
"Timeline": "Línea de tiempo",
"Timezone": "Zona horaria",
Expand Down
12 changes: 12 additions & 0 deletions src/locales/ja.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"Activate": "Activate",
"Activate gift card": "Activate gift card",
"Activation code": "Activation code",
"Add": "追加",
"All": "すべて",
"App": "アプリ",
Expand Down Expand Up @@ -165,6 +168,7 @@
"Facility ID": "施設ID",
"Facility updated successfully": "施設が正常に更新されました",
"Facilities": "施設",
"Failed to activate gift card.": "Failed to activate gift card.",
"Failed to add box": "ボックスの追加に失敗しました",
"Failed to create picklist for orders": "注文のピックリスト作成に失敗しました",
"Failed to create rejection reason.": "拒否理由の作成に失敗しました。",
Expand Down Expand Up @@ -197,6 +201,7 @@
"Failed to update shipment method detail.": "Failed to update shipment method detail.",
"Failed to update tracking code settings.": "追跡コード設定の更新に失敗しました。",
"Failed to update variance type.": "変動タイプの更新に失敗しました。",
"Fetching gift card info.": "Fetching gift card info.",
"Fetching time zones": "タイムゾーンの取得中",
"Fetching order information...": "注文情報の取得中...",
"Fetching pickers": "Fetching pickers",
Expand All @@ -214,6 +219,9 @@
"Fulfillment capacity": "フルフィルメント容量",
"Fulfillment Status": "フルフィルメントステータス",
"gateway": "ゲートウェイ",
"Gift card": "Gift card",
"Gift card activated successfully.": "Gift card activated successfully.",
"Gift card activation": "Gift card activation",
"Generate Label": "Generate Label",
"Generate packing slip": "梱包スリップを生成",
"Generate QR code": "QRコードを生成",
Expand Down Expand Up @@ -370,6 +378,7 @@
"Picklist Size": "ピックリストサイズ",
"Pick All": "すべて選択",
"pieces in stock": "在庫数",
"Please enter a activation code.": "Please enter a activation code.",
"Please enter a unique key": "一意のキーを入力してください",
"Please enter a valid key": "有効なキーを入力してください",
"Please provide a value": "値を入力してください",
Expand Down Expand Up @@ -437,6 +446,7 @@
"Scan barcodes to receive them": "バーコードをスキャンして受け取ります",
"Scan items": "アイテムをスキャン",
"Scan order items": "注文アイテムをスキャンする",
"Scan or enter the unique code on the gift card": "Scan or enter the unique code on the gift card",
"Scanned item is not present within the shipment:": "Scanned item is not present within the shipment: {itemName}",
"Search": "検索",
"Search orders": "注文を検索",
Expand All @@ -462,6 +472,7 @@
"Sequence for rejection reasons updated successfully.": "拒否理由の順序が正常に更新されました。",
"Sequence for shipment methods updated successfully.": "出荷方法の順序が正常に更新されました。",
"Sequence methods": "順序方法",
"serial number": "serial number",
"Settled": "確定済み",
"Setting fulfillment capacity to 0 disables new order from being allocated to this facility. Leave this empty if this facility's fulfillment capacity is unrestricted.": "フルフィルメント容量を0に設定すると、この施設に新しい注文が割り当てられるのを防ぎます。この施設のフルフィルメント容量が無制限の場合は、空白のままにしてください。",
"Settings": "設定",
Expand Down Expand Up @@ -532,6 +543,7 @@
"There are no saved CSV mappings to show. Create a new mapping from a file upload screen": "表示する保存されたCSVマッピングがありません。ファイルアップロード画面から新しいマッピングを作成してください",
"This CSV mapping has been deleted.": "このCSVマッピングは削除されました。",
"This CSV mapping has been saved.": "このCSVマッピングは保存されました。",
"This gift card code will be activated. The customer may also receive a notification about this activation. Please verify all information is entered correctly. This cannot be edited after activation.": "This gift card code will be activated. The customer may also receive a notification about this activation. Please verify all information is entered correctly.{space} This cannot be edited after activation.",
"This is the name of the OMS you are connected to right now. Make sure that you are connected to the right instance before proceeding.": "これは、現在接続しているOMSの名前です。続行する前に、正しいインスタンスに接続していることを確認してください。",
"Timeline": "タイムライン",
"Timezone": "タイムゾーン",
Expand Down
Loading

0 comments on commit 2200c32

Please sign in to comment.