Skip to content

Instantly share code, notes, and snippets.

fetch('/saveInDB/livraison', {
credentials: 'include',
method: 'post',
body: JSON.stringify(values),
headers: new Headers({'Content-Type': 'application/json'})
})
.then(res => res.json())
.then(res => {
if (res.error) {
console.log(res.error);
const makeTransaction = (amount, nonceFromTheClient) => {
gateway.transaction.sale({
amount: amount,
paymentMethodNonce: nonceFromTheClient,
options: {
submitForSettlement: true
}
}, function(err, result) {
if (result.success) {
logger.info('[Braintree] Nouvelle transaction: %s', result.transaction.id);
import React, {Component} from 'react';
class AddProduct extends Component {
constructor(props) {
super(props);
this.state = {
cart: [""],
prix: '',
nom: '',
qte: 1,
get montantHorsFdp() {
if (panier.listeProduits.length > 0) {
return panier.listeProduits.reduce((sum, i) => (
sum += i.qte * i.prix
), 0);
} else {
return 0
}
},
@Franckapik
Franckapik / gist:215bde2edaf5592ca65250627d12b8e4
Last active February 6, 2020 20:36
No render at line 32
import React, {Component} from 'react';
import shopStore, {panier, panierOperations} from '../Store/shopStore';
import {view} from 'react-easy-state';
import client from '../Store/client';
class Cart extends Component {
render() {
return (<div className="cart box_light1 center fullsize">
import React, {Component} from 'react';
import shopStore, {panier, panierOperations} from '../Store/shopStore';
import {view} from 'react-easy-state';
import client from '../Store/client';
class Cart extends Component {
constructor(props) {
super(props);
this.state = {
const upsert = (table, sessid, data, returned) => {
return knex.select('*').groupBy(returned)
.from(table)
.where({
userid: sessid
})
.count()
.then((count) => {
if (count == 0) {
return knex(table)
@Franckapik
Franckapik / javascript object
Created March 29, 2020 18:34
Pug template issue
cart:
{ id: 776,
pid: '10',
userid: 'FA19EE7sBK6QlJ9pjTBUB6Wu4QlLGvZ9',
quantite: '1',
reduction: '0',
sous_total: '85',
montanttotal: 832,
fdp: 45,
prix: 85,
const saveProduct = panier.listeProduits.map((p, i) => {
const data = {
pid: p.id,
cartid: panier.cartid,
nom: p.nom,
quantite: p.qte,
prix: p.prix,
reduction: panier.reduction,
sous_total: p.qte * p.prix,
fdp: panier.fdp,
import React, {useState} from 'react';
import {SketchPicker} from 'react-color';
import Canvas3D from './Canvas3D';
import contreplaque from './contreplaque.jpg';
import okoume from './okoume.jpg';
import '../styles/App.scss';
const formeInit = {
rangee: 7,
epaisseur: 0.003,