diff --git a/gatsby-browser.js b/gatsby-browser.js
index 16f4fc7..3607333 100644
--- a/gatsby-browser.js
+++ b/gatsby-browser.js
@@ -1,7 +1,13 @@
+import { ApolloProvider } from "@apollo/react-hooks"
import React from "react"
import { AppContextProvider } from "./src/app-context"
+import client from "./src/client"
export const wrapRootElement = ({ element }) => {
- return {element}
+ return (
+
+ {element}
+
+ )
}
diff --git a/gatsby-config.js b/gatsby-config.js
index 01605aa..ab108b4 100644
--- a/gatsby-config.js
+++ b/gatsby-config.js
@@ -88,6 +88,24 @@ module.exports = {
disallow: "/bydeau",
userAgent: "*",
},
+ {
+ allow: "/",
+ crawlDelay: 10,
+ disallow: "/addresses",
+ userAgent: "*",
+ },
+ {
+ allow: "/",
+ crawlDelay: 10,
+ disallow: "/address-editor",
+ userAgent: "*",
+ },
+ {
+ allow: "/",
+ crawlDelay: 10,
+ disallow: "/orders",
+ userAgent: "*",
+ },
],
},
resolve: "gatsby-plugin-robots-txt",
diff --git a/gatsby-ssr.js b/gatsby-ssr.js
index e69de29..3607333 100644
--- a/gatsby-ssr.js
+++ b/gatsby-ssr.js
@@ -0,0 +1,13 @@
+import { ApolloProvider } from "@apollo/react-hooks"
+import React from "react"
+
+import { AppContextProvider } from "./src/app-context"
+import client from "./src/client"
+
+export const wrapRootElement = ({ element }) => {
+ return (
+
+ {element}
+
+ )
+}
diff --git a/graphql-types.ts b/graphql-types.ts
index d922f1a..14fdcbd 100644
--- a/graphql-types.ts
+++ b/graphql-types.ts
@@ -6186,10 +6186,10 @@ export type Query = {
allShopifyProduct: ShopifyProductConnection;
shopifyPage?: Maybe;
allShopifyPage: ShopifyPageConnection;
- shopifyBlog?: Maybe;
- allShopifyBlog: ShopifyBlogConnection;
shopifyCollection?: Maybe;
allShopifyCollection: ShopifyCollectionConnection;
+ shopifyBlog?: Maybe;
+ allShopifyBlog: ShopifyBlogConnection;
contentfulAsset?: Maybe;
allContentfulAsset: ContentfulAssetConnection;
contentfulBlockRichTextContentRichTextNode?: Maybe;
@@ -6523,44 +6523,44 @@ export type QueryAllShopifyPageArgs = {
};
-export type QueryShopifyBlogArgs = {
+export type QueryShopifyCollectionArgs = {
id?: Maybe;
parent?: Maybe;
children?: Maybe;
internal?: Maybe;
+ description?: Maybe;
+ descriptionHtml?: Maybe;
handle?: Maybe;
title?: Maybe;
- url?: Maybe;
+ updatedAt?: Maybe;
shopifyId?: Maybe;
+ products?: Maybe;
};
-export type QueryAllShopifyBlogArgs = {
- filter?: Maybe;
- sort?: Maybe;
+export type QueryAllShopifyCollectionArgs = {
+ filter?: Maybe;
+ sort?: Maybe;
skip?: Maybe;
limit?: Maybe;
};
-export type QueryShopifyCollectionArgs = {
+export type QueryShopifyBlogArgs = {
id?: Maybe;
parent?: Maybe;
children?: Maybe;
internal?: Maybe;
- description?: Maybe;
- descriptionHtml?: Maybe;
handle?: Maybe;
title?: Maybe;
- updatedAt?: Maybe;
+ url?: Maybe;
shopifyId?: Maybe;
- products?: Maybe;
};
-export type QueryAllShopifyCollectionArgs = {
- filter?: Maybe;
- sort?: Maybe;
+export type QueryAllShopifyBlogArgs = {
+ filter?: Maybe;
+ sort?: Maybe;
skip?: Maybe;
limit?: Maybe;
};
@@ -9884,6 +9884,16 @@ export type BydeauPageQuery = { shopifyCollection?: Maybe<{ products?: Maybe>> }
)>>> }> };
+export type LoginBgImageQueryVariables = Exact<{ [key: string]: never; }>;
+
+
+export type LoginBgImageQuery = { file?: Maybe<{ childImageSharp?: Maybe<{ fluid?: Maybe }> }> };
+
+export type RegisterBgImageQueryVariables = Exact<{ [key: string]: never; }>;
+
+
+export type RegisterBgImageQuery = { file?: Maybe<{ childImageSharp?: Maybe<{ fluid?: Maybe }> }> };
+
export type BlogPostsPageQueryVariables = Exact<{ [key: string]: never; }>;
diff --git a/package-lock.json b/package-lock.json
index 9b836ce..6889e19 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -4,6 +4,26 @@
"lockfileVersion": 1,
"requires": true,
"dependencies": {
+ "@apollo/react-common": {
+ "version": "3.1.4",
+ "resolved": "https://registry.npmjs.org/@apollo/react-common/-/react-common-3.1.4.tgz",
+ "integrity": "sha512-X5Kyro73bthWSCBJUC5XYQqMnG0dLWuDZmVkzog9dynovhfiVCV4kPSdgSIkqnb++cwCzOVuQ4rDKVwo2XRzQA==",
+ "requires": {
+ "ts-invariant": "^0.4.4",
+ "tslib": "^1.10.0"
+ }
+ },
+ "@apollo/react-hooks": {
+ "version": "3.1.5",
+ "resolved": "https://registry.npmjs.org/@apollo/react-hooks/-/react-hooks-3.1.5.tgz",
+ "integrity": "sha512-y0CJ393DLxIIkksRup4nt+vSjxalbZBXnnXxYbviq/woj+zKa431zy0yT4LqyRKpFy9ahMIwxBnBwfwIoupqLQ==",
+ "requires": {
+ "@apollo/react-common": "^3.1.4",
+ "@wry/equality": "^0.1.9",
+ "ts-invariant": "^0.4.4",
+ "tslib": "^1.10.0"
+ }
+ },
"@ardatan/aggregate-error": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/@ardatan/aggregate-error/-/aggregate-error-0.0.1.tgz",
@@ -2765,6 +2785,12 @@
}
}
},
+ "@types/isomorphic-fetch": {
+ "version": "0.0.35",
+ "resolved": "https://registry.npmjs.org/@types/isomorphic-fetch/-/isomorphic-fetch-0.0.35.tgz",
+ "integrity": "sha512-DaZNUvLDCAnCTjgwxgiL1eQdxIKEpNLOlTNtAgnZc50bG2copGhRrFN9/PxPBuJe+tZVLCbQ7ls0xveXVRPkvw==",
+ "dev": true
+ },
"@types/istanbul-lib-coverage": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.3.tgz",
@@ -2838,8 +2864,7 @@
"@types/node": {
"version": "13.13.12",
"resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.12.tgz",
- "integrity": "sha512-zWz/8NEPxoXNT9YyF2osqyA9WjssZukYpgI4UYZpOjcyqwIUqWGkcCionaEb9Ki+FULyPyvNFpg/329Kd2/pbw==",
- "dev": true
+ "integrity": "sha512-zWz/8NEPxoXNT9YyF2osqyA9WjssZukYpgI4UYZpOjcyqwIUqWGkcCionaEb9Ki+FULyPyvNFpg/329Kd2/pbw=="
},
"@types/normalize-package-data": {
"version": "2.4.0",
@@ -3039,6 +3064,11 @@
"resolved": "https://registry.npmjs.org/@types/yoga-layout/-/yoga-layout-1.9.2.tgz",
"integrity": "sha512-S9q47ByT2pPvD65IvrWp7qppVMpk9WGMbVq9wbWZOHg6tnXSD4vyhao6nOSBwwfDdV2p3Kx9evA9vI+XWTfDvw=="
},
+ "@types/zen-observable": {
+ "version": "0.8.0",
+ "resolved": "https://registry.npmjs.org/@types/zen-observable/-/zen-observable-0.8.0.tgz",
+ "integrity": "sha512-te5lMAWii1uEJ4FwLjzdlbw3+n0FZNOvFXHxQDKeT0dilh7HOzdMzV2TrJVUzq8ep7J4Na8OUYPRLSQkJHAlrg=="
+ },
"@typescript-eslint/eslint-plugin": {
"version": "2.34.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.34.0.tgz",
@@ -3271,6 +3301,15 @@
"@xtuc/long": "4.2.2"
}
},
+ "@wry/context": {
+ "version": "0.4.4",
+ "resolved": "https://registry.npmjs.org/@wry/context/-/context-0.4.4.tgz",
+ "integrity": "sha512-LrKVLove/zw6h2Md/KZyWxIkFM6AoyKp71OqpH9Hiip1csjPVoD3tPxlbQUNxEnHENks3UGgNpSBCAfq9KWuag==",
+ "requires": {
+ "@types/node": ">=6",
+ "tslib": "^1.9.3"
+ }
+ },
"@wry/equality": {
"version": "0.1.11",
"resolved": "https://registry.npmjs.org/@wry/equality/-/equality-0.1.11.tgz",
@@ -3481,6 +3520,58 @@
"normalize-path": "^2.1.1"
}
},
+ "apollo-boost": {
+ "version": "0.4.9",
+ "resolved": "https://registry.npmjs.org/apollo-boost/-/apollo-boost-0.4.9.tgz",
+ "integrity": "sha512-05y5BKcDaa8w47f8d81UVwKqrAjn8uKLv6QM9fNdldoNzQ+rnOHgFlnrySUZRz9QIT3vPftQkEz2UEASp1Mi5g==",
+ "requires": {
+ "apollo-cache": "^1.3.5",
+ "apollo-cache-inmemory": "^1.6.6",
+ "apollo-client": "^2.6.10",
+ "apollo-link": "^1.0.6",
+ "apollo-link-error": "^1.0.3",
+ "apollo-link-http": "^1.3.1",
+ "graphql-tag": "^2.4.2",
+ "ts-invariant": "^0.4.0",
+ "tslib": "^1.10.0"
+ }
+ },
+ "apollo-cache": {
+ "version": "1.3.5",
+ "resolved": "https://registry.npmjs.org/apollo-cache/-/apollo-cache-1.3.5.tgz",
+ "integrity": "sha512-1XoDy8kJnyWY/i/+gLTEbYLnoiVtS8y7ikBr/IfmML4Qb+CM7dEEbIUOjnY716WqmZ/UpXIxTfJsY7rMcqiCXA==",
+ "requires": {
+ "apollo-utilities": "^1.3.4",
+ "tslib": "^1.10.0"
+ }
+ },
+ "apollo-cache-inmemory": {
+ "version": "1.6.6",
+ "resolved": "https://registry.npmjs.org/apollo-cache-inmemory/-/apollo-cache-inmemory-1.6.6.tgz",
+ "integrity": "sha512-L8pToTW/+Xru2FFAhkZ1OA9q4V4nuvfoPecBM34DecAugUZEBhI2Hmpgnzq2hTKZ60LAMrlqiASm0aqAY6F8/A==",
+ "requires": {
+ "apollo-cache": "^1.3.5",
+ "apollo-utilities": "^1.3.4",
+ "optimism": "^0.10.0",
+ "ts-invariant": "^0.4.0",
+ "tslib": "^1.10.0"
+ }
+ },
+ "apollo-client": {
+ "version": "2.6.10",
+ "resolved": "https://registry.npmjs.org/apollo-client/-/apollo-client-2.6.10.tgz",
+ "integrity": "sha512-jiPlMTN6/5CjZpJOkGeUV0mb4zxx33uXWdj/xQCfAMkuNAC3HN7CvYDyMHHEzmcQ5GV12LszWoQ/VlxET24CtA==",
+ "requires": {
+ "@types/zen-observable": "^0.8.0",
+ "apollo-cache": "1.3.5",
+ "apollo-link": "^1.0.0",
+ "apollo-utilities": "1.3.4",
+ "symbol-observable": "^1.0.2",
+ "ts-invariant": "^0.4.0",
+ "tslib": "^1.10.0",
+ "zen-observable": "^0.8.0"
+ }
+ },
"apollo-link": {
"version": "1.2.14",
"resolved": "https://registry.npmjs.org/apollo-link/-/apollo-link-1.2.14.tgz",
@@ -3492,6 +3583,26 @@
"zen-observable-ts": "^0.8.21"
}
},
+ "apollo-link-error": {
+ "version": "1.1.13",
+ "resolved": "https://registry.npmjs.org/apollo-link-error/-/apollo-link-error-1.1.13.tgz",
+ "integrity": "sha512-jAZOOahJU6bwSqb2ZyskEK1XdgUY9nkmeclCrW7Gddh1uasHVqmoYc4CKdb0/H0Y1J9lvaXKle2Wsw/Zx1AyUg==",
+ "requires": {
+ "apollo-link": "^1.2.14",
+ "apollo-link-http-common": "^0.2.16",
+ "tslib": "^1.9.3"
+ }
+ },
+ "apollo-link-http": {
+ "version": "1.5.17",
+ "resolved": "https://registry.npmjs.org/apollo-link-http/-/apollo-link-http-1.5.17.tgz",
+ "integrity": "sha512-uWcqAotbwDEU/9+Dm9e1/clO7hTB2kQ/94JYcGouBVLjoKmTeJTUPQKcJGpPwUjZcSqgYicbFqQSoJIW0yrFvg==",
+ "requires": {
+ "apollo-link": "^1.2.14",
+ "apollo-link-http-common": "^0.2.16",
+ "tslib": "^1.9.3"
+ }
+ },
"apollo-link-http-common": {
"version": "0.2.16",
"resolved": "https://registry.npmjs.org/apollo-link-http-common/-/apollo-link-http-common-0.2.16.tgz",
@@ -7507,11 +7618,21 @@
"integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k="
},
"encoding": {
- "version": "0.1.12",
- "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz",
- "integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=",
+ "version": "0.1.13",
+ "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz",
+ "integrity": "sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==",
"requires": {
- "iconv-lite": "~0.4.13"
+ "iconv-lite": "^0.6.2"
+ },
+ "dependencies": {
+ "iconv-lite": {
+ "version": "0.6.2",
+ "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.2.tgz",
+ "integrity": "sha512-2y91h5OpQlolefMPmUlivelittSWy0rP+oYVpn6A7GwVHNE8AWzoYOBNmlwks3LobaJxgHCYZAnyNo2GgpNRNQ==",
+ "requires": {
+ "safer-buffer": ">= 2.1.2 < 3.0.0"
+ }
+ }
}
},
"end-of-stream": {
@@ -15373,6 +15494,14 @@
}
}
},
+ "optimism": {
+ "version": "0.10.3",
+ "resolved": "https://registry.npmjs.org/optimism/-/optimism-0.10.3.tgz",
+ "integrity": "sha512-9A5pqGoQk49H6Vhjb9kPgAeeECfUDF6aIICbMDL23kDLStBn1MWk3YvcZ4xWF9CsSf6XEgvRLkXy4xof/56vVw==",
+ "requires": {
+ "@wry/context": "^0.4.0"
+ }
+ },
"optimize-css-assets-webpack-plugin": {
"version": "5.0.3",
"resolved": "https://registry.npmjs.org/optimize-css-assets-webpack-plugin/-/optimize-css-assets-webpack-plugin-5.0.3.tgz",
diff --git a/package.json b/package.json
index 8606dbe..e9e8fdc 100644
--- a/package.json
+++ b/package.json
@@ -5,9 +5,11 @@
"version": "0.2.0",
"author": "Kyle Mathews ",
"dependencies": {
+ "@apollo/react-hooks": "^3.1.5",
"@contentful/rich-text-react-renderer": "^13.4.0",
"@emotion/core": "^10.0.27",
"@mdx-js/react": "^1.5.5",
+ "apollo-boost": "^0.4.9",
"disqus-react": "^1.0.8",
"gatsby": "^2.19.25",
"gatsby-image": "^2.2.39",
@@ -33,6 +35,7 @@
"gatsby-source-filesystem": "^2.1.46",
"gatsby-source-shopify": "^3.0.43",
"gatsby-transformer-sharp": "^2.3.13",
+ "isomorphic-fetch": "^2.2.1",
"mailgun-js": "^0.22.0",
"moment": "^2.24.0",
"pdfkit": "^0.11.0",
@@ -58,6 +61,7 @@
"use-query-params": "^0.6.0"
},
"devDependencies": {
+ "@types/isomorphic-fetch": "0.0.35",
"@types/lodash": "^4.14.149",
"@types/node": "^13.7.0",
"@types/qrcode.react": "^1.0.0",
diff --git a/src/app-context.tsx b/src/app-context.tsx
index faecaee..cb7f625 100644
--- a/src/app-context.tsx
+++ b/src/app-context.tsx
@@ -1,13 +1,18 @@
+import { gql } from "apollo-boost"
import React, { createContext, useEffect, useState } from "react"
// @ts-ignore
import Client from "shopify-buy"
import createPersistedState from "use-persisted-state"
+import ApolloClient from "./client"
+import { CUSTOMER } from "./utils/graphql"
+
const client = Client.buildClient({
domain: process.env.SHOPIFY_SHOP_NAME,
storefrontAccessToken: process.env.SHOPIFY_ACCESS_TOKEN,
})
+const useShopifyAccessToken = createPersistedState("shopifyAccessToken")
const useIsAgeRestrictionVisible = createPersistedState(
"isAgeRestrictionVisible",
)
@@ -17,19 +22,24 @@ export interface AppContextProps {
addLineItems: (lineItemsToAdd: any[]) => Promise
checkout?: Client.Cart
client: Client.Client
+ customer?: any
isAgeRestrictionVisible: boolean
isCartVisible: boolean
isCheckoutVisible: boolean
+ isCustomerLoading: boolean
isMenuVisible: boolean
isSubscribeVisible: boolean
isWelcomeVisible: boolean
+ refreshCustomer: () => void
setIsAgeRestrictionVisible: React.Dispatch>
setIsCartVisible: React.Dispatch>
setIsCheckoutVisible: React.Dispatch>
setIsMenuVisible: React.Dispatch>
setIsSubscribeVisible: React.Dispatch>
setIsWelcomeVisible: React.Dispatch>
+ setShopifyAccessToken: React.Dispatch>
setSubscriptionProduct: React.Dispatch>
+ shopifyAccessToken: string
subscriptionProduct: string
updateLineItems: (lineItemsToUpdate: any[]) => Promise
}
@@ -53,10 +63,14 @@ export const AppContextProvider: React.FC = ({
const [isMenuVisible, setIsMenuVisible] = useState(false)
const [isSubscribeVisible, setIsSubscribeVisible] = useState(false)
const [isWelcomeVisible, setIsWelcomeVisible] = useIsWelcomeVisible(true)
+ const [shopifyAccessToken, setShopifyAccessToken] = useShopifyAccessToken("")
const [subscriptionProduct, setSubscriptionProduct] = useState("")
+ const [customer, setCustomer] = useState()
+ const [isCustomerLoading, setIsCustomerLoading] = useState(false)
useEffect(() => {
fetchCheckout()
+ fetchCustomer()
}, [])
const addLineItems = async (lineItemsToAdd: any[]): Promise => {
@@ -109,25 +123,44 @@ export const AppContextProvider: React.FC = ({
}
}
+ const fetchCustomer = async (): Promise => {
+ setIsCustomerLoading(true)
+ const { data } = await ApolloClient.query({
+ fetchPolicy: "no-cache",
+ query: CUSTOMER,
+ variables: { customerAccessToken: shopifyAccessToken },
+ })
+ if (data && data.customer) {
+ setCustomer(data.customer)
+ }
+ setIsCustomerLoading(false)
+ return
+ }
+
return (
{
useEffect(() => {
// @ts-ignore
- if (hj) {
+ // if (hj) {
// @ts-ignore
- hj("stateChange", window.location.href + "@hj-started-checkout")
- }
+ // hj("stateChange", window.location.href + "@hj-started-checkout")
+ // }
}, [])
useEffect(() => {
@@ -65,10 +65,10 @@ const CheckoutPopup: React.FC = () => {
const handleCheckout = (): void => {
// @ts-ignore
- if (hj) {
+ // if (hj) {
// @ts-ignore
- hj("stateChange", window.location.href + "@hj-checkout-handed-to-shopify")
- }
+ // hj("stateChange", window.location.href + "@hj-checkout-handed-to-shopify")
+ // }
try {
setIsUpdatingAttributes(true)
diff --git a/src/components/header.tsx b/src/components/header.tsx
index f90c20a..b94e5ff 100644
--- a/src/components/header.tsx
+++ b/src/components/header.tsx
@@ -1,5 +1,6 @@
+import { Link } from "gatsby"
import React, { useContext } from "react"
-import { MdMenu, MdShoppingCart } from "react-icons/md"
+import { MdMenu, MdPerson, MdShoppingCart } from "react-icons/md"
import { useScrollYPosition } from "react-use-scroll-position"
import { Box, Button, Container, Flex, Text } from "theme-ui"
@@ -11,9 +12,12 @@ interface HeaderProps {
}
const Header: React.FC = ({ logo }) => {
- const { checkout, setIsCartVisible, setIsMenuVisible } = useContext(
- AppContext,
- )
+ const {
+ checkout,
+ setIsCartVisible,
+ setIsMenuVisible,
+ shopifyAccessToken,
+ } = useContext(AppContext)
const scrollY = useScrollYPosition()
const isSticky = scrollY > 0
@@ -46,6 +50,13 @@ const Header: React.FC = ({ logo }) => {
{logo}
+
+
+
+
+