Skip to content

Instantly share code, notes, and snippets.

View ryanbelke's full-sized avatar
💭
coding

Ryan Beke ryanbelke

💭
coding
  • Austin, Tx
View GitHub Profile
<CardImg
top={true}
style={{ height: 250 }}
src={ process.env.NODE_ENV === "production"
? res.image.url : `${process.env.NEXT_PUBLIC_API_URL}${res.image.url}`}
/>
@ryanbelke
ryanbelke / restaurants.js
Created May 17, 2020 04:23
new restaurants.js for deployment
/* /pages/restaurants.js */
import { useContext } from "react";
import { useQuery } from "@apollo/react-hooks";
import { useRouter } from "next/router";
import { gql } from "apollo-boost";
import Cart from "../components/cart/";
import AppContext from "../context/AppContext";
import {
@ryanbelke
ryanbelke / index.js
Created May 17, 2020 04:23
new RestaurantList.js for deployment
/* components/RestaurantList/index.js */
import { useQuery } from "@apollo/react-hooks";
import { gql } from "apollo-boost";
import Link from "next/link";
import {
Card,
CardBody,
CardImg,
async function submitOrder() {
// event.preventDefault();
// // Use elements.getElement to get a reference to the mounted Element.
const cardElement = elements.getElement(CardElement);
// // Pass the Element directly to other Stripe.js methods:
// // e.g. createToken - https://stripe.com/docs/js/tokens_sources/create_token?type=cardElement
// get token back from stripe to process credit card
const token = await stripe.createToken(cardElement);
"use strict";
/**
* Order.js controller
*
* @description: A set of functions called "actions" for managing `Order`.
*/
const stripe = require("stripe")("YOUR STRIPE SECRET KEY");
@ryanbelke
ryanbelke / CardSection.js
Created May 12, 2020 01:53
card section
/* components/Checkout/cardsection.js */
import React from "react";
import { CardElement } from "@stripe/react-stripe-js";
function CardSection(props) {
return (
<div>
<div>
@ryanbelke
ryanbelke / CheckoutForm.js
Last active May 17, 2020 02:45
checkoutform from step-6
/* /components/Checkout/CheckoutForm.js */
import React, { useState, useContext } from "react";
import { FormGroup, Label, Input } from "reactstrap";
import fetch from "isomorphic-fetch";
import Cookies from "js-cookie";
import { CardElement, useStripe, useElements } from "@stripe/react-stripe-js";
@ryanbelke
ryanbelke / checkout.js
Last active May 17, 2020 02:43
checkout.js from step 6
/* pages/checkout.js */
import React, { useContext } from "react";
import { Row, Col } from "reactstrap";
import { loadStripe } from "@stripe/stripe-js";
import { Elements } from "@stripe/react-stripe-js";
import InjectedCheckoutForm from "../components/checkout/CheckoutForm";
import AppContext from "../context/AppContext";
@ryanbelke
ryanbelke / _app.js
Last active May 12, 2020 01:08
step-5 _app.js
/* _app.js */
import React from "react";
import App from "next/app";
import Head from "next/head";
import Cookie from "js-cookie";
import fetch from "isomorphic-fetch";
import Layout from "../components/Layout";
import AppContext from "../context/AppContext";
import withData from "../lib/apollo";
class MyApp extends App {
@ryanbelke
ryanbelke / register.js
Created May 7, 2020 00:32
new register for user context
/* /pages/register.js */
import React, { useState, useContext } from "react";
import {
Container,
Row,
Col,
Button,
Form,