Skip to content

Commit

Permalink
add new condition type option
Browse files Browse the repository at this point in the history
  • Loading branch information
KrystianEscolaSoft committed Oct 7, 2024
1 parent b2b20a5 commit ed748bc
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 8 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "store-admin",
"version": "7.0.2",
"version": "7.0.3",
"private": true,
"description": "Admin panel for Heseya Store API",
"author": "Heseya",
Expand All @@ -19,7 +19,7 @@
"postinstall": "patch-package"
},
"dependencies": {
"@heseya/store-core": "7.0.0",
"@heseya/store-core": "7.1.0-beta.2",
"@sentry/tracing": "^7.6.0",
"@sentry/vue": "^7.6.0",
"ant-design-vue": "^1.7.8",
Expand Down
13 changes: 11 additions & 2 deletions src/components/modules/sales/ConditionForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
"max-uses-per-user": "Max uses per user",
"weekday-in": "Weekday in",
"cart-length": "Number of products in the cart",
"coupons-count": "Number of coupons in the cart"
"coupons-count": "Number of coupons in the cart",
"on-sale": "Product price"
}
},
"pl": {
Expand All @@ -79,7 +80,8 @@
"max-uses-per-user": "Maksymalna liczba użyć na użytkownika",
"weekday-in": "Wybrane dni tygodnia",
"cart-length": "Ilość produktów w koszyku",
"coupons-count": "Ilość kuponów w koszyku"
"coupons-count": "Ilość kuponów w koszyku",
"on-sale": "Cena produktu"
}
}
}
Expand All @@ -98,6 +100,7 @@ import DateBetweenForm from './forms/DateBetweenForm.vue'
import TimeBetweenForm from './forms/TimeBetweenForm.vue'
import WeekdayInForm from './forms/WeekdayInForm.vue'
import EntitiesForm from './forms/EntitiesForm.vue'
import OnSaleForm from './forms/OnSaleForm.vue'
import * as SALES_FORMS from '@/consts/salesConditionsForms'
Expand All @@ -111,6 +114,7 @@ export default defineComponent({
TimeBetweenForm,
WeekdayInForm,
EntitiesForm,
OnSaleForm,
},
props: {
value: { type: Object as PropType<DiscountConditionDto>, required: true },
Expand Down Expand Up @@ -154,6 +158,8 @@ export default defineComponent({
case DiscountConditionType.ProductInSet:
case DiscountConditionType.ProductIn:
return 'EntitiesForm'
case DiscountConditionType.OnSale:
return 'OnSaleForm'
default:
return 'div'
}
Expand Down Expand Up @@ -213,6 +219,9 @@ export default defineComponent({
case DiscountConditionType.CouponsCount:
this.condition = cloneDeep(SALES_FORMS.EMPTY_COUPONS_COUNT_FORM)
break
case DiscountConditionType.OnSale:
this.condition = cloneDeep(SALES_FORMS.EMPTY_ON_SALE_FORM)
break
default:
throw new Error(`Unknown condition type: ${newType}`)
}
Expand Down
72 changes: 72 additions & 0 deletions src/components/modules/sales/forms/OnSaleForm.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<template>
<div class="order-value-form">
<div class="condition-form__row">
<switch-input v-model="form.on_sale" :disabled="disabled">
<template #title>
{{ $t('form.on_sale') }}
<info-tooltip>{{ $t('tooltips.on_sale') }}</info-tooltip>
</template>
</switch-input>
</div>
</div>
</template>

<i18n lang="json">
{
"en": {
"form": {
"on_sale": "Only for non-priced products"
},
"tooltips": {
"on_sale": "If checked, this code will only apply to products that are not discounted"
}
},
"pl": {
"form": {
"on_sale": "Tylko dla produktów nieprzecenionych"
},
"tooltips": {
"on_sale": "Jeżeli zaznaczone, kod ten będzie miał zastosowanie tylko dla produktów nieprzecenionych"
}
}
}
</i18n>

<script lang="ts">
/* eslint-disable camelcase */
import { defineComponent, PropType } from 'vue'
import { DiscountConditionType } from '@heseya/store-core'
import SwitchInput from '@/components/form/SwitchInput.vue'
type OnSaleForm = {
type: DiscountConditionType
on_sale: boolean
}
export default defineComponent({
components: { SwitchInput },
props: {
value: { type: Object as PropType<OnSaleForm>, required: true },
type: { type: String as PropType<DiscountConditionType>, required: true },
disabled: { type: Boolean, default: false },
},
computed: {
DiscountConditionType(): typeof DiscountConditionType {
return DiscountConditionType
},
formId(): string {
// @ts-ignore // ? Unofficial Vue api
return this._uid
},
form: {
get(): OnSaleForm {
return this.value
},
set(v: OnSaleForm) {
this.$emit('input', v)
},
},
},
})
</script>
6 changes: 6 additions & 0 deletions src/consts/salesConditionsForms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
UserInRoleDiscountConditionDto,
WeekdayInDiscountConditionDto,
CouponsCountDiscountConditionDto,
OnSaleDiscountConditionDto,
} from '@heseya/store-core'

export const EMPTY_ORDER_VALUE_FORM: OrderValueDiscountConditionDto = {
Expand Down Expand Up @@ -86,3 +87,8 @@ export const EMPTY_COUPONS_COUNT_FORM: CouponsCountDiscountConditionDto = {
min_value: 0,
max_value: 0,
}

export const EMPTY_ON_SALE_FORM: OnSaleDiscountConditionDto = {
type: DiscountConditionType.OnSale,
on_sale: true,
}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1224,10 +1224,10 @@
dependencies:
"@hapi/hoek" "^9.0.0"

"@heseya/store-core@7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/@heseya/store-core/-/store-core-7.0.0.tgz#5a1199b817e2c3f696456e01cd76370124cf337b"
integrity sha512-Rk/gX5ao+p8de5o5jtFapr4AV0uEJHDXGVq5VXXYLSMWsMfwNIyto0lC/GQvvvi3k3iUDcE+XB3zrpJKtRt12g==
"@heseya/store-core@7.1.0-rc2":
version "7.1.0-beta.2"
resolved "https://registry.yarnpkg.com/@heseya/store-core/-/store-core-7.1.0-beta.2.tgz#fe75d681f5f3c7d5fa4b5037d2122117b738f8fb"
integrity sha512-a7lmTvOWPh1g7+Bq3Fv3szlJ6RaycR9co89Sh0Ydevg8NydCN9haLTlEltkKhPvkFlHdNa8DbsuqZfa19IqaEw==
dependencies:
flat "^5.0.2"
form-data "^4.0.0"
Expand Down

0 comments on commit ed748bc

Please sign in to comment.