Skip to content

Commit

Permalink
temp changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsan-g committed Nov 12, 2023
1 parent 14ba7e0 commit 228c35d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 24 deletions.
14 changes: 7 additions & 7 deletions src/features/campaign/campaign.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class CampaignService {
private familyService: FamilyService,
private mailerService: MailerService,
private childrenService: ChildrenService,
) {}
) { }
private readonly logger = new Logger(CampaignService.name);

getCampaigns(): Promise<CampaignEntity[]> {
Expand Down Expand Up @@ -97,7 +97,7 @@ export class CampaignService {

async sendSwChildConfirmation(
swId: number,
child: ChildrenPreRegisterEntity,
preChild: ChildrenPreRegisterEntity,
) {
const socialWorker = await this.userService.getContributorByFlaskId(
swId,
Expand All @@ -111,7 +111,7 @@ export class CampaignService {
);
const campaign = this.getCampaignByCampaignCode(campaignCode);
if (campaign) {
const title = `${child.sayName.fa} تأیید شد`;
const title = `${preChild.sayName.fa} تأیید شد`;
await this.createCampaign(
campaignCode,
CampaignNameEnum.CHILD_CONFIRMATION,
Expand All @@ -130,10 +130,10 @@ export class CampaignService {
subject: title,
template: './swConfirmedChild', // `.hbs` extension is appended automatically
context: {
avatarAwake: child.awakeUrl,
sayName: child.sayName.fa,
firstName: child.firstName.fa,
lastName: child.lastName.fa,
avatarAwake: preChild.awakeUrl,
sayName: preChild.sayName.fa,
firstName: preChild.firstName.fa,
lastName: preChild.lastName.fa,
userName: socialWorker.firstName
? socialWorker.firstName
: socialWorker.userName,
Expand Down
38 changes: 21 additions & 17 deletions src/features/children/children.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class ChildrenController {
private locationService: LocationService,
private downloadService: DownloadService,
private campaignService: CampaignService,
) {}
) { }

@UsePipes(new ValidationPipe()) // validation for dto files
@Patch(`preregister/approve/:id`)
Expand Down Expand Up @@ -113,6 +113,12 @@ export class ChildrenController {
preRegister.status === PreRegisterStatusEnum.CONFIRMED ||
preRegister.status === PreRegisterStatusEnum.NOT_REGISTERED
) {
// send email
await this.campaignService.sendSwChildConfirmation(
preRegister.flaskSwId,
preRegister,
);

throw new ServerError('Pre register approval cou;d not go ahead!');
}
if (!voiceFile) {
Expand Down Expand Up @@ -266,6 +272,9 @@ export class ChildrenController {
id,
);

if (preRegister.status === PreRegisterStatusEnum.CONFIRMED) {
throw new ForbiddenException(403, 'This Child has been confirmed');
}
await this.childrenService.deletePreRegister(preRegister.id);
} catch (e) {
throw new ServerError(e);
Expand Down Expand Up @@ -314,22 +323,17 @@ export class ChildrenController {

// for local purposes - organized folders and files
if (process.env.NODE_ENV === 'development') {
const newChildFolder = `../../Docs/children${
Number(body.sex) === SexEnum.MALE ? '/boys/' : '/girls/'
}organized/${capitalizeFirstLetter(body.sayNameEn)}-${body.sayNameFa}`;

const originalAwakeGirl = `../../Docs/children/girls/${
files.awakeFile[0].filename.split('-s-')[0]
}.png`;
const originalAwakeBoy = `../../Docs/children/boys/${
files.awakeFile[0].filename.split('-s-')[0]
}.png`;
const originalSleptGirl = `../../Docs/children/girls/${
files.sleptFile[0].filename.split('-s-')[0]
}.png`;
const originalSleptBoy = `../../Docs/children/boys/${
files.sleptFile[0].filename.split('-s-')[0]
}.png`;
const newChildFolder = `../../Docs/children${Number(body.sex) === SexEnum.MALE ? '/boys/' : '/girls/'
}organized/${capitalizeFirstLetter(body.sayNameEn)}-${body.sayNameFa}`;

const originalAwakeGirl = `../../Docs/children/girls/${files.awakeFile[0].filename.split('-s-')[0]
}.png`;
const originalAwakeBoy = `../../Docs/children/boys/${files.awakeFile[0].filename.split('-s-')[0]
}.png`;
const originalSleptGirl = `../../Docs/children/girls/${files.sleptFile[0].filename.split('-s-')[0]
}.png`;
const originalSleptBoy = `../../Docs/children/boys/${files.sleptFile[0].filename.split('-s-')[0]
}.png`;

const newAwakeName = `awake-${body.sayNameEn.toLowerCase()}.png`;
const newSleepName = `sleep-${body.sayNameEn.toLowerCase()}.png`;
Expand Down

0 comments on commit 228c35d

Please sign in to comment.