-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feat/VIC-646-enable-2FA-admin-UI
- Loading branch information
Showing
67 changed files
with
16,113 additions
and
14,058 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
PORT=9000 | ||
BROWSER=none | ||
|
||
REACT_APP_CSRF_WHITELIST_HEADER_FOR_LOCAL_DEVELOPMENT=TOKEN | ||
REACT_APP_API_URL=develop.myDomain.net | ||
REACT_APP_API_URL=develop.myDomain.net | ||
|
||
# OPTIONAL | ||
|
||
# forces the usage of the api url for all api calls # e.g. useful for local development | ||
# REACT_APP_USE_API_URL=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,5 @@ yarn-debug.log* | |
yarn-error.log* | ||
/.idea/ | ||
.history | ||
|
||
.env |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { FETCH_ERRORS, FETCH_METHODS, fetchData } from "../fetchData"; | ||
import { agencyEndpointBase } from "../../appConfig"; | ||
import updateAgencyPostCodeRange from "./updateAgencyPostCodeRange"; | ||
import getConsultingType4Tenant from "../consultingtype/getConsultingType4Tenant"; | ||
|
||
function buildAgencyDataRequestBody( | ||
consultingTypeResponseId: string, | ||
formData: Record<string, any> | ||
) { | ||
return JSON.stringify({ | ||
// diocese in case of SAAS is not relevant object but enforced by API | ||
dioceseId: 0, | ||
name: formData.name, | ||
description: formData.description, | ||
postcode: formData.postcode, | ||
city: formData.city, | ||
consultingType: consultingTypeResponseId, | ||
teamAgency: formData.teamAgency ? formData.teamAgency : false, | ||
// enforced by admin API, without business value for SAAS | ||
external: false, | ||
offline: formData.offline, | ||
}); | ||
} | ||
|
||
async function createAgency(agencyDataRequestBody: string) { | ||
return fetchData({ | ||
url: agencyEndpointBase, | ||
method: FETCH_METHODS.POST, | ||
skipAuth: false, | ||
responseHandling: [FETCH_ERRORS.CATCH_ALL], | ||
bodyData: agencyDataRequestBody, | ||
}).then((addAgencyResponse) => { | ||
return addAgencyResponse.json(); | ||
}); | ||
} | ||
|
||
/** | ||
* add new agency | ||
* @param agencyData | ||
* @return data | ||
*/ | ||
async function addAgencyData(agencyData: Record<string, any>) { | ||
const consultingTypeId = await getConsultingType4Tenant(); | ||
const agencyDataRequestBody = buildAgencyDataRequestBody( | ||
consultingTypeId, | ||
agencyData | ||
); | ||
const agencyCreationResponse = await createAgency(agencyDataRequestBody); | ||
|
||
// eslint-disable-next-line no-underscore-dangle | ||
const { id } = agencyCreationResponse._embedded; | ||
return updateAgencyPostCodeRange(id, agencyData, "POST"); | ||
} | ||
|
||
export default addAgencyData; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { FETCH_ERRORS, FETCH_METHODS, fetchData } from "../fetchData"; | ||
import { agencyEndpointBase } from "../../appConfig"; | ||
import { AgencyData } from "../../types/agency"; | ||
|
||
/** | ||
* delete agency | ||
* @param agencyData | ||
* @return Promise | ||
*/ | ||
const deleteAgencyData = (agencyData: AgencyData) => { | ||
const { id } = agencyData; | ||
|
||
return fetchData({ | ||
url: `${agencyEndpointBase}/${id}`, | ||
method: FETCH_METHODS.DELETE, | ||
skipAuth: false, | ||
responseHandling: [FETCH_ERRORS.CATCH_ALL], | ||
}); | ||
}; | ||
|
||
export default deleteAgencyData; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { agencyEndpointBase } from "../../appConfig"; | ||
|
||
import { FETCH_METHODS, fetchData } from "../fetchData"; | ||
import removeEmbedded from "../../utils/removeEmbedded"; | ||
|
||
export const DEFAULT_SORT = "NAME"; | ||
export const DEFAULT_ORDER = "ASC"; | ||
|
||
/** | ||
* retrieve all agencies for tenant context | ||
* @return {Promise} | ||
*/ | ||
const getAgencyData = (params: TableState) => { | ||
// retrieve Agencies | ||
|
||
let sortBy = params.sortBy || DEFAULT_SORT; | ||
let order = params.order || DEFAULT_ORDER; | ||
|
||
sortBy = sortBy.toUpperCase(); | ||
order = order.toUpperCase(); | ||
|
||
const resolveAgencyStatus = (el: any) => { | ||
if (el.deleteDate !== "null") { | ||
return "IN_DELETION"; | ||
} | ||
return "CREATED"; | ||
}; | ||
|
||
return fetchData({ | ||
url: `${agencyEndpointBase}/?page=${params.current}&perPage=10&order=${order}&field=${sortBy}`, | ||
method: FETCH_METHODS.GET, | ||
skipAuth: false, | ||
responseHandling: [], | ||
}) | ||
.then((result) => { | ||
// eslint-disable-next-line no-underscore-dangle | ||
return removeEmbedded(result); | ||
}) | ||
.then((result) => { | ||
return { | ||
total: result.total, | ||
data: result.data.map((el: any) => { | ||
return { | ||
...el, | ||
teamAgency: el.teamAgency ? "true" : "false", | ||
status: resolveAgencyStatus(el), | ||
online: !el.offline, | ||
}; | ||
}), | ||
}; | ||
}); | ||
}; | ||
|
||
export default getAgencyData; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { FETCH_ERRORS, FETCH_METHODS, fetchData } from "../fetchData"; | ||
import { agencyPostcodeRangeEndpointBase } from "../../appConfig"; | ||
|
||
export interface PostCodeRange { | ||
from: string; | ||
until: string; | ||
} | ||
|
||
/** | ||
* get postcode ranges of an agency | ||
* @param id - agency id | ||
* @return data | ||
*/ | ||
const getAgencyPostCodeRange = (id: string) => { | ||
return fetchData({ | ||
url: `${agencyPostcodeRangeEndpointBase}/${id}`, | ||
method: FETCH_METHODS.GET, | ||
skipAuth: false, | ||
responseHandling: [FETCH_ERRORS.CATCH_ALL], | ||
}).then((data) => { | ||
const result: PostCodeRange[] = []; | ||
// eslint-disable-next-line no-underscore-dangle | ||
data._embedded.postcodeRanges.split(";").forEach((el: string) => { | ||
if (el === "") { | ||
return; | ||
} | ||
const items = el.split("-"); | ||
result.push({ | ||
from: items[0], | ||
until: items[1], | ||
}); | ||
}); | ||
|
||
return result; | ||
}); | ||
}; | ||
|
||
export default getAgencyPostCodeRange; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { FETCH_ERRORS, FETCH_METHODS, fetchData } from "../fetchData"; | ||
import { consultantsForAgencyEndpoint } from "../../appConfig"; | ||
|
||
/** | ||
* has agency consultants | ||
* @param id - agency id | ||
* @return boolean | ||
*/ | ||
const hasAgencyConsultants = (agencyId: string) => { | ||
return fetchData({ | ||
url: `${consultantsForAgencyEndpoint}`.replaceAll("{agencyId}", agencyId), | ||
method: FETCH_METHODS.GET, | ||
skipAuth: false, | ||
responseHandling: [FETCH_ERRORS.CATCH_ALL], | ||
}).then((data) => { | ||
return data.total > 0; | ||
}); | ||
}; | ||
|
||
export default hasAgencyConsultants; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { FETCH_ERRORS, FETCH_METHODS, fetchData } from "../fetchData"; | ||
import { agencyEndpointBase } from "../../appConfig"; | ||
import { AgencyData } from "../../types/agency"; | ||
import updateAgencyPostCodeRange from "./updateAgencyPostCodeRange"; | ||
import updateAgencyType from "./updateAgencyType"; | ||
import getConsultingType4Tenant from "../consultingtype/getConsultingType4Tenant"; | ||
|
||
/** | ||
* update agency | ||
* @param agencyModel - agency data from backend | ||
* @param formInput - input data from form | ||
* @return data | ||
*/ | ||
const updateAgencyData = async ( | ||
agencyModel: AgencyData, | ||
formInput: AgencyData | ||
) => { | ||
const agencyId = agencyModel.id; | ||
if (agencyId == null) { | ||
throw Error("agency id must be set"); | ||
} | ||
|
||
await updateAgencyType(agencyModel, formInput); | ||
await updateAgencyPostCodeRange(agencyId, formInput, "PUT"); | ||
|
||
const consultingTypeId = await getConsultingType4Tenant(); | ||
const agencyDataRequestBody = { | ||
dioceseId: 0, | ||
name: formInput.name, | ||
description: formInput.description, | ||
postcode: formInput.postcode, | ||
city: formInput.city, | ||
consultingType: consultingTypeId, | ||
offline: !formInput.online, | ||
external: false, | ||
}; | ||
return fetchData({ | ||
url: `${agencyEndpointBase}/${agencyModel.id}`, | ||
method: FETCH_METHODS.PUT, | ||
skipAuth: false, | ||
responseHandling: [FETCH_ERRORS.CATCH_ALL], | ||
bodyData: JSON.stringify(agencyDataRequestBody), | ||
}); | ||
}; | ||
|
||
export default updateAgencyData; |
Oops, something went wrong.