Skip to content

Commit

Permalink
[EN-6259] feat: backoffice admin offres
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulEntourage committed Nov 17, 2023
1 parent 39094cc commit 466cef3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/opportunities/dto/create-opportunity.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class CreateOpportunityPipe
forbidNonWhitelisted: true,
forbidUnknownValues: true,
});

if (errors.length > 0) {
throw new BadRequestException();
}
Expand Down
4 changes: 2 additions & 2 deletions src/opportunities/opportunities.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,8 @@ export class OpportunitiesController {
query: {
type: OfferAdminTab;
search: string;
offset: number;
limit: number;
} & FilterParams<OfferFilterKey>
) {
return this.opportunitiesService.findAll(query);
Expand Down Expand Up @@ -422,9 +424,7 @@ export class OpportunitiesController {
search: string;
} & FilterParams<OfferFilterKey>
) {
console.log(query);
const { type, search, businessLines, department, contracts } = query
console.log(type);
return this.opportunitiesService.adminCountOfferByType(type, search,businessLines, department, contracts);
}

Expand Down
11 changes: 10 additions & 1 deletion src/opportunities/opportunities.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ export class OpportunitiesService {
query: {
type: OfferAdminTab;
search: string;
offset: number;
limit: number;
} & FilterParams<OfferFilterKey>
) {
const {
Expand All @@ -182,12 +184,16 @@ export class OpportunitiesService {
delete filterOptions.isPublic;
}

const limit = query.limit || LIMIT;

const opportunities = await this.opportunityModel.findAll({
...options,
where: {
...searchOptions,
...filterOptions,
},
offset: query.offset ? query.offset * limit : 0,
limit,
});

const cleanedOpportunites = opportunities.map((opportunity) => {
Expand Down Expand Up @@ -1080,7 +1086,6 @@ export class OpportunitiesService {

const pendingOpportunitiesCount = await this.opportunityModel.count({
where: {
status: type ? type : '',
...searchOptions,
...filterOptions,
department,
Expand All @@ -1089,6 +1094,10 @@ export class OpportunitiesService {
},
});

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

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

return {pending: pendingOpportunitiesCount}
Expand Down
2 changes: 0 additions & 2 deletions src/utils/misc/getFiltersObjectsFromQueryParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ export function getFiltersObjectsFromQueryParams<K extends string, T>(

let filters = {} as FilterObject<K, T>;


if (filtersConst) {
_.forEach(Object.keys(params), (paramKey) => {
console.log(paramKey);
const filter = findConstant<K, T>(filtersConst, paramKey as K);
if (filter) {
const valueArray = params[paramKey as K];
Expand Down

0 comments on commit 466cef3

Please sign in to comment.