-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2550 from codecrafters-io/update-referral-discoun…
…t-logic feat: update discount models and refactor related logic
- Loading branch information
Showing
20 changed files
with
192 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
...s/pay-page/early-bird-discount-notice.hbs → ...nents/pay-page/signup-discount-notice.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import Component from '@glimmer/component'; | ||
import PromotionalDiscountModel from 'codecrafters-frontend/models/promotional-discount'; | ||
|
||
interface Signature { | ||
Element: HTMLDivElement; | ||
|
||
Args: { | ||
discount: PromotionalDiscountModel; | ||
}; | ||
} | ||
|
||
export default class SignupDiscountNoticeComponent extends Component<Signature> {} | ||
|
||
declare module '@glint/environment-ember-loose/registry' { | ||
export default interface Registry { | ||
'PayPage::SignupDiscountNotice': typeof SignupDiscountNoticeComponent; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
import Model, { attr, belongsTo } from '@ember-data/model'; | ||
import type PromotionalDiscountModel from 'codecrafters-frontend/models/promotional-discount'; | ||
import type RegionalDiscountModel from 'codecrafters-frontend/models/regional-discount'; | ||
|
||
export default class IndividualCheckoutSessionModel extends Model { | ||
@attr('boolean') declare autoRenewSubscription: boolean; | ||
@attr('boolean') declare earlyBirdDiscountEnabled: boolean; | ||
@attr('boolean') declare extraInvoiceDetailsRequested: boolean; | ||
@attr('string') declare pricingFrequency: string; | ||
@attr('boolean') declare referralDiscountEnabled: boolean; | ||
@attr('string') declare successUrl: string; | ||
@attr('string') declare cancelUrl: string; | ||
@attr('string') declare url: string; | ||
|
||
@belongsTo('regional-discount', { async: false, inverse: null }) declare regionalDiscount: RegionalDiscountModel; | ||
@belongsTo('promotional-discount', { async: false, inverse: null }) declare promotionalDiscount: PromotionalDiscountModel; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import AffiliateReferralModel from 'codecrafters-frontend/models/affiliate-referral'; | ||
import Model, { attr, belongsTo } from '@ember-data/model'; | ||
import UserModel from 'codecrafters-frontend/models/user'; | ||
|
||
export default class PromotionalDiscountModel extends Model { | ||
@belongsTo('affiliate-referral', { async: false, inverse: null }) declare affiliateReferral: AffiliateReferralModel; | ||
@belongsTo('user', { async: false, inverse: 'promotionalDiscounts' }) declare user: UserModel; | ||
|
||
@attr('date') createdAt!: Date; | ||
@attr('date') expiresAt!: Date; | ||
@attr('string') type!: 'signup' | 'affiliate_referral'; | ||
@attr('number') percentageOff!: number; | ||
|
||
get isExpired() { | ||
return this.expiresAt < new Date(); | ||
} | ||
|
||
get isFromAffiliateReferral() { | ||
return this.type === 'affiliate_referral'; | ||
} | ||
|
||
get isFromSignup() { | ||
return this.type === 'signup'; | ||
} | ||
|
||
computeDiscountedPrice(price: number) { | ||
return price - (price * this.percentageOff) / 100; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.