Skip to content

Instantly share code, notes, and snippets.

View abel-masila's full-sized avatar
⚛️
Shipping code!

Abel Masila abel-masila

⚛️
Shipping code!
View GitHub Profile
{
"filedata": [
{
"date_issued": "2018-03-27",
"transaction_type": "IMPORT",
"policy_number": "DSM/MARC/POL/0202762",
"open_cover": false,
"icc": "ICC-A",
"insured_name": "GALCO LIMITED",
"insured_email": "[email protected]",
{
"filedata": [
{
"date_issued": "2018-01-25",
"transaction_type": "IMPORT",
"policy_number": "jub/2018/0298",
"open_cover": true,
"endorsement_number": "jub/2018/0298/001",
"icc": "ICC-A",
"insured_name": "Another buyer",
const data=[
{
"date_issued": "2018-01-25",
"transaction_type": "IMPORT",
"policy_number": "jub/2018/0298",
"OPEN COVER (YES or NO)": "YES",
"endorsement_number": "jub/2018/0298/001",
"icc": "ICC-A",
"insured_name": "Another buyer",
"insured_email": "[email protected]",
[
{
"COVER ISSUE DATE ": "25-Jan-2018",
"IMPORT / EXPORT": "IMPORT",
"POLICY NUMBER": "jub/2018/0298",
"OPEN COVER (YES or NO)": "YES",
"ENDORSEMENT NUMBER": "jub/2018/0298/001",
"ICC CLASS (ICC-A, ICC-B or ICC-C)": "ICC-A",
"INSURED NAME": "Another buyer",
"INSURED EMAIL ADDRESS": "[email protected]",
const selectedGoods = quote.selected_goods;
if(this.goodsValidator.allValid()){
this.goodsValidator.hideMessages();
selectedGoods.push(selectedGood);
}else {
this.goodsValidator.showMessages();
// rerender to show messages for the first time
this.forceUpdate();
}
//async promise with user input
const asyncAdd=(a,b)=>{
return new Promise((resolve,reject)=>{
setTimeout(()=>{
if(typeof a=== 'number' && typeof b==='number'){
resolve(a+b);
}else {
reject('Arguments must be numbers');
}
},1500)
axios.get(geocodeURL).then((response)=>{
if(response.data.status==='ZERO_RESULTS'){
throw new Error('Unable to find that address!');
}
const lat=response.data.results[0].geometry.location.lat;
const lng=response.data.results[0].geometry.location.lng;
const weatherURL=`https://api.darksky.net/forecast/3708bcb6e2a477e7fb94de8fd3ecdfab/${lat},${lng}`;
import validator from 'validator';
class FormValidator{
constructor(validations) {
// validations is an array of validation rules specific to a form
this.validations = validations;
}
validate(state){
// start out assuming valid
let validation = this.valid();
import React, { Component } from 'react';
import loading_icon from '../images/ellipsis.gif';
export default class BlankState extends Component {
constructor(props){
super(props);
let { data = [], dataName = 'Info', isDataLoading, customMessage } = this.props;
function loop(arr) {
// i IS NOT known here
// j IS NOT known here
for( var i = 0; i < arr.length; i++ ) {
// i IS known here
}
// i IS known here
// j IS NOT known here