-
Notifications
You must be signed in to change notification settings - Fork 47
Storefront product grid and product details #1215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 13 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
a9f676b
Add storefront product grid with image support
wcole1-godaddy d9a5aef
load styles from provider for exported components
pbennett1-godaddy f28fb20
product details page with option tracking
pbennett1-godaddy 9ab5c9c
add storeId and clientId to gd provider context
pbennett1-godaddy e8cf37b
add cart and router link support
pbennett1-godaddy 009704b
comment out image dupe testing
pbennett1-godaddy a791386
Merge branch 'main' of https://github.com/godaddy/javascript into sto…
pbennett1-godaddy c6cde4b
update providers and skus query
pbennett1-godaddy 0c578af
add storefront schema
pbennett1-godaddy 19220b7
refactor gql for namespacing
pbennett1-godaddy e8e5057
fix input usage for storefront skus
pbennett1-godaddy ae1492f
load in attributes
pbennett1-godaddy a642c4a
add orders schemas and graphql
pbennett1-godaddy 295579e
Potential fix for code scanning alert no. 1: Incomplete URL scheme check
pbennett1-godaddy 635e559
Potential fix for code scanning alert no. 2: Incomplete URL scheme check
pbennett1-godaddy 8da4f66
add lucide to example nextjs app
pbennett1-godaddy d1d533d
replace sku with productId
pbennett1-godaddy e53ea92
add return URL logic back
pbennett1-godaddy 38627f9
use skuGroup for product-details
pbennett1-godaddy 3a88835
remove nuqs dep
pbennett1-godaddy 5117ea0
Small style updates to product grid and details
wcole1-godaddy 69b0029
add changeset
pbennett1-godaddy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,7 +42,7 @@ dist | |
| /blob-report/ | ||
| /playwright/.cache/ | ||
|
|
||
| schema.graphql | ||
| *.graphql | ||
|
|
||
| # macOS | ||
| .DS_Store | ||
|
|
||
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,40 @@ | ||
| 'use client'; | ||
|
|
||
| import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
| import { GoDaddyProvider } from '@godaddy/react'; | ||
| import { QueryClient } from '@tanstack/react-query'; | ||
| import { ReactQueryDevtools } from '@tanstack/react-query-devtools'; | ||
| import Link from 'next/link'; | ||
| import { NuqsAdapter } from 'nuqs/adapters/next/app'; | ||
| import { useState } from 'react'; | ||
|
|
||
| export function Providers({ children }: { children: React.ReactNode }) { | ||
| const [queryClient] = useState(() => new QueryClient()); | ||
| const [queryClient] = useState( | ||
| () => | ||
| new QueryClient({ | ||
| defaultOptions: { | ||
| queries: { | ||
| retry: false, | ||
| refetchOnWindowFocus: false, | ||
| }, | ||
| }, | ||
| }) | ||
| ); | ||
|
|
||
| return ( | ||
| <QueryClientProvider client={queryClient}>{children}</QueryClientProvider> | ||
| <NuqsAdapter> | ||
| <GoDaddyProvider | ||
| queryClient={queryClient} | ||
| apiHost={process.env.NEXT_PUBLIC_GODADDY_API_HOST} | ||
| storeId={process.env.NEXT_PUBLIC_GODADDY_STORE_ID} | ||
| clientId={process.env.NEXT_PUBLIC_GODADDY_CLIENT_ID} | ||
| Link={Link} | ||
| appearance={{ | ||
| variables: { primary: '#ff0000', 'primary-foreground': '#FFFFFF' }, | ||
| }} | ||
| > | ||
| {children} | ||
| <ReactQueryDevtools client={queryClient} initialIsOpen={false} /> | ||
| </GoDaddyProvider> | ||
| </NuqsAdapter> | ||
| ); | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| 'use client'; | ||
|
|
||
| import { CartLineItems, CartTotals } from '@godaddy/react'; | ||
|
|
||
| export default function CartPage() { | ||
| const items = [ | ||
| { | ||
| id: 'LineItem_2y0l7o6Oi4BW6fpSiKPX1hhBccU', | ||
| name: 'Box of cookies', | ||
| image: | ||
| 'https://isteam.dev-wsimg.com/ip/2f2e05ec-de6f-4a89-90f2-038c749655b0/cookies.webp', | ||
| quantity: 2, | ||
| originalPrice: 10.99, | ||
| price: 10.99, | ||
| notes: [], | ||
| }, | ||
| { | ||
| id: 'LineItem_2y0l9FykA04qp2pC6y3YZ0TbZFD', | ||
| name: 'Cupcakes', | ||
| image: | ||
| 'https://isteam.dev-wsimg.com/ip/2f2e05ec-de6f-4a89-90f2-038c749655b0/cupcakes.webp/:/rs=w:600,h:600', | ||
| quantity: 1, | ||
| originalPrice: 5.99, | ||
| price: 5.99, | ||
| notes: [], | ||
| }, | ||
| ]; | ||
|
|
||
| const totals = { | ||
| subtotal: 27.97, | ||
| discount: 0, | ||
| shipping: 0, | ||
| currency: 'USD', | ||
| itemCount: 3, | ||
| total: 27.97, | ||
| tip: 0, | ||
| taxes: 0, | ||
| enableDiscounts: false, | ||
| enableTaxes: true, | ||
| isTaxLoading: false, | ||
| }; | ||
|
|
||
| return ( | ||
| <div className='container px-4 py-8'> | ||
| <h1 className='text-2xl font-bold mb-6'>Cart</h1> | ||
| <div className='grid grid-cols-1 gap-8'> | ||
| <div> | ||
| <div className='bg-white rounded-lg shadow p-6'> | ||
| <h2 className='text-lg font-semibold mb-4'>Your Items</h2> | ||
| <CartLineItems items={items} /> | ||
| </div> | ||
| </div> | ||
| <div> | ||
| <div className='bg-white rounded-lg shadow p-6 sticky top-4'> | ||
| <h2 className='text-lg font-semibold mb-4'>Order Summary</h2> | ||
| <CartTotals {...totals} /> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import Cart from './cart'; | ||
|
|
||
| export default function StorePage() { | ||
| return ( | ||
| <div className='p-4'> | ||
| <Cart /> | ||
| </div> | ||
| ); | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| 'use client'; | ||
|
|
||
| import { Cart } from '@godaddy/react'; | ||
| import { ShoppingCart } from 'lucide-react'; | ||
| import { createContext, useContext, useState } from 'react'; | ||
|
|
||
| interface CartContextType { | ||
| openCart: () => void; | ||
| closeCart: () => void; | ||
| } | ||
|
|
||
| const CartContext = createContext<CartContextType | undefined>(undefined); | ||
|
|
||
| export function useCart() { | ||
| const context = useContext(CartContext); | ||
| if (!context) { | ||
| throw new Error('useCart must be used within CartProvider'); | ||
| } | ||
| return context; | ||
| } | ||
|
|
||
| export default function StoreLayout({ | ||
| children, | ||
| }: { | ||
| children: React.ReactNode; | ||
| }) { | ||
| const [isCartOpen, setIsCartOpen] = useState(false); | ||
|
|
||
| const openCart = () => setIsCartOpen(true); | ||
| const closeCart = () => setIsCartOpen(false); | ||
|
|
||
| return ( | ||
| <CartContext.Provider value={{ openCart, closeCart }}> | ||
| <section className='relative max-w-6xl mx-auto'> | ||
| {/* Cart toggle button */} | ||
| <button | ||
| onClick={openCart} | ||
| className='fixed top-4 right-4 z-40 bg-primary text-primary-foreground p-3 rounded-full shadow-lg hover:bg-primary/90 transition-colors' | ||
| aria-label='Open shopping cart' | ||
| > | ||
| <ShoppingCart className='h-6 w-6' /> | ||
| </button> | ||
|
|
||
| {children} | ||
|
|
||
| <Cart open={isCartOpen} onOpenChange={setIsCartOpen} /> | ||
| </section> | ||
| </CartContext.Provider> | ||
| ); | ||
| } | ||
|
|
||
| export { CartContext }; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import Products from './products'; | ||
|
|
||
| export default function StorePage() { | ||
| return ( | ||
| <div className='p-4'> | ||
| <Products /> | ||
| </div> | ||
| ); | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| 'use client'; | ||
|
|
||
| import { use } from 'react'; | ||
| import Product from '@/app/store/product/[skuId]/product'; | ||
|
|
||
| export default function ProductPage({ | ||
| params, | ||
| }: { | ||
| params: Promise<{ skuId: string }>; | ||
| }) { | ||
| const { skuId } = use(params); | ||
|
|
||
| return ( | ||
| <div className='p-4'> | ||
| <Product skuId={skuId} /> | ||
| </div> | ||
| ); | ||
| } | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| 'use client'; | ||
|
|
||
| import { ProductDetails } from '@godaddy/react'; | ||
| import { ArrowLeft } from 'lucide-react'; | ||
| import Link from 'next/link'; | ||
|
|
||
| export default function Product({ skuId }: { skuId: string }) { | ||
| return ( | ||
| <div className='container mx-auto'> | ||
| <Link | ||
| href='/store' | ||
| className='inline-flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors mb-6' | ||
| > | ||
| <ArrowLeft className='h-4 w-4' /> | ||
| Back to Store | ||
| </Link> | ||
| <ProductDetails sku={skuId} /> | ||
pbennett1-godaddy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| </div> | ||
| ); | ||
| } | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| 'use client'; | ||
|
|
||
| import { ProductGrid } from '@godaddy/react'; | ||
|
|
||
| export default function ProductsPage() { | ||
| return ( | ||
| <div className='container mx-auto'> | ||
| <ProductGrid getProductHref={sku => `/store/product/${sku}`} /> | ||
| </div> | ||
| ); | ||
| } |
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
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
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
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
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
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
4 changes: 2 additions & 2 deletions
4
packages/react/src/components/checkout/discount/utils/use-discount-apply.ts
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.