someimportantlinks

how to find url:

const url = window.location.href

    var regex = /[?&]([^=#]+)=([^&#]*)/g,

        params = {},

        match;

    while (match = regex.exec(url)) {

        params[match[1]] = match[2];

    }

    if (params.key1) {

        if((params.key1).length>30){

          console.log(params.key1,params.key);

          Variables.set_authToken('Token ' + params.key1);

          Variables.set_patientSlug(params.key2);

        

          localStorage.setItem('token', params.key1);

        localStorage.setItem('patient_slug', params.key2);



        }

        else{

            localStorage.setItem('token', params.key2);

            localStorage.setItem('patient_slug', params.key1);

        }

        Variables.set_Base_Url(params.key3)

    

    }


pagination

import Pagination from '@mui/material/Pagination';

from api:

firsttime:--

const getProviderList = async (pageno) => {

    setLoading(true)

    try {

        let response = await fetch(Variables.get_Base_Url() + `/api/hospital-app/discount_card/get_nearest_providers_discount_card_services/` + pageno + '/',

setpage(json.total_pages)

console.log(page);

........................after button click................

 const pageChangeHandler=(event,value)=>{

// console.log(value);

getProviderList (value);

  }

{ page&&<div >

            <Pagination count={page} onChange={pageChangeHandler} shape="rounded" style={{position:'relative',left:'20vw'}} />


validationfor name:

let pattern = /^[a-zA-Z]{1,40}( {1,2}[a-zA-Z]{1,40})+$/;

 if (pattern.test(fullname.trim()) === false)

   let emailreg = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;

    if (emailreg.test(email) === false || email === "") {

      setAlertValue('Please enter the Correct Email');


payment getway:-----

handlePressButtonAsync(json.merchant_key, json.txn_id, json.payment_hash, json.surl, json.furl, json.curl);



const handlePressButtonAsync = async (key, txn, hash, surl, furl, curl) => {

      console.log(key, txn, hash, surl, furl, curl)

      var form = document.createElement("form");

      form.method = 'post';

      // form.action = "https://secure.payu.in/_payment";

      form.action = "https://test.payu.in/_payment";

      const hiddenField = document.createElement('input');

      hiddenField.type = 'hidden';

      hiddenField.name = 'key';

      hiddenField.value = key;

      form.appendChild(hiddenField);

      const hiddenField1 = document.createElement('input');

      hiddenField1.type = 'hidden';

      hiddenField1.name = 'amount';

      hiddenField1.value = discount?Variables.get_charges()-disAmount:Variables.get_charges();

      form.appendChild(hiddenField1);

      const hiddenField2 = document.createElement('input');

      hiddenField2.type = 'hidden';

      hiddenField2.name = 'productinfo';

      hiddenField2.value = 'Ask Second Opinion';

      form.appendChild(hiddenField2);

      const hiddenField3 = document.createElement('input');

      hiddenField3.type = 'hidden';

      hiddenField3.name = 'firstname';

      hiddenField3.value = Variables.get_patientName();

      form.appendChild(hiddenField3);

      const hiddenField4 = document.createElement('input');

      hiddenField4.type = 'hidden';

      hiddenField4.name = 'email';

      hiddenField4.value = Variables.get_email();

      form.appendChild(hiddenField4);

      const hiddenField5 = document.createElement('input');

      hiddenField5.type = 'hidden';

      hiddenField5.name = 'txnid';

      hiddenField5.value = txn;

      form.appendChild(hiddenField5);

      const hiddenField6 = document.createElement('input');

      hiddenField6.type = 'hidden';

      hiddenField6.name = 'phone';

      hiddenField6.value = Variables.get_Mobile();

      form.appendChild(hiddenField6);

      const hiddenField7 = document.createElement('input');

      hiddenField7.type = 'hidden';

      hiddenField7.name = 'surl';

      hiddenField7.value = surl;

      form.appendChild(hiddenField7);

      const hiddenField8 = document.createElement('input');

      hiddenField8.type = 'hidden';

      hiddenField8.name = 'furl';

      hiddenField8.value = furl;

      form.appendChild(hiddenField8);

      const hiddenField9 = document.createElement('input');

      hiddenField9.type = 'hidden';

      hiddenField9.name = 'curl';

      hiddenField9.value = curl;

      form.appendChild(hiddenField9);

      const hiddenField10 = document.createElement('input');

      hiddenField10.type = 'hidden';

      hiddenField10.name = 'hash';

      hiddenField10.value = hash;

      form.appendChild(hiddenField10);

      document.body.appendChild(form);

      form.submit();

  };

Comments

Popular posts from this blog

interview questions js[ Anurag Singh ProCodrr]

reactnative_creation