Skip to content

Commit

Permalink
Apply merge fixes about pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbgomes committed Jan 2, 2024
1 parent abbc068 commit ccb0758
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 26 deletions.
2 changes: 2 additions & 0 deletions src/data/repositories/UserD2Repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ export class UserD2Repository implements UserRepository {
id: true,
},
},
userOnly: true,
userDataViewOnly: true,
paging: false,
})
).flatMap(res => {
Expand Down
51 changes: 29 additions & 22 deletions src/data/repositories/testRepositories/SurveyFormTestRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,29 +111,36 @@ export class SurveyTestRepository implements SurveyRepository {
}
}

getFilteredSurveys(keyword: string, orgUnitId: string): FutureData<Survey[]> {
return Future.success([
{
name: "TestSurvey1",
id: "1",
startDate: new Date(),
status: "ACTIVE",
assignedOrgUnit: { id: orgUnitId, name: "OU1" },
surveyType: "SUPRANATIONAL",
rootSurvey: { id: "1", name: "TestSurvey1", surveyType: "" },
surveyFormType: "PPSSurveyForm",
},
{
name: "TestSurvey2",
id: "2",
startDate: new Date(),
status: "COMPLETED",
assignedOrgUnit: { id: "OU1234", name: "OU2" },
surveyType: "NATIONAL",
rootSurvey: { id: "2", name: "TestSurvey1", surveyType: "" },
surveyFormType: "PPSSurveyForm",
getFilteredSurveys(keyword: string, orgUnitId: string): FutureData<PaginatedReponse<Survey[]>> {
return Future.success({
pager: {
page: 1,
pageSize: 2,
total: 2,
},
]);
objects: [
{
name: "TestSurvey1",
id: "1",
startDate: new Date(),
status: "ACTIVE",
assignedOrgUnit: { id: orgUnitId, name: "OU1" },
surveyType: "SUPRANATIONAL",
rootSurvey: { id: "1", name: "TestSurvey1", surveyType: "" },
surveyFormType: "PPSSurveyForm",
},
{
name: "TestSurvey2",
id: "2",
startDate: new Date(),
status: "COMPLETED",
assignedOrgUnit: { id: "OU1234", name: "OU2" },
surveyType: "NATIONAL",
rootSurvey: { id: "2", name: "TestSurvey1", surveyType: "" },
surveyFormType: "PPSSurveyForm",
},
],
});
}

deleteSurvey(orgUnitId: Id, eventId: Id, programId: Id): FutureData<void> {
Expand Down
2 changes: 1 addition & 1 deletion src/domain/repositories/SurveyRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ export interface SurveyRepository {
): FutureData<PaginatedReponse<Survey[]>>;
getPopulatedSurveyById(eventId: Id, programId: Id): FutureData<Questionnaire>;
getSurveyNameFromId(id: Id): FutureData<string | undefined>;
getFilteredSurveys(keyword: string, orgUnitId: Id): FutureData<Survey[]>;
getFilteredSurveys(keyword: string, orgUnitId: Id): FutureData<PaginatedReponse<Survey[]>>;
deleteSurvey(eventId: Id, orgUnitId: Id, programId: Id): FutureData<void>;
}
3 changes: 2 additions & 1 deletion src/domain/usecases/GetFilteredPatientsUseCase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import { Id } from "@eyeseetea/d2-api";
import { FutureData } from "../../data/api-futures";
import { Survey } from "../entities/Survey";
import { SurveyRepository } from "../repositories/SurveyRepository";
import { PaginatedReponse } from "../entities/TablePagination";

export class GetFilteredPatientsUseCase {
constructor(private surveyFormRepository: SurveyRepository) {}

public execute(keyword: string, orgUnitId: Id): FutureData<Survey[]> {
public execute(keyword: string, orgUnitId: Id): FutureData<PaginatedReponse<Survey[]>> {
return this.surveyFormRepository.getFilteredSurveys(keyword, orgUnitId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export const usePatientSurveyFilters = (
compositionRoot.surveys.getFilteredPatients
.execute(patientFilterKeyword, currentHospitalForm?.orgUnitId ?? "")
.run(
surveys => {
setSurveyList(surveys);
response => {
setSurveyList(response.objects);
setIsLoading(false);
},
() => {
Expand Down

0 comments on commit ccb0758

Please sign in to comment.