Skip to content

Commit

Permalink
fix: resolve linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
AbleKSaju committed Sep 28, 2024
1 parent 53cf61d commit dc7b4b0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 23 deletions.
28 changes: 9 additions & 19 deletions src/pages/POS/LoyaltyprogramModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
<Button
class="w-full bg-green-500"
style="padding: 1.35rem"
@click="setLoyaltyPoints()"
:disabled="validationError"
@click="setLoyaltyPoints()"
>
<slot>
<p class="uppercase text-lg text-white font-semibold">
Expand Down Expand Up @@ -67,9 +67,7 @@

<script lang="ts">
import Button from 'src/components/Button.vue';
import Currency from 'src/components/Controls/Currency.vue';
import Data from 'src/components/Controls/Data.vue';
import Date from 'src/components/Controls/Date.vue';
import Modal from 'src/components/Modal.vue';
import { SalesInvoice } from 'models/baseModels/SalesInvoice/SalesInvoice';
import { defineComponent, inject } from 'vue';
Expand All @@ -81,17 +79,10 @@ export default defineComponent({
name: 'LoyaltyProgramModal',
components: {
Modal,
Currency,
Button,
Data,
Date,
},
emits: ['setLoyaltyPoints', 'toggleModal'],
props: {
sinvDoc: {
type: Object,
required: true,
},
loyaltyPoints: {
type: Number,
required: true,
Expand All @@ -101,14 +92,15 @@ export default defineComponent({
required: true,
},
},
data() {
emits: ['setLoyaltyPoints', 'toggleModal'],
setup() {
return {
validationError: false,
sinvDoc: inject('sinvDoc') as SalesInvoice,
};
},
setup() {
data() {
return {
sinvDoc: inject('sinvDoc') as SalesInvoice,
validationError: false,
};
},
methods: {
Expand All @@ -119,7 +111,7 @@ export default defineComponent({
} else {
throw new Error(
`${this.sinvDoc.party as string} only has ${
this.loyaltyPoints as number
this.loyaltyPoints
} points`
);
}
Expand All @@ -128,17 +120,15 @@ export default defineComponent({
ModelNameEnum.LoyaltyProgram,
{
fields: ['conversionFactor'],
filters: { name: this.loyaltyProgram as string },
filters: { name: this.loyaltyProgram },
}
);
const loyaltyPoint =
newValue * ((loyaltyProgramDoc[0]?.conversionFactor as number) || 0);
if (this.sinvDoc.baseGrandTotal?.lt(loyaltyPoint)) {
throw new Error(
t`no need ${newValue as number} points to purchase this item`
);
throw new Error(t`no need ${newValue} points to purchase this item`);
}
this.validationError = false;
} catch (error) {
Expand Down
7 changes: 3 additions & 4 deletions src/pages/POS/POS.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

<LoyaltyProgramModal
:open-modal="openLoyaltyProgramModal"
:sinvDoc="sinvDoc"
:loyalty-points="loyaltyPoints"
:loyalty-program="loyaltyProgram"
@set-loyalty-points="setLoyaltyPoints"
Expand Down Expand Up @@ -486,7 +485,7 @@ export default defineComponent({
const party = await this.fyo.db.getAll(ModelNameEnum.Party, {
fields: ['loyaltyProgram', 'loyaltyPoints'],
filters: { name: value as string },
filters: { name: value },
});
this.loyaltyProgram = party[0]?.loyaltyProgram as string;
Expand Down Expand Up @@ -561,8 +560,8 @@ export default defineComponent({
const totalLotaltyAmount = await getAddedLPWithGrandTotal(
this.fyo,
this.loyaltyProgram as string,
value as number
this.loyaltyProgram,
value
);
const total = totalLotaltyAmount
Expand Down

0 comments on commit dc7b4b0

Please sign in to comment.