chore: applied pre-commit hooks
This commit is contained in:
@@ -2,7 +2,15 @@
|
||||
<Dialog v-model="show" :options="{ title: dialogTitle, size: '3xl' }">
|
||||
<template #body-content>
|
||||
<div class="grid grid-cols-2 gap-4 pt-4">
|
||||
<FormControl v-model="doc.code" :label="__('Coupon Code')" :required="true" pattern="^[A-Za-z0-9]+$" minlength="6" @beforeinput="handleCodeInput" @input="doc.code = $event.target.value.toUpperCase()" />
|
||||
<FormControl
|
||||
v-model="doc.code"
|
||||
:label="__('Coupon Code')"
|
||||
:required="true"
|
||||
pattern="^[A-Za-z0-9]+$"
|
||||
minlength="6"
|
||||
@beforeinput="handleCodeInput"
|
||||
@input="doc.code = $event.target.value.toUpperCase()"
|
||||
/>
|
||||
<FormControl
|
||||
v-model="doc.discount_type"
|
||||
:label="__('Discount Type')"
|
||||
@@ -38,14 +46,33 @@
|
||||
/>
|
||||
<Switch v-model="doc.active" :label="__('Active')" />
|
||||
<div class="col-span-2">
|
||||
<div class="text-md font-medium text-ink-gray-7 mb-1 mt-2">{{ __('Select Courses/Batches') }}<span class="text-ink-red-3">*</span></div>
|
||||
<div class="text-md font-medium text-ink-gray-7 mb-1 mt-2">
|
||||
{{ __('Select Courses/Batches')
|
||||
}}<span class="text-ink-red-3">*</span>
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<div v-for="(row, idx) in doc.applicable_items" :key="idx" class="flex gap-2 items-end">
|
||||
<FormControl class="w-28" v-model="row.reference_doctype" :label="__('Type')" type="select" :options="[
|
||||
{ label: 'Course ', value: 'LMS Course' },
|
||||
{ label: 'Batch ', value: 'LMS Batch' }
|
||||
]" />
|
||||
<Link class="min-w-40" :doctype="row.reference_doctype || 'LMS Course'" :label="__('Name')" :value="row.reference_name" @change="(opt) => (row.reference_name = opt)" />
|
||||
<div
|
||||
v-for="(row, idx) in doc.applicable_items"
|
||||
:key="idx"
|
||||
class="flex gap-2 items-end"
|
||||
>
|
||||
<FormControl
|
||||
class="w-28"
|
||||
v-model="row.reference_doctype"
|
||||
:label="__('Type')"
|
||||
type="select"
|
||||
:options="[
|
||||
{ label: 'Course ', value: 'LMS Course' },
|
||||
{ label: 'Batch ', value: 'LMS Batch' },
|
||||
]"
|
||||
/>
|
||||
<Link
|
||||
class="min-w-40"
|
||||
:doctype="row.reference_doctype || 'LMS Course'"
|
||||
:label="__('Name')"
|
||||
:value="row.reference_name"
|
||||
@change="(opt) => (row.reference_name = opt)"
|
||||
/>
|
||||
<Button variant="subtle" @click="removeRow(idx)">
|
||||
<X class="h-3 w-3" />
|
||||
</Button>
|
||||
@@ -60,7 +87,9 @@
|
||||
</template>
|
||||
<template #actions>
|
||||
<div class="pb-5 float-right space-x-2">
|
||||
<Button variant="outline" @click="show = false">{{ __('Cancel') }}</Button>
|
||||
<Button variant="outline" @click="show = false">{{
|
||||
__('Cancel')
|
||||
}}</Button>
|
||||
<Button variant="solid" @click="save">{{ __('Save') }}</Button>
|
||||
</div>
|
||||
</template>
|
||||
@@ -87,7 +116,9 @@ const doc = ref({
|
||||
applicable_items: [],
|
||||
})
|
||||
|
||||
const dialogTitle = computed(() => (props.couponId === 'new' ? __('New Coupon') : __('Edit Coupon')))
|
||||
const dialogTitle = computed(() =>
|
||||
props.couponId === 'new' ? __('New Coupon') : __('Edit Coupon')
|
||||
)
|
||||
|
||||
const getDoc = createResource({
|
||||
url: 'frappe.client.get',
|
||||
@@ -106,14 +137,22 @@ watch(
|
||||
if (props.couponId && props.couponId !== 'new') {
|
||||
getDoc.submit()
|
||||
} else {
|
||||
doc.value = { code: '', discount_type: 'Percent', active: 1, applicable_items: [] }
|
||||
doc.value = {
|
||||
code: '',
|
||||
discount_type: 'Percent',
|
||||
active: 1,
|
||||
applicable_items: [],
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
function addRow() {
|
||||
doc.value.applicable_items.push({ reference_doctype: 'LMS Course', reference_name: null })
|
||||
doc.value.applicable_items.push({
|
||||
reference_doctype: 'LMS Course',
|
||||
reference_name: null,
|
||||
})
|
||||
}
|
||||
function removeRow(idx) {
|
||||
doc.value.applicable_items.splice(idx, 1)
|
||||
@@ -141,28 +180,33 @@ function handleCodeInput(event) {
|
||||
|
||||
function save() {
|
||||
if (props.couponId && props.couponId !== 'new') {
|
||||
saveDoc.submit({}, {
|
||||
onSuccess() {
|
||||
toast.success(__('Saved'))
|
||||
show.value = false
|
||||
emit('saved')
|
||||
},
|
||||
onError(err) {
|
||||
toast.error(err.messages?.[0] || err.message || err)
|
||||
saveDoc.submit(
|
||||
{},
|
||||
{
|
||||
onSuccess() {
|
||||
toast.success(__('Saved'))
|
||||
show.value = false
|
||||
emit('saved')
|
||||
},
|
||||
onError(err) {
|
||||
toast.error(err.messages?.[0] || err.message || err)
|
||||
},
|
||||
}
|
||||
})
|
||||
)
|
||||
} else {
|
||||
insertDoc.submit({}, {
|
||||
onSuccess() {
|
||||
toast.success(__('Saved'))
|
||||
show.value = false
|
||||
emit('saved')
|
||||
},
|
||||
onError(err) {
|
||||
toast.error(err.messages?.[0] || err.message || err)
|
||||
insertDoc.submit(
|
||||
{},
|
||||
{
|
||||
onSuccess() {
|
||||
toast.success(__('Saved'))
|
||||
show.value = false
|
||||
emit('saved')
|
||||
},
|
||||
onError(err) {
|
||||
toast.error(err.messages?.[0] || err.message || err)
|
||||
},
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -27,36 +27,49 @@
|
||||
<th class="text-left p-2">{{ __('Expires On') }}</th>
|
||||
<th class="text-left p-2">{{ __('Usage') }}</th>
|
||||
<th class="text-left p-2">{{ __('Active') }}</th>
|
||||
<th class="text-right p-2 w-8"></th>
|
||||
<th class="text-right p-2 w-8"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="row in coupons.data" :key="row.name" class="hover:bg-surface-gray-2 cursor-pointer" @click="openForm(row.name)">
|
||||
<tr
|
||||
v-for="row in coupons.data"
|
||||
:key="row.name"
|
||||
class="hover:bg-surface-gray-2 cursor-pointer"
|
||||
@click="openForm(row.name)"
|
||||
>
|
||||
<td class="p-2">{{ row.code }}</td>
|
||||
<td class="p-2">{{ row.discount_type }}</td>
|
||||
<td class="p-2">
|
||||
<span v-if="row.discount_type === 'Percent'">{{ row.percent_off }}%</span>
|
||||
<span v-if="row.discount_type === 'Percent'"
|
||||
>{{ row.percent_off }}%</span
|
||||
>
|
||||
<span v-else>{{ row.amount_off }}</span>
|
||||
</td>
|
||||
<td class="p-2">{{ row.expires_on || '-' }}</td>
|
||||
<td class="p-2">{{ row.times_redeemed }}/{{ row.usage_limit || '∞' }}</td>
|
||||
<td class="p-2">
|
||||
{{ row.times_redeemed }}/{{ row.usage_limit || '∞' }}
|
||||
</td>
|
||||
<td class="p-2">
|
||||
<Badge v-if="row.active" theme="green">{{ __('Enabled') }}</Badge>
|
||||
<Badge v-else theme="gray">{{ __('Disabled') }}</Badge>
|
||||
</td>
|
||||
<td class="p-2 text-right" @click.stop>
|
||||
<Button variant="ghost" @click="confirmDelete(row)">
|
||||
<template #icon>
|
||||
<td class="p-2 text-right" @click.stop>
|
||||
<Button variant="ghost" @click="confirmDelete(row)">
|
||||
<template #icon>
|
||||
<Trash2 class="h-4 w-4 stroke-1.5 text-ink-red-4" />
|
||||
</template>
|
||||
</Button>
|
||||
</td>
|
||||
</template>
|
||||
</Button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<CouponDetails v-model="showDialog" :coupon-id="selected" @saved="onSaved" />
|
||||
<CouponDetails
|
||||
v-model="showDialog"
|
||||
:coupon-id="selected"
|
||||
@saved="onSaved"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
@@ -104,7 +117,9 @@ function onSaved() {
|
||||
function confirmDelete(row) {
|
||||
$dialog({
|
||||
title: __('Delete this coupon?'),
|
||||
message: __('This will permanently delete the coupon and the code will no longer work. Are you sure?'),
|
||||
message: __(
|
||||
'This will permanently delete the coupon and the code will no longer work. Are you sure?'
|
||||
),
|
||||
actions: [
|
||||
{
|
||||
label: __('Delete'),
|
||||
@@ -127,4 +142,3 @@ function trashCoupon(name, close) {
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -88,7 +88,10 @@
|
||||
:disabled="true"
|
||||
/>
|
||||
<FormControl
|
||||
v-if="Number(transactionData.discount_amount) || Number(transactionData.gst_amount)"
|
||||
v-if="
|
||||
Number(transactionData.discount_amount) ||
|
||||
Number(transactionData.gst_amount)
|
||||
"
|
||||
:label="__('Total Amount')"
|
||||
v-model="transactionData.total_amount"
|
||||
:disabled="true"
|
||||
|
||||
@@ -73,7 +73,8 @@
|
||||
:disabled="true"
|
||||
/>
|
||||
<div v-else-if="column.key == 'amount'">
|
||||
{{ getCurrencySymbol(row['currency']) }} {{ row['total_amount'] }}
|
||||
{{ getCurrencySymbol(row['currency']) }}
|
||||
{{ row['total_amount'] }}
|
||||
</div>
|
||||
<div v-else class="leading-5 text-sm">
|
||||
{{ row[column.key] }}
|
||||
|
||||
@@ -35,7 +35,10 @@
|
||||
{{ orderSummary.data.original_amount_formatted }}
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="orderSummary.data.discount_amount" class="flex items-center justify-between mt-2">
|
||||
<div
|
||||
v-if="orderSummary.data.discount_amount"
|
||||
class="flex items-center justify-between mt-2"
|
||||
>
|
||||
<div class="text-ink-gray-5">{{ __('Discount') }}</div>
|
||||
<div>-{{ orderSummary.data.discount_amount_formatted }}</div>
|
||||
</div>
|
||||
@@ -61,11 +64,32 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-5">
|
||||
<div class="flex items-center gap-3 mt-2 flex-wrap md:flex-nowrap" v-if="props.type !== 'certificate'">
|
||||
<span class="text-ink-gray-5 text-xs shrink-0">{{ __('Coupon') }}</span>
|
||||
<FormControl class="flex-1 min-w-0 [&_input]:!bg-[#fefefe]" v-model="couponCode" :disabled="appliedCoupon" @input="couponCode = $event.target.value.toUpperCase()"/>
|
||||
<Button v-if="!appliedCoupon" @click="applyCouponCode" variant="outline">{{ __('Apply') }}</Button>
|
||||
<Button v-if="appliedCoupon" @click="removeCoupon" variant="subtle" class="bg-red-200"><X class="h-4.5 w-4.5" /></Button>
|
||||
<div
|
||||
class="flex items-center gap-3 mt-2 flex-wrap md:flex-nowrap"
|
||||
v-if="props.type !== 'certificate'"
|
||||
>
|
||||
<span class="text-ink-gray-5 text-xs shrink-0">{{
|
||||
__('Coupon')
|
||||
}}</span>
|
||||
<FormControl
|
||||
class="flex-1 min-w-0 [&_input]:!bg-[#fefefe]"
|
||||
v-model="couponCode"
|
||||
:disabled="appliedCoupon"
|
||||
@input="couponCode = $event.target.value.toUpperCase()"
|
||||
/>
|
||||
<Button
|
||||
v-if="!appliedCoupon"
|
||||
@click="applyCouponCode"
|
||||
variant="outline"
|
||||
>{{ __('Apply') }}</Button
|
||||
>
|
||||
<Button
|
||||
v-if="appliedCoupon"
|
||||
@click="removeCoupon"
|
||||
variant="subtle"
|
||||
class="bg-red-200"
|
||||
><X class="h-4.5 w-4.5"
|
||||
/></Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -268,7 +292,7 @@ const setBillingDetails = (data) => {
|
||||
const paymentLink = createResource({
|
||||
url: 'lms.lms.payments.get_payment_link',
|
||||
makeParams(values) {
|
||||
let data={
|
||||
let data = {
|
||||
doctype: props.type == 'batch' ? 'LMS Batch' : 'LMS Course',
|
||||
docname: props.name,
|
||||
title: orderSummary.data.title,
|
||||
|
||||
Reference in New Issue
Block a user