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
| /* /components/Checkout/CheckoutForm.js */ | |
| import React from "react"; | |
| import CardSection from "./CardSection"; | |
| import { FormGroup, Label, Input, FormText, Row, Col } from "reactstrap"; | |
| import { injectStripe } from "react-stripe-elements"; | |
| import Strapi from "strapi-sdk-javascript/build/main"; | |
| import Router from "next/router"; |
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
| /* pages/checkout.js */ | |
| import React, { Component } from "react"; | |
| import defaultPage from "../hocs/defaultPage"; | |
| import Cart from "../components/Cart/Cart"; | |
| import InjectedCheckoutForm from "../components/Checkout/CheckoutForm"; | |
| import { Row, Col } from "reactstrap"; | |
| import { StripeProvider, Elements } from "react-stripe-elements"; | |
| import { withContext } from "../components/Context/AppProvider"; |
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
| /* /components/Context/AppProvider */ | |
| import React from "react"; | |
| import Cookies from "js-cookie"; | |
| /* First we will make a new context */ | |
| const AppContext = React.createContext(); | |
| /* Then create a provider Component */ | |
| class AppProvider extends React.Component { | |
| constructor(props) { |
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
| /* components/Cart/Cart.js */ | |
| import React from "react"; | |
| import defaultPage from "../../hocs/defaultPage"; | |
| import { withContext } from "../Context/AppProvider"; | |
| import { compose } from "recompose"; | |
| import Link from "next/link"; | |
| import { withRouter } from "next/router"; | |
| import { | |
| Button, |
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 from "react"; | |
| import { unsetToken } from "../lib/auth"; | |
| class Layout extends React.Component { | |
| render() { | |
| const { isAuthenticated, children } = this.props; | |
| return ( | |
| <div> | |
| <header> | |
| <Nav className="navbar navbar-dark bg-dark"> |
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
| /* /pages/signin.js */ | |
| import React from "react"; | |
| import defaultPage from "../hocs/defaultPage"; | |
| import { strapiLogin } from "../lib/auth"; | |
| import Router from "next/router"; | |
| import { | |
| Container, | |
| Row, |
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
| /* /pages/signup.js */ | |
| import React from "react"; | |
| import { strapiRegister } from "../lib/auth"; | |
| import Router from "next/router"; | |
| import { | |
| Container, | |
| Row, | |
| Col, |
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
| /* /lib/auth.js */ | |
| import jwtDecode from "jwt-decode"; | |
| import Cookies from "js-cookie"; | |
| import Strapi from "strapi-sdk-javascript/build/main"; | |
| import Router from "next/router"; | |
| const apiUrl = process.env.API_URL || "http://localhost:1337"; | |
| const strapi = new Strapi(apiUrl); |
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
| /* components/hocs/securePage.js */ | |
| import React from "react"; | |
| import PropTypes from "prop-types"; | |
| import defaultPage from "./defaultPage"; | |
| const securePageHoc = Page => | |
| class SecurePage extends React.Component { | |
| static propTypes = { |
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
| /* hocs/defaultPage.js */ | |
| import React from "react"; | |
| import Router from "next/router"; | |
| import { getUserFromServerCookie, getUserFromLocalCookie } from "../lib/auth"; | |
| export default Page => | |
| class DefaultPage extends React.Component { | |
| static async getInitialProps({ req }) { |