Skip to content

Commit

Permalink
childre nsort
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsan-g committed Jul 16, 2024
1 parent aeabda7 commit 1870b24
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 22 deletions.
66 changes: 45 additions & 21 deletions src/features/children/children.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,30 @@ export class ChildrenController {
private downloadService: DownloadService,
private campaignService: CampaignService,
) {}
@Get(`preregister/:childFlaskId`)
@ApiOperation({ description: 'Get child preregister' })
async getChildPreregister(
@Req() req: Request,
@Param('childFlaskId') childFlaskId: number,
) {
const panelFlaskUserId = req.headers['panelFlaskUserId'];
const panelFlaskTypeId = req.headers['panelFlaskTypeId'];
if (
!isAuthenticated(panelFlaskUserId, panelFlaskTypeId) ||
!(
panelFlaskTypeId === FlaskUserTypesEnum.SOCIAL_WORKER ||
panelFlaskTypeId === FlaskUserTypesEnum.NGO_SUPERVISOR ||
panelFlaskTypeId === FlaskUserTypesEnum.SUPER_ADMIN ||
panelFlaskTypeId === FlaskUserTypesEnum.ADMIN
)
) {
throw new ForbiddenException('You Are not the Authorized!');
}

return await this.childrenService.getChildrenPreRegisterByFlaskId(
childFlaskId,
);
}

@UsePipes(new ValidationPipe()) // validation for dto files
@Patch(`preregister/approve/:id`)
Expand Down Expand Up @@ -318,7 +342,7 @@ export class ChildrenController {
panelFlaskTypeId === FlaskUserTypesEnum.ADMIN
)
) {
throw new ForbiddenException('You Are not the Super admin');
throw new ForbiddenException('You Are not the Authorized!');
}

if (!files) {
Expand Down Expand Up @@ -546,26 +570,26 @@ export class ChildrenController {
) {
throw new ForbiddenException('You Are not the Super admin');
}
// if(body.flaskChildId>0){
// const token =
// config().dataCache.fetchPanelAuthentication(panelFlaskUserId).token;
// const configs = {
// headers: {
// 'Content-Type': 'multipart/form-data',
// Authorization: token,
// processData: false,
// contentType: false,
// },
// };
// const formData = new FormData();
// formData.append('ngo_id', String(preRegister.flaskNgoId));
// // create flask child
// const { data } = await axios.post(
// 'https://api.sayapp.company/api/v2/child/add/',
// formData,
// configs,
// );
// }
// if(body.flaskChildId>0){
// const token =
// config().dataCache.fetchPanelAuthentication(panelFlaskUserId).token;
// const configs = {
// headers: {
// 'Content-Type': 'multipart/form-data',
// Authorization: token,
// processData: false,
// contentType: false,
// },
// };
// const formData = new FormData();
// formData.append('ngo_id', String(preRegister.flaskNgoId));
// // create flask child
// const { data } = await axios.post(
// 'https://api.sayapp.company/api/v2/child/add/',
// formData,
// configs,
// );
// }
try {
return await this.childrenService.preRegisterUpdate(body.id, {
bio: { fa: body.bio, en: '' },
Expand Down
2 changes: 1 addition & 1 deletion src/features/children/children.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ export class ChildrenService {
options,
queryBuilder,
{
sortableColumns: ['id'],
sortableColumns: ['createdAt'],
nullSort: 'last',
},
);
Expand Down

0 comments on commit 1870b24

Please sign in to comment.