This file contains hidden or 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
| addProductToCart(productId) { | |
| this.props.commerce.Cart.add({ | |
| id: productId, | |
| }, (resp) => { | |
| // if successful update Cart | |
| if (!resp.error) { | |
| this.setState({ | |
| cart: resp.cart | |
| }) | |
| } |
This file contains hidden or 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
| componentDidMount() { | |
| const { | |
| commerce | |
| } = this.props | |
| if (commerce !== undefined && typeof commerce !== 'undefined') { | |
| // invoke commerce products method to get all products | |
| commerce.Products.list( | |
| (resp) => { |
This file contains hidden or 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
| constructor(props) { | |
| super(props) | |
| this.state = { | |
| products: [], | |
| cart: null | |
| } | |
| } |
This file contains hidden or 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
| // init commerce below | |
| const commerce = new window | |
| .Commerce( | |
| process.env.REACT_APP_COMMERCEJS_PUBLIC_KEY, | |
| (process.env.NODE_ENV === 'development') ? true : false | |
| ); | |
| // pass as prop to App component | |
| ReactDOM.render(<App commerce={commerce} />, document.getElementById('root')); |
This file contains hidden or 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 test = { | |
| phonenumber : "hello world", | |
| email: "goodbye world" | |
| } | |
| const email = true; | |
| const phoneNumber = true; | |
| document.write(test[ | |
| (email ? 'email' : 'phonenumber') |
This file contains hidden or 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
| async function testAA(startTest = false) { | |
| if (startTest) { | |
| const result = await new Promise((resolve, reject) => { | |
| setTimeout(() => resolve("worked"), 3000) | |
| }) | |
| startTest = result | |
| } | |
| return console.log( | |
| startTest |
This file contains hidden or 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, PureComponent } from 'react' | |
| import { connect } from 'react-redux' | |
| import { Page, Text, View, Document, StyleSheet, PDFViewer, Image } from '@react-pdf/renderer'; | |
| // Utils | |
| import createUUID from '../util/createUUID' | |
| import agent from '../util/agent' | |
| // Images | |
| import logo from '../images/small_logo.png'; |
This file contains hidden or 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
| // write a function that returns a boolean indiciating | |
| // whether a whitelisted state key has a value that is different than it's // previous value | |
| const _whitelistedKeys = [ | |
| 'invoiceName', | |
| // customer details | |
| 'customersFullName', | |
| 'customersAddress', | |
| 'customersCityState', | |
| 'customersZipCode', |
NewerOlder