Skip to content

Commit

Permalink
fix(backend): fix patch of profile
Browse files Browse the repository at this point in the history
  • Loading branch information
pYassine committed Jul 26, 2024
1 parent 5553926 commit 5d513e8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 14 deletions.
1 change: 1 addition & 0 deletions packages/backend/src/auth/guards/usager-access.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export class UsagerAccessGuard implements CanActivate {
const structureId = parseInt(r.user.structureId, 10);

try {
// Todo: optimize this request, generate one request with a join
const usager = await usagerRepository.findOneOrFail({
where: {
structureId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export class UsagersController {
historyBeginDate,
});

return currentUsager;
return { ...currentUsager, ...usagerDto };
}

@UseGuards(UsagerAccessGuard)
Expand Down Expand Up @@ -256,7 +256,7 @@ export class UsagersController {
);
}

// TODO: optimize
// TODO: optimize this "get". Maybe we can do this better
const usager = await usagerRepository.getUsager(currentUsager.uuid);
const createdAt = new Date();
const historyBeginDate = createdAt;
Expand Down Expand Up @@ -332,7 +332,6 @@ export class UsagersController {
params.push(duplicateUsagerDto.usagerRef);
}

console.log(query);
return usagerRepository.query(query, params);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export class InteractionService {
.pipe(
tap((newUsager: UsagerLight) => {
this.store.dispatch(cacheManager.updateUsager({ usager: newUsager }));
return newUsager;
})
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HttpClient } from "@angular/common/http";
import { Injectable } from "@angular/core";
import { Observable } from "rxjs";
import { map, tap } from "rxjs/operators";
import { tap } from "rxjs/operators";
import { environment } from "src/environments/environment";
import {
UsagerDecisionRadiationForm,
Expand Down Expand Up @@ -79,14 +79,8 @@ export class UsagerDecisionService {
}

public getLastFiveCustomRef(usagerRef: number): Observable<UsagerLight[]> {
return this.http
.get(this.endPointDecision + "/last-usagers-refs/" + usagerRef)
.pipe(
map((response) => {
return Array.isArray(response)
? response.map((item) => item as UsagerLight)
: [response as UsagerLight];
})
);
return this.http.get<UsagerLight[]>(
this.endPointDecision + "/last-usagers-refs/" + usagerRef
);
}
}

0 comments on commit 5d513e8

Please sign in to comment.