Skip to content

Commit

Permalink
Merge pull request #2366 from graphcommerce-org/feature/guest-only-mode
Browse files Browse the repository at this point in the history
Feature/guest only mode
  • Loading branch information
paales authored Sep 24, 2024
2 parents 28b2c0c + e8f8e3f commit 5a78713
Show file tree
Hide file tree
Showing 88 changed files with 1,050 additions and 241 deletions.
2 changes: 1 addition & 1 deletion .changeset/green-flowers-double.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
'@graphcommerce/react-hook-form': patch
---

When a useFormGql throws an error in the onBeforeSubmit method or onComplete method it will setError('root.thrown') with the message, allowing it to be displayed somewhere. PaymentMethodButton will now render this as an ErrorSnackbar.
When a useFormGql throws an error in the onBeforeSubmit method or onComplete method it will be set as an ApolloError with the message, allowing it to be displayed somewhere. PaymentMethodButton will now render this as an ErrorSnackbar.
9 changes: 9 additions & 0 deletions .changeset/popular-rules-complain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@graphcommerce/ecommerce-ui': minor
'@graphcommerce/magento-cart-email': minor
'@graphcommerce/magento-customer': minor
'@graphcommerce/magento-cart': minor
'@graphcommerce/magento-graphcms': minor
---

Add `permissions` config so the website or store can be configurated to run in different modes.
24 changes: 24 additions & 0 deletions docs/framework/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@ Limit the static generation of SSG when building.

By default GraphCommerce will statically generate all product and category pages during build. This can take quite a long time, to skip this step set this value to true.

#### permissions: [GraphCommercePermissions](#GraphCommercePermissions)

Allows the option to require login or completely disable certain sections of the site, can be overriden per storeview with the storefrontConfig

#### previewSecret: string

To enable next.js' preview mode, configure the secret you'd like to use.
Expand Down Expand Up @@ -366,6 +370,22 @@ Issues that this can cause are:
- The same package is included multiple times in the bundle, increasing the bundle size.
- The Typescript types of the package are not compatible with each other, causing Typescript errors.

### GraphCommercePermissions

#### cart: CUSTOMER_ONLY | DISABLED | ENABLED

Changes the availability of the add to cart buttons and the cart page to either customer only or completely disables it.

#### checkout: CUSTOMER_ONLY | DISABLED | ENABLED

Changes the availability of the checkout to either customer only or completely disables it.

#### customerAccount: DISABLED | DISABLE_REGISTRATION | ENABLED

Enables / disabled the account section of the website. DISABLE_REGISTRATION will only disable the registration page.

#### website: ENABLED

### GraphCommerceStorefrontConfig

All storefront configuration for the project
Expand Down Expand Up @@ -438,6 +458,10 @@ Add a gcms-locales header to make sure queries return in a certain language, can

Custom locale used to load the .po files. Must be a valid locale, also used for Intl functions.

#### permissions: [GraphCommercePermissions](#GraphCommercePermissions)

Allows the option to require login or completely disable certain sections of the site on a per store basis

#### robotsAllow: boolean

Allow the site to be indexed by search engines.
Expand Down
4 changes: 3 additions & 1 deletion examples/magento-graphcms/components/Layout/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Image } from '@graphcommerce/image'
import { useCheckoutGuestEnabled } from '@graphcommerce/magento-cart'
import { StoreSwitcherButton } from '@graphcommerce/magento-store'
import { Footer as FooterBase } from '@graphcommerce/next-ui'
import { Trans } from '@lingui/macro'
Expand All @@ -9,6 +10,7 @@ export type FooterProps = FooterQueryFragment

export function Footer(props: FooterProps) {
const { footer } = props
const cartEnabled = useCheckoutGuestEnabled()

return (
<FooterBase
Expand Down Expand Up @@ -46,7 +48,7 @@ export function Footer(props: FooterProps) {
{link.title}
</Link>
))}
{import.meta.graphCommerce.magentoVersion >= 247 && (
{import.meta.graphCommerce.magentoVersion >= 247 && cartEnabled && (
<Link href='/guest/orderstatus' color='textPrimary' underline='always'>
<Trans>Order status</Trans>
</Link>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CartFab } from '@graphcommerce/magento-cart'
import { CartFab, useCartEnabled } from '@graphcommerce/magento-cart'
import { magentoMenuToNavigation } from '@graphcommerce/magento-category'
import { CustomerFab, CustomerMenuFabItem } from '@graphcommerce/magento-customer'
import { ProductFiltersProSearchField, SearchLink } from '@graphcommerce/magento-search'
Expand Down Expand Up @@ -39,6 +39,8 @@ export function LayoutNavigation(props: LayoutNavigationProps) {
const selection = useNavigationSelection()
const router = useRouter()

const cartEnabled = useCartEnabled()

return (
<>
<NavigationProvider
Expand Down Expand Up @@ -157,7 +159,7 @@ export function LayoutNavigation(props: LayoutNavigationProps) {
<WishlistFab icon={<IconSvg src={iconHeart} size='large' />} />
<CustomerFab guestHref='/account/signin' authHref='/account' />
{/* The placeholder exists because the CartFab is sticky but we want to reserve the space for the <CartFab /> */}
<PlaceholderFab />
{cartEnabled && <PlaceholderFab />}
</DesktopNavActions>
</>
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useCartEnabled } from '@graphcommerce/magento-cart'
import {
AddProductsToCartError,
AddProductsToCartQuantity,
Expand All @@ -21,6 +22,7 @@ export type AddProductsToCartViewProps = {

export function AddProductsToCartView(props: AddProductsToCartViewProps) {
const { product } = props
const cartEnabled = useCartEnabled()

return (
<>
Expand All @@ -39,20 +41,17 @@ export function AddProductsToCartView(props: AddProductsToCartViewProps) {
<>
<ProductCustomizable product={product} />
<Divider />

<ProductPageAddToCartQuantityRow product={product}>
<AddProductsToCartQuantity sx={{ flexShrink: '0' }} />
{cartEnabled && <AddProductsToCartQuantity sx={{ flexShrink: '0' }} />}

<AddProductsToCartError>
<Typography component='div' variant='h3' lineHeight='1'>
<ProductPagePrice product={product} />
</Typography>
</AddProductsToCartError>
</ProductPageAddToCartQuantityRow>

<ProductPagePriceTiers product={product} />

<ProductSidebarDelivery product={product} />
{cartEnabled && <ProductSidebarDelivery product={product} />}
</>
)}
</>
Expand Down
31 changes: 27 additions & 4 deletions examples/magento-graphcms/locales/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ msgstr "Kategorien"
msgid "Order #{orderNumber}"
msgstr "Bestellung #{orderNumber}"

#. js-lingui-generated-id
msgid "You must first login before you can continue"
msgstr "Sie müssen sich zuerst anmelden, bevor Sie fortfahren können"

msgid "Change"
msgstr "Ändern"

Expand Down Expand Up @@ -611,6 +615,10 @@ msgstr "Produkt nicht verfügbar in {allLabels}"
msgid "Products"
msgstr "Produkte"

#. js-lingui-generated-id
msgid "An error occurred while processing your payment. Please contact the store owner"
msgstr "Bei der Bearbeitung Ihrer Zahlung ist ein Fehler aufgetreten. Bitte kontaktieren Sie den Ladenbesitzer"

#. js-lingui-generated-id
msgid "Results for ‘{search}’"
msgstr "Ergebnisse für ‘{search}’"
Expand All @@ -619,6 +627,10 @@ msgstr "Ergebnisse für ‘{search}’"
msgid "Telephone"
msgstr "Telefon"

#. js-lingui-generated-id
msgid "Please login to add products to your cart"
msgstr "Bitte loggen Sie sich ein, um Produkte zu Ihrem Warenkorb hinzuzufügen"

msgid "Recently viewed products"
msgstr "Kürzlich angesehene Produkte"

Expand Down Expand Up @@ -715,11 +727,14 @@ msgstr "Abmelden"
msgid "Sign up for our newsletter and stay updated"
msgstr "Abonnieren Sie unseren Newsletter und bleiben Sie auf dem Laufenden"

msgid "Sign up is disabled, please contact us for more information."
msgstr "Die Anmeldung ist deaktiviert, bitte kontaktieren Sie uns für weitere Informationen."

msgid "Skip to main content"
msgstr "Zum Hauptinhalt springen"

msgid "Some items in your cart contain errors, please update or remove them, then try again."
msgstr "Einige Artikel im Warenkorb enthalten Fehler, bitte aktualisieren oder entfernen Sie diese, und versuchen Sie es erneut."
msgstr "Einige Artikel in Ihrem Warenkorb enthalten Fehler, bitte aktualisieren oder entfernen Sie sie, und versuchen Sie es erneut."

msgid "Something went wrong"
msgstr "Etwas ist schief gelaufen"
Expand Down Expand Up @@ -799,9 +814,6 @@ msgstr "Die Zahlung wurde abgelehnt, bitte versuchen Sie es erneut oder wählen
msgid "There is a maximum of ‘{maxLength}’ characters"
msgstr "Es gibt maximal '{maxLength}' Zeichen"

msgid "This cart is assigned to {email}. Please sign in to continue shopping."
msgstr "Dieser Warenkorb ist {email} zugewiesen. Bitte melden Sie sich an, um mit dem Einkauf fortzufahren."

msgid "This field is invalid"
msgstr "Dieses Feld ist ungültig"

Expand Down Expand Up @@ -922,6 +934,9 @@ msgstr "Sie müssen zustimmen, um fortfahren zu können"
msgid "You haven't placed any reviews yet"
msgstr "Sie haben noch keine Bewertungen abgegeben"

msgid "You must be signed in to continue"
msgstr "Sie müssen sich anmelden, um fortzufahren"

msgid "You must sign in to continue"
msgstr "Sie müssen sich anmelden, um fortzufahren"

Expand Down Expand Up @@ -1025,6 +1040,10 @@ msgstr "Auftrag erhalten"
msgid "one product"
msgstr "ein Produkt"

#. js-lingui-generated-id
msgid "Start Checkout"
msgstr "Zur Kasse gehen"

#. js-lingui-generated-id
msgid "Order not found"
msgstr "Bestellung nicht gefunden"
Expand All @@ -1049,6 +1068,10 @@ msgstr "Die angegebene E-Mail-Adresse stimmt nicht mit der Kontoe-Mail-Adresse
msgid "Message"
msgstr "Nachricht"

#. js-lingui-generated-id
msgid "Some items in your cart contain errors, please update or remove them, then try again."
msgstr "Einige Artikel im Warenkorb enthalten Fehler, bitte aktualisieren oder entfernen Sie diese, und versuchen Sie es erneut."

#. js-lingui-generated-id
msgid "Order details"
msgstr "Details zur Bestellung"
Expand Down
29 changes: 26 additions & 3 deletions examples/magento-graphcms/locales/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ msgstr "Categories"
msgid "Order #{orderNumber}"
msgstr "Order #{orderNumber}"

#. js-lingui-generated-id
msgid "You must first login before you can continue"
msgstr "You must first login before you can continue"

msgid "Change"
msgstr "Change"

Expand Down Expand Up @@ -611,6 +615,10 @@ msgstr "Product not available in {allLabels}"
msgid "Products"
msgstr "Products"

#. js-lingui-generated-id
msgid "An error occurred while processing your payment. Please contact the store owner"
msgstr "An error occurred while processing your payment. Please contact the store owner"

#. js-lingui-generated-id
msgid "Results for ‘{search}’"
msgstr "Results for ‘{search}’"
Expand All @@ -619,6 +627,10 @@ msgstr "Results for ‘{search}’"
msgid "Telephone"
msgstr "Telephone"

#. js-lingui-generated-id
msgid "Please login to add products to your cart"
msgstr "Please login to add products to your cart"

msgid "Recently viewed products"
msgstr "Recently viewed products"

Expand Down Expand Up @@ -715,6 +727,9 @@ msgstr "Sign out"
msgid "Sign up for our newsletter and stay updated"
msgstr "Sign up for our newsletter and stay updated"

msgid "Sign up is disabled, please contact us for more information."
msgstr "Sign up is disabled, please contact us for more information."

msgid "Skip to main content"
msgstr "Skip to main content"

Expand Down Expand Up @@ -799,9 +814,6 @@ msgstr "The payment is refused, please try again or select a different payment m
msgid "There is a maximum of ‘{maxLength}’ characters"
msgstr "There is a maximum of ‘{maxLength}’ characters"

msgid "This cart is assigned to {email}. Please sign in to continue shopping."
msgstr "This cart is assigned to {email}. Please sign in to continue shopping."

msgid "This field is invalid"
msgstr "This field is invalid"

Expand Down Expand Up @@ -922,6 +934,9 @@ msgstr "You have to agree in order to proceed"
msgid "You haven't placed any reviews yet"
msgstr "You haven't placed any reviews yet"

msgid "You must be signed in to continue"
msgstr "You must be signed in to continue"

msgid "You must sign in to continue"
msgstr "You must sign in to continue"

Expand Down Expand Up @@ -1025,6 +1040,10 @@ msgstr "Get order"
msgid "one product"
msgstr "one product"

#. js-lingui-generated-id
msgid "Start Checkout"
msgstr "Start Checkout"

#. js-lingui-generated-id
msgid "Order not found"
msgstr "Order not found"
Expand All @@ -1049,6 +1068,10 @@ msgstr "The given email does not match the account email"
msgid "Message"
msgstr "Message"

#. js-lingui-generated-id
msgid "Some items in your cart contain errors, please update or remove them, then try again."
msgstr "Some items in your cart contain errors, please update or remove them, then try again."

#. js-lingui-generated-id
msgid "Order details"
msgstr "Order details"
Expand Down
Loading

0 comments on commit 5a78713

Please sign in to comment.