Skip to content

Commit

Permalink
[EN-6259] feat: back office admin offres
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulEntourage committed Nov 23, 2023
1 parent 6279eaf commit 2e04cfc
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 52 deletions.
27 changes: 14 additions & 13 deletions src/opportunities/opportunities.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,19 +414,20 @@ export class OpportunitiesController {
return this.opportunityUsersService.candidateCountOffersByStatus(candidateId);
}

@UserPermissions(Permissions.ADMIN)
@UseGuards(UserPermissionsGuard)
@Get('/admin/tabCount')
async adminCountOffersByType(
@Query()
query: {
type: OfferAdminTab;
search: string;
} & FilterParams<OfferFilterKey>
) {
const { type, search, businessLines, department, contracts } = query
return this.opportunitiesService.adminCountOfferByType(type, search,businessLines, department, contracts);
}
// to be implemented
// @UserPermissions(Permissions.ADMIN)
// @UseGuards(UserPermissionsGuard)
// @Get('/admin/tabCount')
// async adminCountOffersByType(
// @Query()
// query: {
// type: OfferAdminTab;
// search: string;
// } & FilterParams<OfferFilterKey>
// ) {
// const { type, search, businessLines, department, contracts } = query
// return this.opportunitiesService.adminCountOfferByType(type, search,businessLines, department, contracts);
// }

@UserPermissions(Permissions.CANDIDATE, Permissions.COACH)
@UseGuards(UserPermissionsGuard)
Expand Down
79 changes: 40 additions & 39 deletions src/opportunities/opportunities.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1060,46 +1060,47 @@ export class OpportunitiesService {
}


async adminCountOfferByType(
type: OfferAdminTab,
search: string,
businessLines: string[],
department: string[],
contracts: string[],
) {
// to be implemented
// async adminCountOfferByType(
// type: OfferAdminTab,
// search: string,
// businessLines: string[],
// department: string[],
// contracts: string[],
// ) {

const {
typeParams,
searchOptions,
filterOptions,
} = destructureOptionsAndParams({type, search, businessLines, department});
// const {
// typeParams,
// searchOptions,
// filterOptions,
// } = destructureOptionsAndParams({type, search, businessLines, department});

// const typeCounts = await this.opportunityModel.sequelize.query()
// // const typeCounts = await this.opportunityModel.sequelize.query()

// console.log("before destructure")
// console.log({typeParams, searchOptions,
// businessLinesOptions,
// filterOptions})
// console.log("after destructure")

console.log("type params", typeParams);

const pendingOpportunitiesCount = await this.opportunityModel.count({
where: {
...searchOptions,
...filterOptions,
department,
isValidated: false,
isArchived: false,
},
});

// const cleanedOpportunites = pendingOpportunitiesCount.map((opportunity) => {
// return opportunity.toJSON();
// });

console.log({type, search, businessLines, department, contracts});

return {pending: pendingOpportunitiesCount}
}
// // console.log("before destructure")
// // console.log({typeParams, searchOptions,
// // businessLinesOptions,
// // filterOptions})
// // console.log("after destructure")

// console.log("type params", typeParams);

// const pendingOpportunitiesCount = await this.opportunityModel.count({
// where: {
// ...searchOptions,
// ...filterOptions,
// department,
// isValidated: false,
// isArchived: false,
// },
// });

// // const cleanedOpportunites = pendingOpportunitiesCount.map((opportunity) => {
// // return opportunity.toJSON();
// // });

// console.log({type, search, businessLines, department, contracts});

// return {pending: pendingOpportunitiesCount}
// }
}

0 comments on commit 2e04cfc

Please sign in to comment.