Skip to content

Commit

Permalink
src/affiliate: Generate new code whenever affiliate is set to active
Browse files Browse the repository at this point in the history
  • Loading branch information
sashko9807 committed Oct 20, 2023
1 parent 1dc7243 commit 505a210
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions apps/api/src/affiliate/affiliate.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,14 @@ export class AffiliateController {
throw new ConflictException('Status is the same')
}

if (
(affiliate.status === 'pending' || affiliate.status === 'cancelled') &&
newStatus === 'active'
) {
if (affiliate.status !== 'active' && newStatus === 'active') {
affiliateCode = affiliateCodeGenerator(affiliate.id)
}

if (affiliate.status === 'active' && newStatus !== 'active') {
affiliateCode = null
}

return await this.affiliateService.updateStatus(affiliateId, newStatus, affiliateCode)
}

Expand Down

0 comments on commit 505a210

Please sign in to comment.