Skip to content

Commit

Permalink
Merge branch 'main' of github.com:WWWPiramalFinanceCOM/piramalfinance
Browse files Browse the repository at this point in the history
  • Loading branch information
omprakashgupta1995 committed Oct 14, 2024
2 parents ffe6d3c + 9a6a4dd commit 7eaf8ad
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 103 deletions.
9 changes: 1 addition & 8 deletions blocks/applyloanform/applyloanform.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { validationJSFunc } from './validation.js';
import AirDatepicker from '../datepickerlib/datepickerlib.js';
import Popper from '../datepickerlib/popper.js';
import { buttonCLick } from './loanformapi.js';
import { fetchAPI } from '../../scripts/scripts.js';
import { CFApiCall, fetchAPI } from '../../scripts/scripts.js';

export default async function decorate(block) {
const cfURL = block.textContent.trim();
Expand All @@ -32,13 +32,6 @@ export default async function decorate(block) {
}
}

export async function CFApiCall(cfurl) {
const response = await fetchAPI('GET', cfurl);
const responseJson = await response.json();
return responseJson;
}


function applyLoanFormJson(data) {
var mainObj = {};

Expand Down
14 changes: 4 additions & 10 deletions blocks/aprcalculator/aprcalculator.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { fetchAPI } from '../../scripts/scripts.js';
import { calculatorFlatStrLogic, CFApiCall, fetchAPI } from '../../scripts/scripts.js';
import { homeLoanCalcFunc } from '../emiandeligiblitycalc/homeloancalculators.js';
import { homeloanCalHTML } from '../homeloancalculatorv2/templatehtmlv2.js';

export default async function decorate(block) {
const cfURL = block.textContent.trim();

const cfRepsonse = await CFApiCall(cfURL);
const repsonseData = cfRepsonse.data[0].data;
const jsonResponseData = JSON.parse(repsonseData);
const cfRepsonse = cfURL && await CFApiCall(cfURL);
const repsonseData = cfRepsonse.data;
const jsonResponseData = calculatorFlatStrLogic(repsonseData);

block.innerHTML = homeloanCalHTML(jsonResponseData);

Expand All @@ -34,12 +34,6 @@ export default async function decorate(block) {
}
}

export async function CFApiCall(cfurl) {
const response = await fetchAPI('GET', cfurl);
const responseJson = await response.json();
return responseJson;
}

function onloadAPRCalc() {
const isAprCalculator = document.querySelector('.homeloancalculator .apr');
if (isAprCalculator) {
Expand Down
9 changes: 2 additions & 7 deletions blocks/authorisedagencies/authorisedagencies.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { fetchAPI, targetObject } from '../../scripts/scripts.js';
import { CFApiCall, fetchAPI, targetObject } from '../../scripts/scripts.js';
import { ctaClickInteraction } from '../../dl.js';

export default async function decorate(block) {
const cfURL = block.textContent.trim();
const cfRepsonse = await fetchApiCall(cfURL);
const cfRepsonse = await CFApiCall(cfURL);
const repsonseData = cfRepsonse.data;
const result = Object.groupBy(repsonseData, ({ Location }) => {
const lowercaseLocation = Location.toLowerCase();
Expand Down Expand Up @@ -158,8 +158,3 @@ export default async function decorate(block) {
// })
};
}
export async function fetchApiCall(cfurl) {
const response = await fetchAPI('GET', cfurl);
const responseJson = await response.json();
return responseJson;
}
7 changes: 1 addition & 6 deletions blocks/branchcarousel/branchcarousel.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fetchAPI } from '../../scripts/scripts.js';
import { CFApiCall, fetchAPI } from '../../scripts/scripts.js';
import { setLocationObj } from '../moredetailsaddress/moredetailsaddress.js';

export default async function decorate(block) {
Expand All @@ -25,8 +25,3 @@ export default async function decorate(block) {
block.classList.add('dp-none');
}

export async function CFApiCall(linkURL) {
const response = await fetchAPI('GET', linkURL);
const responseJson = await response.json();
return responseJson;
}
8 changes: 1 addition & 7 deletions blocks/branchkeyfeatures/branchkeyfeatures.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fetchAPI } from '../../scripts/scripts.js';
import { CFApiCall, fetchAPI } from '../../scripts/scripts.js';
import { featureDropDownClick } from '../keyfeatures/keyfeatures.js';
import { setLocationObj } from '../moredetailsaddress/moredetailsaddress.js';

Expand Down Expand Up @@ -52,9 +52,3 @@ export default async function decorate(block) {

block.classList.add('dp-none');
}

export async function CFApiCall(linkURL) {
const response = await fetchAPI('GET', linkURL);
const responseJson = await response.json();
return responseJson;
}
5 changes: 5 additions & 0 deletions blocks/branchlocator/branchlocator-biz.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ async function getStateCity(lat, lng) {
setLocationObj.geoInfo.city = city.long_name;
setLocationObj.geoInfo.state = region.long_name;
setLocationObj.geoInfo.country = country.long_name;

/* setLocationObj.getExcelData[region.long_name].filter((each) => {
return each['Location'].includes(city.long_name);
}); */

resolve();
} else {
reject('No results found');
Expand Down
8 changes: 1 addition & 7 deletions blocks/branchlocator/branchlocator.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { branchURLStr, fetchAPI } from '../../scripts/scripts.js';
import { branchURLStr, CFApiCall, fetchAPI } from '../../scripts/scripts.js';
import { dropDownStateCity, locateMeClick, onloadBranchLocator } from './branchlocator-biz.js';
import { setLocationObj } from './branchlocator-init.js';

Expand Down Expand Up @@ -93,12 +93,6 @@ export function innerBranchFunc(branchhList) {
return innerBranch;
}

export async function CFApiCall(cfurl) {
const response = await fetchAPI('GET', cfurl);
const responseJson = await response.json();
return responseJson;
}

export default async function decorate(block) {
const props = Array.from(block.children, (row) => row.firstElementChild);

Expand Down
14 changes: 4 additions & 10 deletions blocks/calculatorsection/calculatorsection.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { fetchAPI } from '../../scripts/scripts.js';
import { calculatorFlatStrLogic, CFApiCall, fetchAPI } from '../../scripts/scripts.js';
import { homeLoanCalcFunc } from '../emiandeligiblitycalc/homeloancalculators.js';
import { renderCalculatorData } from './renderdatafunc.js';
import { homeloanCalHTML } from '../homeloancalculatorv2/templatehtmlv2.js';

export default async function decorate(block) {
const cfURL = block.textContent.trim();

const cfRepsonse = await CFApiCall(cfURL);
const repsonseData = cfRepsonse.data[0].data;
const jsonResponseData = JSON.parse(repsonseData);
const cfRepsonse = cfURL && await CFApiCall(cfURL);
const repsonseData = cfRepsonse.data;
const jsonResponseData = calculatorFlatStrLogic(repsonseData);

block.innerHTML = homeloanCalHTML(jsonResponseData);

Expand Down Expand Up @@ -39,12 +39,6 @@ export default async function decorate(block) {
}
}

export async function CFApiCall(cfurl) {
const response = await fetchAPI('GET', cfurl);
const responseJson = await response.json();
return responseJson;
}

export function readMoreFucn(block) {
document.querySelector('.discalimer-details').classList.remove('dp-none');
if (block.querySelector('.discalimer-calc')) {
Expand Down
16 changes: 5 additions & 11 deletions blocks/gstcalculator/gstcalculator.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { currenyCommaSeperation, fetchAPI } from '../../scripts/scripts.js';
import { calculatorFlatStrLogic, CFApiCall, currenyCommaSeperation, fetchAPI } from '../../scripts/scripts.js';
import { homeLoanCalcFunc } from '../emiandeligiblitycalc/homeloancalculators.js';
import { homeloanCalHTML } from '../homeloancalculatorv2/templatehtmlv2.js';

export default async function decorate(block) {
const cfURL = block.textContent.trim();

const cfRepsonse = await CFApiCall(cfURL);
const repsonseData = cfRepsonse.data[0].data;
const jsonResponseData = JSON.parse(repsonseData);
const cfRepsonse = cfURL && await CFApiCall(cfURL);
const repsonseData = cfRepsonse.data;
const jsonResponseData = calculatorFlatStrLogic(repsonseData);

block.innerHTML = homeloanCalHTML(jsonResponseData);

let elgCalDiv; let
elgOverlay;
let elgCalDiv; let elgOverlay;

try {
elgCalDiv = document.querySelector('.home-page-calculator-call-xf');
Expand All @@ -34,11 +33,6 @@ export default async function decorate(block) {
}
}

export async function CFApiCall(cfurl) {
const response = await fetchAPI('GET', cfurl);
const responseJson = await response.json();
return responseJson;
}

function onloadGSTCalc() {
const isGstCalculator = document.querySelector('.homeloancalculator .gst');
Expand Down
15 changes: 4 additions & 11 deletions blocks/homeloancalculatorv2/homeloancalculatorv2.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@ import { firstTabActive } from "./commonfile.js"; */
import { homeloanCalHTML } from './templatehtmlv2.js';
import { homeLoanCalcFunc } from './homeloancalculators.js';
import { calculatorTypeTabClick, mainTabClick, renderEmiEligibility } from './combineemieligibility.js';
import { fetchAPI } from '../../scripts/scripts.js';
import { calculatorFlatStrLogic, CFApiCall, fetchAPI } from '../../scripts/scripts.js';

let calculatorType; let emiCalDiv; let
emiOverlay;
let calculatorType; let emiCalDiv; let emiOverlay;

export default async function decorate(block) {
const cfURL = block.textContent.trim();

const cfRepsonse = cfURL && await CFApiCall(cfURL);
const repsonseData = cfRepsonse && cfRepsonse.data[0].data;
const jsonResponseData = repsonseData && JSON.parse(repsonseData);
const repsonseData = cfRepsonse.data;
const jsonResponseData = calculatorFlatStrLogic(repsonseData);

if (!jsonResponseData) return;

Expand Down Expand Up @@ -63,12 +62,6 @@ export default async function decorate(block) {
}
}

export async function CFApiCall(cfurl) {
// const cfModification = cfurl?.replace("/content/dam/", "/api/assets/");
const response = await fetchAPI('GET', cfurl);
const responseJson = await response.json();
return responseJson;
}

/* export function homeLoancalculatorCallXf() {
document.querySelectorAll("[data-teaserv2-xf='home-page-calculator-call-xf']") &&
Expand Down
12 changes: 6 additions & 6 deletions blocks/homeloancalculatorv2/templatehtmlv2.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function homeloanCalHTML(callJson) {
buttonLink2 = callJson.button2link.replace('DWEB', 'MWEB');
}

const salaried = callJson.salaried?.salariedcheck
const salaried = callJson.salaried?.salariedcheck == 'true'
? `
<li id="salaryTab" class="firsttab onetab">
<div class="customecheck">
Expand All @@ -32,7 +32,7 @@ export function homeloanCalHTML(callJson) {
</li>`
: '';

const business = callJson.business?.businesscheck
const business = callJson.business?.businesscheck == 'true'
? `
<li id="${callJson.business.businesstabid}" class="firsttab secondtab twotab">
<div class="customecheck">
Expand All @@ -59,7 +59,7 @@ export function homeloanCalHTML(callJson) {
: '';

let emiinputdiv = '';
callJson.chechboxemiobj.chechboxemi
callJson.chechboxemiobj.chechboxemi == 'true'
&& callJson.chechboxemiobj.loanamout.forEach((each, index) => {
emiinputdiv += `<div class="loanamount">
<div class="data">
Expand Down Expand Up @@ -89,7 +89,7 @@ export function homeloanCalHTML(callJson) {
});

let eligibilityinputdiv = '';
callJson.chechboxelibilityobj.chechboxemi
callJson.chechboxelibilityobj.chechboxemi == 'true'
&& callJson.chechboxelibilityobj.loanamout.forEach((each, index) => {
eligibilityinputdiv += `<div class="loanamount">
<div class="data">
Expand Down Expand Up @@ -135,7 +135,7 @@ export function homeloanCalHTML(callJson) {
</div>`
: '';

const emidiv = callJson.chechboxemiobj.chechboxemi
const emidiv = callJson.chechboxemiobj.chechboxemi == 'true'
? `
<div class="emicalculator commoncalculator">
<div class="parent-emi" id="emic">
Expand Down Expand Up @@ -167,7 +167,7 @@ export function homeloanCalHTML(callJson) {
</div>`
: '';

const eligibilitydiv = callJson.chechboxelibilityobj.chechboxemi
const eligibilitydiv = callJson.chechboxelibilityobj.chechboxemi == 'true'
? `
<div class="eligibilitycalculator calculator commoncalculator">
<div class="parent-emi parent-eligibility" id="emic">
Expand Down
7 changes: 1 addition & 6 deletions blocks/moredetailsaddress/moredetailsaddress.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fetchAPI, getDay } from '../../scripts/scripts.js';
import { CFApiCall, fetchAPI, getDay } from '../../scripts/scripts.js';

export const setLocationObj = {};
const locationInLatLan = {};
Expand Down Expand Up @@ -156,11 +156,6 @@ async function getReviewRating(placeID) {
});
}

export async function CFApiCall(cfurl) {
const response = await fetchAPI('GET', cfurl);
const responseJson = await response.json();
return responseJson;
}

/* async function onbranchDetails(block) {
let locationCodeURL = location.href.split("/").pop().split("-").pop();
Expand Down
8 changes: 1 addition & 7 deletions blocks/partpaymentcalculator/partpaymentcalculator.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fetchAPI } from '../../scripts/scripts.js';
import { CFApiCall, fetchAPI } from '../../scripts/scripts.js';
import { homeLoanCalcFunc } from '../emiandeligiblitycalc/homeloancalculators.js';
import { onloadDatePickerCalls } from './partpaymentdatepicker.js';
import { partPaymentCalHTML } from './partpaymenttemplate.js';
Expand Down Expand Up @@ -35,12 +35,6 @@ export default async function decorate(block) {
}
}

export async function CFApiCall(cfurl) {
const response = await fetchAPI('GET', cfurl);
const responseJson = await response.json();
return responseJson;
}

function readMoreFucn(block) {
document.querySelector('.discalimer-details').classList.remove('dp-none');
if (block.querySelector('.discalimer-calc')) {
Expand Down
10 changes: 3 additions & 7 deletions blocks/sarfaesiretail/sarfaesiretail.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { fetchAPI } from '../../scripts/scripts.js';
import { CFApiCall, fetchAPI } from '../../scripts/scripts.js';

export default async function decorate(block) {
const cfURL = block.textContent.trim();
const cfRepsonse = await fetchApiCall(cfURL);
const cfRepsonse = await CFApiCall(cfURL);
const repsonseData = cfRepsonse.data;

const headers = Object.keys(repsonseData[0]);
Expand All @@ -25,8 +25,4 @@ export default async function decorate(block) {

block.innerHTML = `${tableHTML}`;
}
async function fetchApiCall(cfurl) {
const response = await fetchAPI('GET', cfurl);
const responseJson = await response.json();
return responseJson;
}

0 comments on commit 7eaf8ad

Please sign in to comment.