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
const useZingCash = (userId, amountToPay) => { | |
//Find all zingcash document which {userId: userId, isExpired: false, status: ACTIVE, transactionType: CREDIT} and sort in ascending order by expiryDate | |
data = Date from db | |
let remainingAmountToPay = amountToPay | |
const transactionToUpdate = [] // will contain all transaction id which will be completely used to pay amountToPay | |
const breakTransaction = { _id: null, updateBody: {}} | |
for (let i=0; i<data.length; ++i) { | |
const {amount} = data[i] |
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
import React, { Component, Fragment } from "react"; | |
import { Route, Redirect } from "react-router-dom"; | |
import Fetch from "./fetch"; | |
class PrivateRoute extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
isValidToken: false, | |
loading: 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
// I think we should create 2 entries for same product one in english and another in spanish | |
// For example: Product is IphoneX, | |
// Save one entry in english Language | |
{ | |
name: "IphoneX", | |
price: x, | |
lang: "en", |
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
const fetch1 = fetch(url).then((res) => res.json()). then((data) => {// do required things after fetch call and return Promise.resoove(true)}) | |
const fetch2 = fetch(url).then((res) => res.json()). then((data) => {// do required things after fetch call and return Promise.resolve(true)}) | |
const fetch3 = fetch(url).then((res) => res.json()). then((data) => {// do required things after fetch call return Promise.resolve(true)}) | |
const allFetchDone = Promise.all([fetch1, fetch2, fetch3]).then(() => {// this function will be called after all fetch request is completed with success}) | |
// this can be also done using async and await. This will make code Readable | |
// function for fetch call |
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
const multipleFetch = async () => { | |
const Fetch1 = await fetch(url, options) | |
/* | |
* Fetch1 has completed, Do required things after fetch1 | |
*/ | |
const Fetch2 = await fetch(url, options) | |
/* | |
* Fetch1 and Fetch2 has completed, Do required things after fetch2 | |
*/ | |
const Fetch3 = await fetch(url, options) |
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
import React, { Component } from "react"; | |
import logo from "./logo.svg"; | |
import "./App.css"; | |
import CardCase1 from "./CardCase1.js"; | |
import CardCase2 from "./CardCase2.js"; | |
import CardCase3 from "./CardCase3.js"; | |
import CardCase4 from "./CardCase4.js"; | |
import CardCase5 from "./CardCase5.js"; | |
import CardCase6 from "./CardCase6.js"; | |
import BillCard1 from "./BillCard1.js"; |
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
/* | |
* @params | |
* @profit array of profit for each day | |
* @ L, R range | |
*/ | |
let count = 0; | |
for(let i=0; i<profit.length; ++i) { | |
const value = profit[i] | |
if(value >= L || value <=R) { | |
++count |
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
mapArray = (array) => { | |
const mapObj = {} | |
if(array.length === 0) { | |
return mapObj | |
} | |
for(let i=0; i<array.length; ++i) { | |
const value = array[i] | |
if(mapObj[value]) { | |
++mapObj[value] | |
}else{ |