mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Updated complimentary subscription assignment to member
no refs With custom products, we added a new modal to add a complimentary price to a member. Since we want to handle the comp prices implicitly with new changes, this change updates the comp subscription assignment to a member directly without opening a modal, by using the old `comped` flag in API. The `comped` flag takes care of creating the right complimentary subscription for member. In case a member already has a comped subscription, we hide the option to add another subscription.
This commit is contained in:
parent
a2e3e0c570
commit
942ad319e8
4 changed files with 28 additions and 11 deletions
|
@ -109,9 +109,11 @@
|
|||
<div class="gh-cp-memberproduct-noproduct">
|
||||
<div class="mb2">This member doesn't have subscriptions.</div>
|
||||
{{#unless this.member.isNew}}
|
||||
<button type="button" class="gh-btn gh-btn-text green gh-btn-icon gh-btn-addproduct" {{action (toggle "showMemberProductModal" this)}}>
|
||||
<span>{{svg-jar "add"}} Add complimentary subscription</span>
|
||||
</button>
|
||||
{{#if this.isAddComplimentaryAllowed}}
|
||||
<button type="button" class="gh-btn gh-btn-text green gh-btn-icon gh-btn-addproduct" {{action "addCompedSubscription"}}>
|
||||
<span>{{svg-jar "add"}} Add complimentary subscription</span>
|
||||
</button>
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -177,12 +179,13 @@
|
|||
</span>
|
||||
</div>
|
||||
{{/each}}
|
||||
|
||||
<div class="gh-memberproduct-list-footer">
|
||||
<button type="button" class="gh-btn gh-btn-text green gh-btn-icon gh-btn-addproduct" {{action (toggle "showMemberProductModal" this)}}>
|
||||
<span>{{svg-jar "add"}} Add complimentary subscription</span>
|
||||
</button>
|
||||
</div>
|
||||
{{#if this.isAddComplimentaryAllowed}}
|
||||
<div class="gh-memberproduct-list-footer">
|
||||
<button type="button" class="gh-btn gh-btn-text green gh-btn-icon gh-btn-addproduct" {{action "addCompedSubscription"}}>
|
||||
<span>{{svg-jar "add"}} Add complimentary subscription</span>
|
||||
</button>
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
{{/each}}
|
||||
|
|
|
@ -29,6 +29,14 @@ export default class extends Component {
|
|||
return !this.member.get('isNew') && this.membersUtils.isStripeEnabled;
|
||||
}
|
||||
|
||||
get isAddComplimentaryAllowed() {
|
||||
let subscriptions = this.member.get('subscriptions') || [];
|
||||
const hasZeroPriceSub = subscriptions.find((sub) => {
|
||||
return !sub?.price?.amount;
|
||||
});
|
||||
return !hasZeroPriceSub;
|
||||
}
|
||||
|
||||
get products() {
|
||||
let products = this.member.get('products') || [];
|
||||
let subscriptions = this.member.get('subscriptions') || [];
|
||||
|
@ -95,6 +103,11 @@ export default class extends Component {
|
|||
continueSubscription(subscriptionId) {
|
||||
this.continueSubscriptionTask.perform(subscriptionId);
|
||||
}
|
||||
@action
|
||||
addCompedSubscription() {
|
||||
this.args.setProperty('comped', true);
|
||||
this.args.saveMember();
|
||||
}
|
||||
|
||||
@task({drop: true})
|
||||
*cancelSubscriptionTask(subscriptionId) {
|
||||
|
|
|
@ -159,7 +159,7 @@ export default class MemberController extends Controller {
|
|||
_saveMemberProperty(propKey, newValue) {
|
||||
let currentValue = this.member.get(propKey);
|
||||
|
||||
if (newValue) {
|
||||
if (newValue && typeof newValue === 'string') {
|
||||
newValue = newValue.trim();
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
@member={{this.member}}
|
||||
@scratchMember={{this.scratchMember}}
|
||||
@setProperty={{this.setProperty}}
|
||||
@saveMember={{this.save}}
|
||||
@isLoading={{this.isLoading}} />
|
||||
</form>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue