Skip to content

Commit

Permalink
fix(filtre): fix filtre campaign
Browse files Browse the repository at this point in the history
  • Loading branch information
lailabjil committed Dec 12, 2023
1 parent fba5c81 commit b8f4970
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 15 deletions.
9 changes: 3 additions & 6 deletions src/pages/surveys-overview/SurveysOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,10 @@ const SurveysOverviewPage = () => {
setCampaingFilter(value);
campaingFilter = value;

if (value) {
if (value && value != "all") {
const newSearchResult = searchResult?.filter(
(houseHoldData: any) => houseHoldData.campaingId == value,
);
console.log(searchResult, value, newSearchResult);
sortSearchResult(newSearchResult);
setSearchResult(newSearchResult);

Expand All @@ -172,10 +171,8 @@ const SurveysOverviewPage = () => {
);
setFilterValidatedResult(newFilterValidatedResult);
} else {
const newSearchResult = searchResult?.concat(filterValidatedResult);
sortSearchResult(newSearchResult);
setSearchResult(newSearchResult);
onFilterSearchBox;
sortSearchResult(searchResult);
setSearchResult(searchResult);
}
},
[searchResult, filterValidatedResult, campaingFilter],
Expand Down
39 changes: 30 additions & 9 deletions src/service/api-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ export const fetchReferentiels = (
axios
.all(
refsEndPoints.map(endPoint =>
axios.get(stromaeBackOfficeApiBaseUrl + endPoint, getHeader(stromaeBackOfficeApiBaseUrl)),
axios.get(
stromaeBackOfficeApiBaseUrl + endPoint,
getHeader(stromaeBackOfficeApiBaseUrl),
),
),
)
.then(res => {
Expand All @@ -87,7 +90,10 @@ export const fetchReferentiels = (
const fetchUserSurveysInfo = (setError: (error: ErrorCodeEnum) => void): Promise<UserSurveys[]> => {
return new Promise(resolve => {
axios
.get(edtOrganisationApiBaseUrl + "api/survey-assigment/interviewer/my-surveys", getHeader(edtOrganisationApiBaseUrl))
.get(
edtOrganisationApiBaseUrl + "api/survey-assigment/interviewer/my-surveys",
getHeader(edtOrganisationApiBaseUrl),
)
.then(response => {
const data: UserSurveys[] = response.data;
resolve(data);
Expand All @@ -113,7 +119,10 @@ const fetchSurveysSourcesByIds = (
axios
.all(
sourcesEndPoints.map(endPoint =>
axios.get(stromaeBackOfficeApiBaseUrl + endPoint, getHeader(stromaeBackOfficeApiBaseUrl)),
axios.get(
stromaeBackOfficeApiBaseUrl + endPoint,
getHeader(stromaeBackOfficeApiBaseUrl),
),
),
)
.then(res => {
Expand All @@ -135,7 +144,10 @@ const fetchSurveysSourcesByIds = (
const fetchReviewerSurveysAssignments = (setError: (error: ErrorCodeEnum) => void): Promise<any> => {
return new Promise(resolve => {
axios
.get(edtOrganisationApiBaseUrl + "api/survey-assigment/reviewer/my-surveys", getHeader(edtOrganisationApiBaseUrl))
.get(
edtOrganisationApiBaseUrl + "api/survey-assigment/reviewer/my-surveys",
getHeader(edtOrganisationApiBaseUrl),
)
.then(response => {
resolve(response.data);
})
Expand All @@ -156,7 +168,11 @@ const requestPutSurveyData = (
): Promise<SurveyData> => {
return new Promise<SurveyData>(resolve => {
axios
.put(stromaeBackOfficeApiBaseUrl + "api/survey-unit/" + idSurvey, data, getHeader(stromaeBackOfficeApiBaseUrl, token))
.put(
stromaeBackOfficeApiBaseUrl + "api/survey-unit/" + idSurvey,
data,
getHeader(stromaeBackOfficeApiBaseUrl, token),
)
.then(() => {
resolve(data);
});
Expand Down Expand Up @@ -289,7 +305,10 @@ const remoteGetSurveyData = (
): Promise<SurveyData> => {
return new Promise(resolve => {
axios
.get(stromaeBackOfficeApiBaseUrl + "api/survey-unit/" + idSurvey, getHeader(stromaeBackOfficeApiBaseUrl))
.get(
stromaeBackOfficeApiBaseUrl + "api/survey-unit/" + idSurvey,
getHeader(stromaeBackOfficeApiBaseUrl),
)
.then(response => {
resolve(response.data);
})
Expand All @@ -309,7 +328,10 @@ const requestGetDataReviewer = (
): Promise<LunaticData> => {
return new Promise<LunaticData>(resolve => {
axios
.get(stromaeBackOfficeApiBaseUrl + "api/survey-unit/" + idSurvey + "/data", getHeader(stromaeBackOfficeApiBaseUrl))
.get(
stromaeBackOfficeApiBaseUrl + "api/survey-unit/" + idSurvey + "/data",
getHeader(stromaeBackOfficeApiBaseUrl),
)
.then(response => {
if (response.data?.data != null) {
resolve(response.data.data);
Expand Down Expand Up @@ -403,6 +425,5 @@ export {
remoteGetSurveyData,
remoteGetSurveyDataReviewer,
remotePutSurveyData,
remotePutSurveyDataReviewer
remotePutSurveyDataReviewer,
};

0 comments on commit b8f4970

Please sign in to comment.