Skip to content

Commit

Permalink
Merge pull request #29 from triwats/main
Browse files Browse the repository at this point in the history
allow pricing to be undefined
  • Loading branch information
nuotsu authored Oct 28, 2024
2 parents e17f92e + b432a06 commit 5992313
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
6 changes: 3 additions & 3 deletions sanity/schemas/documents/pricing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ export default defineType({
return {
title,
subtitle: [
price.base || 'Free',
price.strikethrough && `(${price.strikethrough})`,
price.suffix,
price?.base || 'Free',
price?.strikethrough && `(${price.strikethrough})`,
price?.suffix,
]
.filter(Boolean)
.join(' '),
Expand Down
2 changes: 1 addition & 1 deletion src/types/Sanity.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ declare global {
title: string
highlight?: string
price: {
base: number
base?: number
strikethrough?: number
suffix?: string
}
Expand Down
32 changes: 17 additions & 15 deletions src/ui/modules/PricingList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,23 @@ export default function PricingList({
</Pretitle>
</dt>

<dt className="flex flex-wrap items-end gap-x-2">
{!isNaN(tier.price.base) && (
<b className="h1">{formatPrice(tier.price.base)}</b>
)}
{tier.price.suffix && (
<span className={cn(isNaN(tier.price.base) && 'h1')}>
{tier.price.suffix}
</span>
)}
{tier.price.strikethrough && (
<s className="font-bold decoration-red-500">
{formatPrice(tier.price.strikethrough)}
</s>
)}
</dt>
{tier.price?.base !== undefined && (
<dt className="flex flex-wrap items-end gap-x-2">
{tier.price.base !== undefined && !isNaN(tier.price.base) && (
<b className="h1">{formatPrice(tier.price.base)}</b>
)}
{tier.price.suffix && (
<span className={cn(isNaN(tier.price.base) && 'h1')}>
{tier.price.suffix}
</span>
)}
{tier.price.strikethrough && (
<s className="font-bold decoration-red-500">
{formatPrice(tier.price?.strikethrough)}
</s>
)}
</dt>
)}
</div>

<dd>
Expand Down

0 comments on commit 5992313

Please sign in to comment.