Skip to content

Commit

Permalink
Donor Home Fix (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
smile0711 authored Feb 7, 2024
1 parent 776f180 commit a51ecf7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
4 changes: 2 additions & 2 deletions api/src/controllers/home.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class HomeController {
if(home3d) {
// check they have enough in their wallet to buy the 3d home
// this is optional (if not null)
const homeDesignInfo = this.homeService.getHomeDesign(home3d);
const homeDesignInfo = await this.homeService.getHomeDesign(session.id, home3d);
if(homeDesignInfo.price > memberInfo.walletBalance) {
throw new Error('Not enough funds to purchase house.');
}
Expand Down Expand Up @@ -239,7 +239,7 @@ class HomeController {
) {
// check they have enough in their wallet to buy the 3d home
// this is optional (if not null)
const homeDesignInfo = this.homeService.getHomeDesign(home3d);
const homeDesignInfo = await this.homeService.getHomeDesign(session.id, home3d);
if(typeof homeDesignInfo.id === 'undefined') {
throw new Error('Home design not found.');
}
Expand Down
4 changes: 4 additions & 0 deletions api/src/repositories/home-design/home-design.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ export class HomeDesignRepository {
},
{
'id': 'championhome',
'price': 100000,
},
{
'id': 'free',
'price': 0,
},
]
Expand Down
22 changes: 21 additions & 1 deletion api/src/services/home/home.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
MapLocationRepository,
HomeDesignRepository,
HomeRepository,
RoleAssignmentRepository,
RoleRepository,
} from '../../repositories';
import { Place, HomeDesign } from '../../types/models';

Expand All @@ -17,6 +19,8 @@ export class HomeService {
private mapLocationRespository: MapLocationRepository,
private homeDesignRespository: HomeDesignRepository,
private homeRepository: HomeRepository,
private roleAssignmentRepository: RoleAssignmentRepository,
private roleRepository: RoleRepository,
) {}


Expand All @@ -42,7 +46,23 @@ export class HomeService {

}

public getHomeDesign(homeDesignId: string): HomeDesign {
public async getHomeDesign(memberId: number, homeDesignId: string): Promise<HomeDesign> {
const donorId = {
supporter: await this.roleRepository.roleMap.Supporter,
advocate: await this.roleRepository.roleMap.Advocate,
devotee: await this.roleRepository.roleMap.Devotee,
champion: await this.roleRepository.roleMap.Champion,
};

try {
const donorLevel: any = await this.roleAssignmentRepository.getDonor(memberId, donorId);
if (homeDesignId === 'championhome' && donorLevel.name === 'Champion'){
homeDesignId = 'free';
}
} catch (e) {
const donorLevel= 'none';
}

return this.homeDesignRespository.find(homeDesignId);
}

Expand Down
3 changes: 2 additions & 1 deletion spa/src/pages/home/HomeUpdateHomePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,9 @@ export default Vue.extend({
await this.$http.get("/member/getdonorlevel")
.then((response) => {
this.donorLevel = response.data.name;
console.log(this.donorLevel);
});
if(this.donorLevel === "Champion"){
this.homeData.championhome.price = 0;
}
Expand Down

0 comments on commit a51ecf7

Please sign in to comment.