@@ -8,12 +8,20 @@ import type { CardFactory } from '@fiction/site/cardFactory'
8
8
9
9
import { getCheckoutUrl } from '@fiction/plugin-stripe/utils.js'
10
10
11
- async function purchaseUrl ( args : { priceLookupKey : string , fictionStripe ?: FictionStripe } ) {
12
- const { fictionStripe } = args
11
+ async function purchaseUrl ( args : { priceLookupKey : string , site : Site } ) {
12
+ const { site } = args
13
13
14
- const loginPath = '/auth'
14
+ const { fictionStripe , fictionUser } = site . fictionSites . fictionEnv . getService < { fictionStripe : FictionStripe } > ( )
15
15
16
- if ( ! fictionStripe ) {
16
+ const loginPath = '/app/auth?_reload=1'
17
+
18
+ if ( typeof window === 'undefined' ) {
19
+ return loginPath
20
+ }
21
+
22
+ const user = await fictionUser . userInitialized ( )
23
+
24
+ if ( ! fictionStripe || ! user ) {
17
25
return loginPath
18
26
}
19
27
@@ -25,8 +33,6 @@ export async function getPricingPage(args: { factory: CardFactory, site: Site })
25
33
26
34
const annualDiscountPercent = 30
27
35
28
- const { fictionStripe } = site . fictionSites . fictionEnv . getService < { fictionStripe : FictionStripe } > ( )
29
-
30
36
const pricingCard = await factory . fromTemplate < typeof pricingTemplate > ( {
31
37
templateId : 'cardPricingV1' ,
32
38
userConfig : {
@@ -35,8 +41,8 @@ export async function getPricingPage(args: { factory: CardFactory, site: Site })
35
41
layout : 'standard' ,
36
42
prices : [
37
43
{
38
- title : 'Free ' ,
39
- price : 0 ,
44
+ title : 'Standard ' ,
45
+ price : 9 ,
40
46
description : `Start building your audience` ,
41
47
variant : 'muted' ,
42
48
icon : { class : 'i-tabler-rocket' } ,
@@ -48,9 +54,10 @@ export async function getPricingPage(args: { factory: CardFactory, site: Site })
48
54
{ label : 'Email Support' } ,
49
55
] ,
50
56
button : {
51
- label : 'Start Free ' ,
57
+ label : 'Start Standard ' ,
52
58
icon : { class : 'i-tabler-rocket' } ,
53
- href : '#free-tier' ,
59
+ href : await purchaseUrl ( { site, priceLookupKey : 'standard_month' } ) ,
60
+ hrefAnnual : await purchaseUrl ( { site, priceLookupKey : 'standard_year' } ) ,
54
61
} ,
55
62
} ,
56
63
{
@@ -73,8 +80,8 @@ export async function getPricingPage(args: { factory: CardFactory, site: Site })
73
80
button : {
74
81
label : 'Start Pro Trial' ,
75
82
icon : { class : 'i-tabler-stars' } ,
76
- href : await purchaseUrl ( { fictionStripe , priceLookupKey : 'pro_month' } ) ,
77
- hrefAnnual : await purchaseUrl ( { fictionStripe , priceLookupKey : 'pro_year' } ) ,
83
+ href : await purchaseUrl ( { site , priceLookupKey : 'pro_month' } ) ,
84
+ hrefAnnual : await purchaseUrl ( { site , priceLookupKey : 'pro_year' } ) ,
78
85
} ,
79
86
} ,
80
87
{
@@ -98,8 +105,8 @@ export async function getPricingPage(args: { factory: CardFactory, site: Site })
98
105
button : {
99
106
label : 'Start Workshop Trial' ,
100
107
icon : { class : 'i-tabler-crown' } ,
101
- href : await purchaseUrl ( { fictionStripe , priceLookupKey : 'elite_month' } ) ,
102
- hrefAnnual : await purchaseUrl ( { fictionStripe , priceLookupKey : 'elite_year' } ) ,
108
+ href : await purchaseUrl ( { site , priceLookupKey : 'elite_month' } ) ,
109
+ hrefAnnual : await purchaseUrl ( { site , priceLookupKey : 'elite_year' } ) ,
103
110
} ,
104
111
} ,
105
112
] ,
0 commit comments