Skip to content
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

Cart upgrades #448

Merged
merged 6 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 10 additions & 25 deletions apps/web/vibes/soul/examples/pages/cart/electric.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getLineItems, getSubtotal } from '@/vibes/soul/data/line-items';
import { getLineItems } from '@/vibes/soul/data/line-items';
import { locales } from '@/vibes/soul/data/locales';
import { action } from '@/vibes/soul/examples/primitives/inline-email-form/actions';
import { localeAction } from '@/vibes/soul/examples/primitives/navigation/actions';
Expand Down Expand Up @@ -52,7 +52,6 @@ const paymentIconsArray: React.ReactNode[] = [

export default async function Preview() {
const lineItems = await getLineItems('Electric');
const subtotal = await getSubtotal('Electric');

return (
<>
Expand All @@ -73,31 +72,17 @@ export default async function Preview() {
/>

<Cart
checkoutAction={checkoutAction}
emptyState={{
title: 'Your cart is empty',
subtitle: 'Add some products to get started.',
cta: {
label: 'Continue shopping',
href: '#',
},
cart={{
lineItems,
summaryItems: [
{ label: 'Subtotal', value: '$100' },
{ label: 'Shipping', value: 'TBD' },
{ label: 'Tax', value: 'TBD' },
],
total: '127.60',
}}
checkoutAction={checkoutAction}
lineItemAction={lineItemAction}
lineItems={lineItems}
summary={{
title: 'Summary',
subtotal: subtotal,
caption: 'Shipping & taxes calculated at checkout',
subtotalLabel: 'Subtotal',
shippingLabel: 'Shipping',
shipping: 'TBD',
taxLabel: 'Tax',
tax: 'TBD',
// grandTotalLabel: 'Total',
// grandTotal: '$127.60',
ctaLabel: 'Checkout',
}}
title="Cart"
/>

<Subscribe
Expand Down
37 changes: 11 additions & 26 deletions apps/web/vibes/soul/examples/pages/cart/luxury.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getLineItems, getSubtotal } from '@/vibes/soul/data/line-items';
import { getLineItems } from '@/vibes/soul/data/line-items';
import { locales } from '@/vibes/soul/data/locales';
import { action } from '@/vibes/soul/examples/primitives/inline-email-form/actions';
import { localeAction } from '@/vibes/soul/examples/primitives/navigation/actions';
Expand Down Expand Up @@ -51,8 +51,7 @@ const paymentIconsArray: React.ReactNode[] = [
];

export default async function Preview() {
const lineItems = await getLineItems('Luxury');
const subtotal = await getSubtotal('Luxury');
const lineItems = await getLineItems('Warm');

return (
<>
Expand All @@ -73,31 +72,17 @@ export default async function Preview() {
/>

<Cart
checkoutAction={checkoutAction}
emptyState={{
title: 'Your cart is empty',
subtitle: 'Add some products to get started.',
cta: {
label: 'Continue shopping',
href: '#',
},
cart={{
lineItems,
summaryItems: [
{ label: 'Subtotal', value: '$100' },
{ label: 'Shipping', value: 'TBD' },
{ label: 'Tax', value: 'TBD' },
],
total: '127.60',
}}
checkoutAction={checkoutAction}
lineItemAction={lineItemAction}
lineItems={lineItems}
summary={{
title: 'Summary',
subtotal: subtotal,
caption: 'Shipping & taxes calculated at checkout',
subtotalLabel: 'Subtotal',
shippingLabel: 'Shipping',
shipping: 'TBD',
taxLabel: 'Tax',
tax: 'TBD',
// grandTotalLabel: 'Total',
// grandTotal: '$127.60',
ctaLabel: 'Checkout',
}}
title="Cart"
/>

<Subscribe
Expand Down
36 changes: 10 additions & 26 deletions apps/web/vibes/soul/examples/pages/cart/warm.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getLineItems, getSubtotal } from '@/vibes/soul/data/line-items';
import { getLineItems } from '@/vibes/soul/data/line-items';
import { locales } from '@/vibes/soul/data/locales';
import { action } from '@/vibes/soul/examples/primitives/inline-email-form/actions';
import { localeAction } from '@/vibes/soul/examples/primitives/navigation/actions';
Expand Down Expand Up @@ -52,8 +52,6 @@ const paymentIconsArray: React.ReactNode[] = [

export default async function Preview() {
const lineItems = await getLineItems('Warm');
const subtotal = await getSubtotal('Warm');

return (
<>
<Banner id="example-banner">
Expand All @@ -73,31 +71,17 @@ export default async function Preview() {
/>

<Cart
checkoutAction={checkoutAction}
emptyState={{
title: 'Your cart is empty',
subtitle: 'Add some products to get started.',
cta: {
label: 'Continue shopping',
href: '#',
},
cart={{
lineItems,
summaryItems: [
{ label: 'Subtotal', value: '$100' },
{ label: 'Shipping', value: 'TBD' },
{ label: 'Tax', value: 'TBD' },
],
total: '127.60',
}}
checkoutAction={checkoutAction}
lineItemAction={lineItemAction}
lineItems={lineItems}
summary={{
title: 'Summary',
subtotal: subtotal,
caption: 'Shipping & taxes calculated at checkout',
subtotalLabel: 'Subtotal',
shippingLabel: 'Shipping',
shipping: 'TBD',
taxLabel: 'Tax',
tax: 'TBD',
// grandTotalLabel: 'Total',
// grandTotal: '$127.60',
ctaLabel: 'Checkout',
}}
title="Cart"
/>

<Subscribe
Expand Down
42 changes: 12 additions & 30 deletions apps/web/vibes/soul/examples/sections/cart/electric.tsx
Original file line number Diff line number Diff line change
@@ -1,42 +1,24 @@
import { getLineItems, getSubtotal } from '@/vibes/soul/data/line-items';
import { Cart, CartLineItem } from '@/vibes/soul/sections/cart';
import { getLineItems } from '@/vibes/soul/data/line-items';
import { Cart } from '@/vibes/soul/sections/cart';

import { checkoutAction, lineItemAction } from './actions';

export default async function Preview() {
// const products = await getLineItems('Electric')
const lineItems = new Promise<CartLineItem[]>((res) =>
setTimeout(() => res(getLineItems('Electric')), 5000),
);
const subtotal = await getSubtotal('Electric');
const lineItems = await getLineItems('Electric');

return (
<Cart
checkoutAction={checkoutAction}
emptyState={{
title: 'Your cart is empty',
subtitle: 'Add some products to get started.',
cta: {
label: 'Continue shopping',
href: '#',
},
cart={{
lineItems,
summaryItems: [
{ label: 'Subtotal', value: '$100' },
{ label: 'Shipping', value: 'TBD' },
{ label: 'Tax', value: 'TBD' },
],
total: '127.60',
}}
checkoutAction={checkoutAction}
lineItemAction={lineItemAction}
lineItems={lineItems}
summary={{
title: 'Summary',
subtotal: subtotal,
caption: 'Shipping & taxes calculated at checkout',
subtotalLabel: 'Subtotal',
shippingLabel: 'Shipping',
shipping: 'TBD',
taxLabel: 'Tax',
tax: 'TBD',
// grandTotalLabel: 'Total',
// grandTotal: '$127.60',
ctaLabel: 'Checkout',
}}
title="Cart"
/>
);
}
46 changes: 14 additions & 32 deletions apps/web/vibes/soul/examples/sections/cart/loading-electric.tsx
Original file line number Diff line number Diff line change
@@ -1,43 +1,25 @@
import { getLineItems, getSubtotal } from '@/vibes/soul/data/line-items';
import { Cart, CartLineItem } from '@/vibes/soul/sections/cart';
import { getLineItems } from '@/vibes/soul/data/line-items';
import { Cart } from '@/vibes/soul/sections/cart';

import { checkoutAction, lineItemAction } from './actions';

export default function Preview() {
const lineItems = new Promise<CartLineItem[]>((res) =>
setTimeout(() => res(getLineItems('Electric')), 5000),
);
const subtotal = new Promise<string>((res) =>
setTimeout(() => res(getSubtotal('Electric')), 10000),
);
export default async function Preview() {
const lineItems = await getLineItems('Electric');

return (
<Cart
checkoutAction={checkoutAction}
emptyState={{
title: 'Your cart is empty',
subtitle: 'Add some products to get started.',
cta: {
label: 'Continue shopping',
href: '#',
},
cart={{
lineItems,
summaryItems: [
{ label: 'Subtotal', value: '$100' },
{ label: 'Shipping', value: 'TBD' },
{ label: 'Tax', value: 'TBD' },
],
total: '127.60',
totalLabel: 'Total',
}}
checkoutAction={checkoutAction}
lineItemAction={lineItemAction}
lineItems={lineItems}
summary={{
title: 'Summary',
subtotal: subtotal,
caption: 'Shipping & taxes calculated at checkout',
subtotalLabel: 'Subtotal',
shippingLabel: 'Shipping',
shipping: 'TBD',
taxLabel: 'Tax',
tax: 'TBD',
// grandTotalLabel: 'Total',
// grandTotal: '$127.60',
ctaLabel: 'Checkout',
}}
title="Cart"
/>
);
}
45 changes: 13 additions & 32 deletions apps/web/vibes/soul/examples/sections/cart/loading-luxury.tsx
Original file line number Diff line number Diff line change
@@ -1,43 +1,24 @@
import { getLineItems, getSubtotal } from '@/vibes/soul/data/line-items';
import { Cart, CartLineItem } from '@/vibes/soul/sections/cart';
import { getLineItems } from '@/vibes/soul/data/line-items';
import { Cart } from '@/vibes/soul/sections/cart';

import { checkoutAction, lineItemAction } from './actions';

export default function Preview() {
const lineItems = new Promise<CartLineItem[]>((res) =>
setTimeout(() => res(getLineItems('Luxury')), 5000),
);
const subtotal = new Promise<string>((res) =>
setTimeout(() => res(getSubtotal('Luxury')), 10000),
);
export default async function Preview() {
const lineItems = await getLineItems('Luxury');

return (
<Cart
checkoutAction={checkoutAction}
emptyState={{
title: 'Your cart is empty',
subtitle: 'Add some products to get started.',
cta: {
label: 'Continue shopping',
href: '#',
},
cart={{
lineItems,
summaryItems: [
{ label: 'Subtotal', value: '$100' },
{ label: 'Shipping', value: 'TBD' },
{ label: 'Tax', value: 'TBD' },
],
total: '127.60',
}}
checkoutAction={checkoutAction}
lineItemAction={lineItemAction}
lineItems={lineItems}
summary={{
title: 'Summary',
subtotal: subtotal,
caption: 'Shipping & taxes calculated at checkout',
subtotalLabel: 'Subtotal',
shippingLabel: 'Shipping',
shipping: 'TBD',
taxLabel: 'Tax',
tax: 'TBD',
// grandTotalLabel: 'Total',
// grandTotal: '$127.60',
ctaLabel: 'Checkout',
}}
title="Cart"
/>
);
}
43 changes: 13 additions & 30 deletions apps/web/vibes/soul/examples/sections/cart/loading-warm.tsx
Original file line number Diff line number Diff line change
@@ -1,41 +1,24 @@
import { getLineItems, getSubtotal } from '@/vibes/soul/data/line-items';
import { Cart, CartLineItem } from '@/vibes/soul/sections/cart';
import { getLineItems } from '@/vibes/soul/data/line-items';
import { Cart } from '@/vibes/soul/sections/cart';

import { checkoutAction, lineItemAction } from './actions';

export default function Preview() {
const lineItems = new Promise<CartLineItem[]>((res) =>
setTimeout(() => res(getLineItems('Warm')), 5000),
);
const subtotal = new Promise<string>((res) => setTimeout(() => res(getSubtotal('Warm')), 10000));
export default async function Preview() {
const lineItems = await getLineItems('Warm');

return (
<Cart
checkoutAction={checkoutAction}
emptyState={{
title: 'Your cart is empty',
subtitle: 'Add some products to get started.',
cta: {
label: 'Continue shopping',
href: '#',
},
cart={{
lineItems,
summaryItems: [
{ label: 'Subtotal', value: '$100' },
{ label: 'Shipping', value: 'TBD' },
{ label: 'Tax', value: 'TBD' },
],
total: '127.60',
}}
checkoutAction={checkoutAction}
lineItemAction={lineItemAction}
lineItems={lineItems}
summary={{
title: 'Summary',
subtotal: subtotal,
caption: 'Shipping & taxes calculated at checkout',
subtotalLabel: 'Subtotal',
shippingLabel: 'Shipping',
shipping: 'TBD',
taxLabel: 'Tax',
tax: 'TBD',
// grandTotalLabel: 'Total',
// grandTotal: '$127.60',
ctaLabel: 'Checkout',
}}
title="Cart"
/>
);
}
Loading