Skip to content

Commit

Permalink
preregister bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsan-g committed Nov 15, 2023
1 parent 804dad2 commit 56f9646
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 37 deletions.
4 changes: 2 additions & 2 deletions src/features/campaign/campaign.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,14 @@ export class CampaignService {
CampaignTypeEnum.EMAIL,
);
const campaign = await this.getCampaignByCampaignCode(
campaignCode,
`${campaignCode} - ${preChild.sayName.fa} - ${preChild.flaskChildId}`,
CampaignTypeEnum.EMAIL,
);

if (!campaign) {
const title = `${preChild.sayName.fa} تأیید شد`;
await this.createCampaign(
campaignCode,
`${campaignCode} - ${preChild.sayName.fa} - ${preChild.flaskChildId}`,
CampaignNameEnum.CHILD_CONFIRMATION,
CampaignTypeEnum.EMAIL,
title,
Expand Down
2 changes: 1 addition & 1 deletion src/features/campaign/middlewares/campaign.middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class CampaignMiddleware implements NestMiddleware {
try {
await updateFlaskCacheAuthentication(req, this.logger);
} catch (e) {
throw new ServerError(e);
throw new ServerError(e.message, e.status);
}

const { host, origin } = req.headers;
Expand Down
26 changes: 1 addition & 25 deletions src/features/children/children.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,34 +247,10 @@ export class ChildrenController {
approvedPre: approvedPre,
};
} catch (e) {
console.log(e);
throw new ServerError('Flask reverted!');
}
}
@Patch('test')
async confirm(@Req() req: Request,) {
const panelFlaskUserId = req.headers['panelFlaskUserId'];
const panelFlaskTypeId = req.headers['panelFlaskTypeId'];
try {


const preRegister = await this.childrenService.getChildrenPreRegisterByFlaskId(
170);
console.log(preRegister);

// send email
await this.campaignService.sendSwChildConfirmation(
preRegister.flaskSwId,
preRegister,
);

} catch (e) {
console.log(e);

}

}


@Delete(`preregister/:id`)
@ApiOperation({ description: 'Delete a pre register' })
async deletePreRegister(@Req() req: Request, @Param('id') id: string) {
Expand Down
19 changes: 10 additions & 9 deletions src/features/children/children.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class ChildrenService {
private childrenRepository: Repository<ChildrenEntity>,
@InjectRepository(Child, 'flaskPostgres')
private flaskChildRepository: Repository<Child>,
) {}
) { }

async countChildren(ngoIds: number[]) {
return this.flaskChildRepository
Expand Down Expand Up @@ -270,7 +270,8 @@ export class ChildrenService {
options,
queryBuilder,
{
sortableColumns: ['createdAt'],
defaultSortBy: [['createdAt', 'DESC']],
sortableColumns: ['id'],
nullSort: 'last',
},
);
Expand Down Expand Up @@ -333,8 +334,8 @@ export class ChildrenService {
body.isConfirmed === ChildConfirmation.CONFIRMED
? [true]
: ChildConfirmation.NOT_CONFIRMED
? [false]
: ChildConfirmation.BOTH && [true, false],
? [false]
: ChildConfirmation.BOTH && [true, false],
})
.andWhere('child.id_social_worker IN (:...socialWorkerIds)', {
socialWorkerIds: [...socialWorkerIds],
Expand All @@ -344,11 +345,11 @@ export class ChildrenService {
body.statuses[0] >= 0
? [...body.statuses]
: [
ChildExistence.DEAD,
ChildExistence.AlivePresent,
ChildExistence.AliveGone,
ChildExistence.TempGone,
],
ChildExistence.DEAD,
ChildExistence.AlivePresent,
ChildExistence.AliveGone,
ChildExistence.TempGone,
],
})

.andWhere('child.id_ngo NOT IN (:...testNgoIds)', {
Expand Down

0 comments on commit 56f9646

Please sign in to comment.