Skip to content

Commit

Permalink
update voice for preregister
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsan-g committed Jul 24, 2024
1 parent efbfdd7 commit 3f057dd
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 39 deletions.
77 changes: 38 additions & 39 deletions src/features/children/children.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,44 @@ export class ChildrenController {
}
}

@ApiOperation({
description: 'update pre register',
})
@ApiOperation({ description: 'update pre register' })
@Patch(`preregister/update`)
@UsePipes(new ValidationPipe())
@UseInterceptors(FileInterceptor('voiceFile', voiceStorage))
async preRegisterUpdate(
@Req() req: Request,
@UploadedFile() voiceFile,
@Body(ValidateChildTsPipe) body: UpdatePreRegisterChildDto,
) {
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 Super admin');
}
try {
return await this.childrenService.preRegisterUpdate(body.id, {
bio: { fa: body.bio, en: '' },
voiceUrl: voiceFile.filename,
housingStatus: Number(body.housingStatus),
educationLevel: Number(body.educationLevel),
schoolType: Number(body.schoolType),
lastName: { fa: body.lastName, en: '' },
firstName: { fa: body.firstName, en: '' },
});
} catch (e) {
throw new ServerError(e.message, e.status);
}
}

@ApiOperation({ description: 'update approved pre register' })
@Patch(`preregister/update-approved/:flaskChildId`)
@UsePipes(new ValidationPipe())
async preRegisterUpdateApproved(
Expand Down Expand Up @@ -649,42 +684,6 @@ export class ChildrenController {
}
}

@ApiOperation({
description: 'update pre register',
})
@Patch(`preregister/update`)
@UsePipes(new ValidationPipe())
async preRegisterUpdate(
@Req() req: Request,
@Body(ValidateChildTsPipe) body: UpdatePreRegisterChildDto,
) {
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 Super admin');
}
try {
return await this.childrenService.preRegisterUpdate(body.id, {
bio: { fa: body.bio, en: '' },
housingStatus: Number(body.housingStatus),
educationLevel: Number(body.educationLevel),
schoolType: Number(body.schoolType),
lastName: { fa: body.lastName, en: '' },
firstName: { fa: body.firstName, en: '' },
});
} catch (e) {
throw new ServerError(e.message, e.status);
}
}

@UseInterceptors(ChildrenInterceptor)
@Get(`preregister/all/:status`)
@ApiOperation({ description: 'Get all children from db' })
Expand Down
1 change: 1 addition & 0 deletions src/types/parameters/ChildParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export type PreRegisterChildPrepareParams = {

export type PreRegisterChildUpdateParams = {
bio: { fa: string; en: string };
voiceUrl?: string;
housingStatus: HousingEnum;
educationLevel: EducationEnum;
schoolType: SchoolTypeEnum;
Expand Down

0 comments on commit 3f057dd

Please sign in to comment.