Skip to content

Commit

Permalink
fix(backend): add search from 1 character
Browse files Browse the repository at this point in the history
  • Loading branch information
pYassine committed Nov 19, 2024
1 parent 7253f25 commit f190508
Show file tree
Hide file tree
Showing 17 changed files with 59 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
</p>

<p>
<strong>Sujet : </strong> {{ subject }}
<strong>Sujet : </strong>
{{ subject }}
</p>

<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
UserStructureAuthenticated,
UserStructureProfile,
} from "../../_common/model";
import { RdvDto } from "../dto/rdv.dto";
import { RdvDto } from "../dto/decision-form/rdv.dto";
import { UsagersService } from "../services/usagers.service";
import { Usager } from "@domifa/common";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export class UsagerDocsController {

@Get(":usagerRef")
@AllowUserStructureRoles("simple", "responsable", "admin")
@UseGuards(UsagerAccessGuard, UsagerDocAccessGuard)
@UseGuards(UsagerAccessGuard)
public async getUsagerDocuments(
@Param("usagerRef", new ParseIntPipe()) usagerRef: number,
@CurrentUsager() currentUsager: Usager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class UsagersController {
structureId: user.structureId,
},
select: USAGER_LIGHT_ATTRIBUTES,
take: chargerTousRadies ? undefined : 60,
take: chargerTousRadies ? undefined : 1600,
});

const usagersRadiesTotalCount = chargerTousRadies
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ApiProperty } from "@nestjs/swagger";
import { IsNotEmpty, IsString, MaxLength } from "class-validator";
import { StripTagsTransform } from "../../_common/decorators";
import { StripTagsTransform } from "../../../_common/decorators";

export class CheckDuplicateUsagerRefDto {
@ApiProperty({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { IsNotEmpty, IsString, MaxLength } from "class-validator";
import {
LowerCaseTransform,
StripTagsTransform,
} from "../../_common/decorators";
} from "../../../_common/decorators";

export class CheckDuplicateUsagerDto {
@ApiProperty({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
import {
UsagerSexe,
COUNTRIES,
Telephone,
UsagerAyantDroit,
} from "@domifa/common";
import { ApiProperty } from "@nestjs/swagger";
import { Type } from "class-transformer";
import {
IsArray,
IsBoolean,
IsDateString,
IsEmail,
IsIn,
IsNotEmpty,
IsObject,
IsOptional,
IsString,
MaxLength,
IsOptional,
IsDateString,
IsEmail,
IsObject,
IsBoolean,
IsArray,
ValidateIf,
ValidateNested,
} from "class-validator";

import { UsagerAyantDroitDto } from "./UsagerAyantDroitDto";

import {
LowerCaseTransform,
StripTagsTransform,
Trim,
StripTagsTransform,
TrimOrNullTransform,
} from "../../_common/decorators";
import {
Telephone,
UsagerAyantDroit,
UsagerSexe,
COUNTRIES,
} from "@domifa/common";
import { IsValidPhone } from "../../_common/decorators/IsValidPhoneDecorator";
LowerCaseTransform,
IsValidPhone,
} from "../../../_common/decorators";
import { UsagerAyantDroitDto } from "../UsagerAyantDroitDto";

export class CreateUsagerDto {
@ApiProperty({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ import {
ValidateIf,
} from "class-validator";

import {} from "../../_common/model";
import {
UsagerDecisionStatut,
UsagerDecisionMotif,
UsagerDecisionOrientation,
UsagerDecision,
} from "@domifa/common";
import { StripTagsTransform } from "../../_common/decorators";
import { StripTagsTransform } from "../../../_common/decorators";

export class DecisionDto implements UsagerDecision {
@ApiProperty({
Expand Down
6 changes: 6 additions & 0 deletions packages/backend/src/usagers/dto/decision-form/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// @index('./*', f => `export * from '${f.path}'`)
export * from "./check-duplicate-usager-ref.dto";
export * from "./check-duplicate-usager.dto";
export * from "./create-usager.dto";
export * from "./decision.dto";
export * from "./rdv.dto";
File renamed without changes.
6 changes: 1 addition & 5 deletions packages/backend/src/usagers/dto/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
// @index('./*', f => `export * from '${f.path}'`)
export * from "./check-duplicate-usager-ref.dto";
export * from "./check-duplicate-usager.dto";
export * from "./contact-details.dto";
export * from "./create-note.dto";
export * from "./create-usager.dto";
export * from "./decision.dto";
export * from "./decision-form";
export * from "./entretien.dto";
export * from "./pagination";
export * from "./procuration.dto";
export * from "./rdv.dto";
export * from "./search-usager.dto";
export * from "./transfert.dto";
export * from "./usager-doc";
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/usagers/dto/search-usager.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class SearchUsagerDto {
@IsOptional()
@IsString()
@Trim()
@MinLength(2)
@MinLength(1)
@StripTagsTransform()
@LowerCaseTransform()
public searchString!: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,7 @@ export class ManageUsagersPageComponent
private readonly toastr: CustomToastService
) {
this.selectedRefs = [];

this.me = this.authService.currentUserValue;

this.nbResults = 0;
this.needToPrint = false;
this.searching = true;
Expand Down Expand Up @@ -176,8 +174,6 @@ export class ManageUsagersPageComponent
).pipe(
debounceTime(300),
map((event: InputEvent) => {
console.log("searchInput");
console.log((event.target as HTMLInputElement).value);
return (event.target as HTMLInputElement).value;
})
);
Expand Down Expand Up @@ -237,6 +233,24 @@ export class ManageUsagersPageComponent
})
);

this.subscription.add(
this.chargerTousRadies$
.pipe(
filter((chargerTousRadies) => chargerTousRadies === true),
switchMap((chargerTousRadies) =>
this.usagerService
.fetchSearchPageUsagerData({ chargerTousRadies })
.pipe(
switchMap(() =>
this.findRemoteUsagers(chargerTousRadies, this.filters)
)
)
),
takeUntil(this.destroy$)
)
.subscribe()
);

this.subscription.add(
this.store
.select(selectUsagerStateData())
Expand Down Expand Up @@ -272,7 +286,6 @@ export class ManageUsagersPageComponent
})
);
}),

takeUntil(this.destroy$)
)
.subscribe(({ filters, usagers, usagersRadiesTotalCount }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ it("usagersSorter RADIE (usager.decision.dateFin)", () => {
expect(results.length).toEqual(usagers.length);
expect(
results.map((x) => {
console.log({ dateToDisplay: x.echeanceInfos.dateToDisplay, ref: x.ref });
return x.ref;
})
).toEqual([5, 4, 1, 2, 3]); // null last
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export class DecisionRadiationFormComponent implements OnInit, OnDestroy {
);
this.store.dispatch(
usagerActions.updateUsagersRadiesTotalCount({
usagersRefsToDelete: this.selectedRefs.length,
newRadies: this.selectedRefs.length,
})
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ export const _usagerReducer = createReducer(
usagersRadiesTotalCount: newState.usagersRadiesTotalCount - radiesCount,
};
}

return newState;
}),
on(usagerActions.updateUsagerNotes, (state, { ref, nbNotes }) =>
Expand All @@ -86,16 +85,12 @@ export const _usagerReducer = createReducer(
usagersRadiesTotalCount,
})
),
on(
usagerActions.updateUsagersRadiesTotalCount,
(state, { usagersRefsToDelete }) => {
return {
...state,
usagersRadiesTotalCount:
state.usagersRadiesTotalCount - usagersRefsToDelete,
};
}
)
on(usagerActions.updateUsagersRadiesTotalCount, (state, { newRadies }) => {
return {
...state,
usagersRadiesTotalCount: state.usagersRadiesTotalCount + newRadies,
};
})
);

// get the selectors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const usagerActions = {
),
updateUsagersRadiesTotalCount: createAction(
"[Usager] updateUsagersRadiesTotalCount",
props<{ usagersRefsToDelete: number }>()
props<{ newRadies: number }>()
),
};
// Feature Selector
Expand Down

0 comments on commit f190508

Please sign in to comment.