Skip to content

Commit

Permalink
remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
RenauxLeaInsee committed Jun 5, 2024
1 parent 9c99ef7 commit 5fe425e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 84 deletions.
50 changes: 0 additions & 50 deletions src/Authentication/oidc.js

This file was deleted.

70 changes: 36 additions & 34 deletions src/utils/Service.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { NotificationManager } from "react-notifications";
import D from "../i18n";

const baseUrlPearlJam = `${window.localStorage.getItem("PEARL_JAM_URL")}`;
const baseUrlQueen = `${window.localStorage.getItem("QUEEN_URL_BACK_END")}`;

class Service {
constructor(token) {
this.token = token;
this.baseUrlPearlJam = `${window.localStorage.getItem("PEARL_JAM_URL")}`;
this.baseUrlQueen = `${window.localStorage.getItem("QUEEN_URL_BACK_END")}`;
}
makeOptions() {
if (this.token && this.token !== "accessToken") {
Expand All @@ -29,7 +31,7 @@ class Service {
getSurveyUnits(campaignId, state, cb) {
return new Promise((resolve) => {
fetch(
`${this.baseUrlPearlJam}/api/campaign/${campaignId}/survey-units?${
`${baseUrlPearlJam}/api/campaign/${campaignId}/survey-units?${
state ? `state=${state}` : ""
}`,
this.makeOptions()
Expand All @@ -53,7 +55,7 @@ class Service {
}

async getSurveyUnitsQuestionnaireId(listSurveyUnitIds, cb) {
return fetch(`${this.baseUrlPearlJam}/api/survey-units/questionnaire-model-id`, {
return fetch(`${baseUrlQueen}/api/survey-units/questionnaire-model-id`, {
...this.makeOptions(),
method: "POST",
body: JSON.stringify(listSurveyUnitIds),
Expand All @@ -74,7 +76,7 @@ class Service {
}

getSurveyUnitsClosable(cb) {
fetch(`${this.baseUrlPearlJam}/api/survey-units/closable`, this.makeOptions())
fetch(`${baseUrlPearlJam}/api/survey-units/closable`, this.makeOptions())
.then((res) => res.json())
.then((data) => {
cb(data);
Expand All @@ -91,7 +93,7 @@ class Service {

getSurveyUnitsNotAttributedByCampaign(campaignId, cb) {
fetch(
`${this.baseUrlPearlJam}/api/campaign/${campaignId}/survey-units/not-attributed`,
`${baseUrlPearlJam}/api/campaign/${campaignId}/survey-units/not-attributed`,
this.makeOptions()
)
.then((res) => res.json())
Expand All @@ -106,7 +108,7 @@ class Service {

getSurveyUnitsAbandonedByCampaign(campaignId, cb) {
fetch(
`${this.baseUrlPearlJam}/api/campaign/${campaignId}/survey-units/abandoned`,
`${baseUrlPearlJam}/api/campaign/${campaignId}/survey-units/abandoned`,
this.makeOptions()
)
.then((res) => res.json())
Expand All @@ -120,7 +122,7 @@ class Service {
}

getStatesBySurveyUnit(su, cb) {
fetch(`${this.baseUrlPearlJam}/api/survey-unit/${su}/states`, this.makeOptions())
fetch(`${baseUrlPearlJam}/api/survey-unit/${su}/states`, this.makeOptions())
.then((res) => res.json())
.then((data) => {
cb(data);
Expand All @@ -139,7 +141,7 @@ class Service {
const options = {};
Object.assign(options, this.makeOptions());
options.method = "PUT";
fetch(`${this.baseUrlPearlJam}/api/survey-unit/${su}/state/FIN`, options)
fetch(`${baseUrlPearlJam}/api/survey-unit/${su}/state/FIN`, options)
.then((res) => cb(res))
.catch((e) => {
console.error(e);
Expand All @@ -151,7 +153,7 @@ class Service {
const options = {};
Object.assign(options, this.makeOptions());
options.method = "PUT";
fetch(`${this.baseUrlPearlJam}/api/survey-unit/${su}/state/${state}`, options)
fetch(`${baseUrlPearlJam}/api/survey-unit/${su}/state/${state}`, options)
.then((res) => cb(res))
.catch((e) => {
console.error(e);
Expand All @@ -164,7 +166,7 @@ class Service {
Object.assign(options, this.makeOptions());
options.method = "PUT";
fetch(
`${this.baseUrlPearlJam}/api/survey-unit/${su}/close/${closingCause}`,
`${baseUrlPearlJam}/api/survey-unit/${su}/close/${closingCause}`,
options
)
.then((res) => cb(res))
Expand All @@ -179,7 +181,7 @@ class Service {
Object.assign(options, this.makeOptions());
options.method = "PUT";
fetch(
`${this.baseUrlPearlJam}/api/survey-unit/${su}/closing-cause/${closingCause}`,
`${baseUrlPearlJam}/api/survey-unit/${su}/closing-cause/${closingCause}`,
options
)
.then((res) => cb(res))
Expand All @@ -194,7 +196,7 @@ class Service {
Object.assign(options, this.makeOptions());
options.method = "PUT";
options.body = JSON.stringify(comment);
fetch(`${this.baseUrlPearlJam}/api/survey-unit/${su}/comment`, options)
fetch(`${baseUrlPearlJam}/api/survey-unit/${su}/comment`, options)
.then((res) => cb(res))
.catch((e) => {
console.error(e);
Expand All @@ -206,7 +208,7 @@ class Service {
const options = {};
Object.assign(options, this.makeOptions());
options.method = "PUT";
fetch(`${this.baseUrlPearlJam}/api/survey-unit/${su}/viewed`, options)
fetch(`${baseUrlPearlJam}/api/survey-unit/${su}/viewed`, options)
.then((res) => cb(res))
.catch((e) => {
console.error(e);
Expand All @@ -225,7 +227,7 @@ class Service {
Object.assign(options, this.makeOptions());
options.method = "PUT";
options.body = JSON.stringify(preferences);
fetch(`${this.baseUrlPearlJam}/api/preferences`, options)
fetch(`${baseUrlPearlJam}/api/preferences`, options)
.then((res) => cb(res))
.catch(console.error);
}
Expand All @@ -238,7 +240,7 @@ class Service {
// -------------------- //
getUser(cb) {
return new Promise((resolve) => {
fetch(`${this.baseUrlPearlJam}/api/user`, this.makeOptions())
fetch(`${baseUrlPearlJam}/api/user`, this.makeOptions())
.then((res) => res.json())
.then((data) => {
if (cb) {
Expand Down Expand Up @@ -267,7 +269,7 @@ class Service {
// Campaigns service begin //
// ----------------------- //
getCampaigns(cb) {
fetch(`${this.baseUrlPearlJam}/api/campaigns`, this.makeOptions())
fetch(`${baseUrlPearlJam}/api/campaigns`, this.makeOptions())
.then((res) => res.json())
.then((data) => {
cb(data);
Expand All @@ -285,7 +287,7 @@ class Service {
getCampaignsByInterviewer(idep, cb) {
return new Promise((resolve) => {
fetch(
`${this.baseUrlPearlJam}/api/interviewer/${idep}/campaigns`,
`${baseUrlPearlJam}/api/interviewer/${idep}/campaigns`,
this.makeOptions()
)
.then((res) => res.json())
Expand Down Expand Up @@ -314,7 +316,7 @@ class Service {
getStateCount(campaignId, date, cb) {
return new Promise((resolve) => {
fetch(
`${this.baseUrlPearlJam}/api/campaign/${campaignId}/survey-units/state-count?date=${date}`,
`${baseUrlPearlJam}/api/campaign/${campaignId}/survey-units/state-count?date=${date}`,
this.makeOptions()
)
.then((res) => res.json())
Expand All @@ -333,7 +335,7 @@ class Service {
getStateCountNotAttributed(campaignId, date, cb) {
return new Promise((resolve) => {
fetch(
`${this.baseUrlPearlJam}/api/campaign/${campaignId}/survey-units/not-attributed/state-count?date=${date}`,
`${baseUrlPearlJam}/api/campaign/${campaignId}/survey-units/not-attributed/state-count?date=${date}`,
this.makeOptions()
)
.then((res) => res.json())
Expand All @@ -356,7 +358,7 @@ class Service {
getStateCountByInterviewer(campaignId, idep, date, cb) {
return new Promise((resolve) => {
fetch(
`${this.baseUrlPearlJam}/api/campaign/${campaignId}/survey-units/interviewer/${idep}/state-count?date=${date}`,
`${baseUrlPearlJam}/api/campaign/${campaignId}/survey-units/interviewer/${idep}/state-count?date=${date}`,
this.makeOptions()
)
.then((res) => res.json())
Expand All @@ -379,7 +381,7 @@ class Service {
getStateCountByCampaign(date, cb) {
return new Promise((resolve) => {
fetch(
`${this.baseUrlPearlJam}/api/campaigns/survey-units/state-count?date=${date}`,
`${baseUrlPearlJam}/api/campaigns/survey-units/state-count?date=${date}`,
this.makeOptions()
)
.then((res) => res.json())
Expand All @@ -397,7 +399,7 @@ class Service {

getStateCountTotalByCampaign(campaignId, cb) {
fetch(
`${this.baseUrlPearlJam}/api/campaign/${campaignId}/survey-units/state-count`,
`${baseUrlPearlJam}/api/campaign/${campaignId}/survey-units/state-count`,
this.makeOptions()
)
.then((res) => res.json())
Expand All @@ -423,7 +425,7 @@ class Service {
getContactOutcomes(campaignId, date, cb) {
return new Promise((resolve) => {
fetch(
`${this.baseUrlPearlJam}/api/campaign/${campaignId}/survey-units/contact-outcomes?date=${date}`,
`${baseUrlPearlJam}/api/campaign/${campaignId}/survey-units/contact-outcomes?date=${date}`,
this.makeOptions()
)
.then((res) => res.json())
Expand All @@ -442,7 +444,7 @@ class Service {
getContactOutcomesNotAttributed(campaignId, date, cb) {
return new Promise((resolve) => {
fetch(
`${this.baseUrlPearlJam}/api/campaign/${campaignId}/survey-units/not-attributed/contact-outcomes?date=${date}`,
`${baseUrlPearlJam}/api/campaign/${campaignId}/survey-units/not-attributed/contact-outcomes?date=${date}`,
this.makeOptions()
)
.then((res) => res.json())
Expand All @@ -465,7 +467,7 @@ class Service {
getContactOutcomesByInterviewer(campaignId, idep, date, cb) {
return new Promise((resolve) => {
fetch(
`${this.baseUrlPearlJam}/api/campaign/${campaignId}/survey-units/interviewer/${idep}/contact-outcomes?date=${date}`,
`${baseUrlPearlJam}/api/campaign/${campaignId}/survey-units/interviewer/${idep}/contact-outcomes?date=${date}`,
this.makeOptions()
)
.then((res) => res.json())
Expand All @@ -488,7 +490,7 @@ class Service {
getContactOutcomesByCampaign(date, cb) {
return new Promise((resolve) => {
fetch(
`${this.baseUrlPearlJam}/api/campaigns/survey-units/contact-outcomes?date=${date}`,
`${baseUrlPearlJam}/api/campaigns/survey-units/contact-outcomes?date=${date}`,
this.makeOptions()
)
.then((res) => res.json())
Expand All @@ -513,7 +515,7 @@ class Service {
getClosingCausesByInterviewer(campaignId, idep, date, cb) {
return new Promise((resolve) => {
fetch(
`${this.baseUrlPearlJam}/api/campaign/${campaignId}/survey-units/interviewer/${idep}/closing-causes?date=${date}`,
`${baseUrlPearlJam}/api/campaign/${campaignId}/survey-units/interviewer/${idep}/closing-causes?date=${date}`,
this.makeOptions()
)
.then((res) => res.json())
Expand All @@ -540,7 +542,7 @@ class Service {
// Interviewers service begin //
// --------------------------- //
getInterviewers(cb) {
fetch(`${this.baseUrlPearlJam}/api/interviewers`, this.makeOptions())
fetch(`${baseUrlPearlJam}/api/interviewers`, this.makeOptions())
.then((res) => res.json())
.then((data) => {
cb(data);
Expand All @@ -554,7 +556,7 @@ class Service {
getInterviewersByCampaign(campaignId, cb) {
return new Promise((resolve) => {
fetch(
`${this.baseUrlPearlJam}/api/campaign/${campaignId}/interviewers`,
`${baseUrlPearlJam}/api/campaign/${campaignId}/interviewers`,
this.makeOptions()
)
.then((res) => res.json())
Expand All @@ -576,7 +578,7 @@ class Service {
// ----------------------------- //
getQuestionnaireId(campaignId, cb) {
fetch(
`${this.baseUrlPearlJam}/api/campaign/${campaignId}/questionnaire-id`,
`${baseUrlQueen}/api/campaign/${campaignId}/questionnaire-id`,
this.makeOptions()
)
.then((res) => res.json())
Expand All @@ -601,7 +603,7 @@ class Service {
options.method = "POST";
options.body = JSON.stringify(body);

fetch(`${this.baseUrlPearlJam}/api/message`, options).then((data) => {
fetch(`${baseUrlPearlJam}/api/message`, options).then((data) => {
cb(data);
});
}
Expand All @@ -612,7 +614,7 @@ class Service {
options.method = "POST";
options.body = JSON.stringify({ text });

fetch(`${this.baseUrlPearlJam}/api/verify-name`, options)
fetch(`${baseUrlPearlJam}/api/verify-name`, options)
.then((res) => res.json())
.then((data) => {
cb(data);
Expand All @@ -624,7 +626,7 @@ class Service {
}

getMessageHistory(cb) {
fetch(`${this.baseUrlPearlJam}/api/message-history`, this.makeOptions())
fetch(`${baseUrlPearlJam}/api/message-history`, this.makeOptions())
.then((res) => res.json())
.then((data) => {
cb(data);
Expand Down

0 comments on commit 5fe425e

Please sign in to comment.