Skip to content

Commit

Permalink
fix setting group plan
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipthelen committed Dec 2, 2024
1 parent 837e531 commit 4d4ae79
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ export default {
},
beginGroupPlanConvert () {
this.isConvertingToGroupPlan = true;
this.purchased.plan.owner = '';
this.hero.purchased.plan.owner = '';
},
saveClicked (e) {
e.preventDefault();
Expand All @@ -454,7 +454,7 @@ export default {
alert('Invalid group ID');
return;
}
this.hero.purchased.plan.convertToGroup = this.groupPlanID;
this.hero.purchased.plan.convertToGroupPlan = this.groupPlanID;
this.saveHero({ hero: this.hero, msg: 'Group Plan Subscription' });
} else {
this.saveHero({ hero: this.hero, msg: 'Subscription Perks' });
Expand Down
9 changes: 6 additions & 3 deletions website/server/controllers/api-v3/hall.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { model as Group } from '../../models/group';
import common from '../../../common';
import {
NotFound,
BadRequest,
} from '../../libs/errors';
import { apiError } from '../../libs/apiError';
import {
Expand Down Expand Up @@ -333,13 +334,15 @@ api.updateHero = {

if (plan.convertToGroupPlan) {
const groupID = plan.convertToGroupPlan;
const group = await Group.getGroup({ hero, groupId: groupID });
const group = await Group.getGroup({ user: hero, groupId: groupID });
if (!group) throw new NotFound(res.t('groupNotFound'));
hero.purchased.plan.customerId = null;
hero.purchased.plan.paymentMethod = null;
if (group.hasNotCancelled()) {
hero.purchased.plan.customerId = null;
hero.purchased.plan.paymentMethod = null;
await addSubToGroupUser(hero, group);
await group.updateGroupPlan();
} else {
throw new BadRequest('Group does not have a plan');
}
}
}
Expand Down

0 comments on commit 4d4ae79

Please sign in to comment.