[javascript] gavno
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
- const fetchGetProfile = () => dispatch => {
- return new Promise(resolve => {
- dispatch({ type: FETCH_REQUEST })
- ServiceApi.getProfile()
- .then(response => {
- const { success, body: {
- children,
- locations,
- contracts,
- user,
- contract_acceptance_needed,
- contract_waiting_acceptance
- } } = response.data;
- if (success) {
- let blocked_diary = true;
- let blocked_booking = true;
- const filtedLocations = locations.filter(item => {
- let LocationHasContract = contracts.filter(i => i.location_id === item.id)[0]
- return LocationHasContract && item
- })
- const filtedContracts = contracts.filter(item => {
- let paramHasContract = filtedLocations.filter(i => i.id === item.location_id)[0];
- return paramHasContract && item
- })
- const filtedChildren = children.filter(item => {
- let childHasContract = filtedContracts.filter(i => i.child_id === item.id)[0]
- return childHasContract && item
- })
- const contractsList = filtedContracts.filter(item => item.archive === false)
- .map(item => {
- const contract_child_name = children.filter(child => child.id === item.child_id)[0].normal_name;
- const currentLocation = locations.filter(location => location.id === item.location_id);
- const locationOptions = currentLocation.map(item => {
- let haveParamHistory = item.features.findIndex(loc => loc === "parents_login_child_history");
- let haveParamAdvanced = item.features.findIndex(loc => loc === "parents_login_advanced");
- if (haveParamHistory >= 0 && blocked_diary) { blocked_diary = false };
- if (haveParamAdvanced >= 0 && blocked_booking) { blocked_booking = false };
- return {
- contract_location_name: item.name,
- parents_login_child_history: haveParamHistory >= 0 ? true : false,
- parents_login_advanced: haveParamAdvanced >= 0 ? true : false
- }
- })
- return ({
- ...item,
- contract_child_name: contract_child_name,
- ...locationOptions[0],
- })
- })
- const archiveContracts = contracts.filter(item => item.archive)
- .map(item => {
- const contract_child_name = children.filter(child => child.id === item.child_id)[0].normal_name;
- const currentLocation = locations.filter(location => location.id === item.location_id);
- const locationOptions = currentLocation.map(item => {
- let haveParamHistory = item.features.findIndex(loc => loc === "parents_login_child_history");
- let haveParamAdvanced = item.features.findIndex(loc => loc === "parents_login_advanced");
- if (haveParamHistory >= 0 && blocked_diary) { blocked_diary = false };
- if (haveParamAdvanced >= 0 && blocked_booking) { blocked_booking = false };
- return {
- contract_location_name: item.name,
- parents_login_child_history: haveParamHistory >= 0 ? true : false,
- parents_login_advanced: haveParamAdvanced >= 0 ? true : false
- }
- })
- return ({
- ...item,
- contract_child_name: contract_child_name,
- ...locationOptions[0],
- })
- })
- dispatch({
- type: FETCH_SUCCESS,
- payload: {
- children: filtedChildren,
- locations: filtedLocations,
- contracts: contractsList,
- archive_contracts: archiveContracts,
- user,
- blocked_diary,
- blocked_booking,
- contract_acceptance_needed,
- contract_waiting_acceptance,
- }
- })
- resolve({ language: user.language, contract_acceptance_needed })
- } else {
- dispatch({ type: FETCH_FAILURE });
- logger.error('fetchGetProfile', error);
- }
- })
- .catch(error => {
- dispatch({ type: FETCH_FAILURE })
- logger.error('fetchGetProfile', error);
- })
- })
- }
Editor
You can edit this paste and save as new:
File Description
- gavno
- Paste Code
- 01 Mar-2021
- 4.39 Kb
You can Share it:
Latest Code Pastes