Files
discourse-subscriptions/assets/javascripts/discourse/components/create-coupon-form.js
T

36 lines
725 B
JavaScript
Raw Normal View History

import Component from "@ember/component";
2024-11-29 15:42:50 +00:00
import { action } from "@ember/object";
import discourseComputed from "discourse-common/utils/decorators";
2024-11-29 15:42:50 +00:00
export default class CreateCouponForm extends Component {
discountType = "amount";
discount = null;
promoCode = null;
active = false;
@discourseComputed
discountTypes() {
return [
{ id: "amount", name: "Amount" },
{ id: "percent", name: "Percent" },
];
2024-11-29 15:42:50 +00:00
}
2024-11-29 15:42:50 +00:00
@action
createNewCoupon() {
const createParams = {
promo: this.promoCode,
discount_type: this.discountType,
discount: this.discount,
active: this.active,
};
2024-11-29 15:42:50 +00:00
this.create(createParams);
}
@action
cancelCreate() {
this.cancel();
}
}