1
1
import * as entri from "entrijs" ;
2
2
import { useEffect , useState } from "react" ;
3
- import { globalCss , Button , Text } from "@webstudio-is/design-system" ;
3
+ import {
4
+ globalCss ,
5
+ Button ,
6
+ Text ,
7
+ ProBadge ,
8
+ toast ,
9
+ } from "@webstudio-is/design-system" ;
4
10
import { trpcClient } from "~/shared/trpc/trpc-client" ;
11
+ import { useStore } from "@nanostores/react" ;
12
+ import { $userPlanFeatures } from "~/shared/nano-states" ;
13
+ import { extractCname } from "./cname" ;
5
14
6
15
// https://developers.entri.com/docs/install
7
16
type DnsRecord = {
@@ -69,7 +78,8 @@ const useEntri = ({ domain, dnsRecords, onClose }: EntriProps) => {
69
78
token : data . token ,
70
79
dnsRecords,
71
80
prefilledDomain : domain ,
72
- wwwRedirect : true ,
81
+ // add redirect to www only when registered domain has www subdomain
82
+ wwwRedirect : extractCname ( domain ) === "www" ,
73
83
} ) ;
74
84
}
75
85
} ) ;
@@ -86,6 +96,7 @@ const useEntri = ({ domain, dnsRecords, onClose }: EntriProps) => {
86
96
87
97
export const Entri = ( { domain, dnsRecords, onClose } : EntriProps ) => {
88
98
entriGlobalStyles ( ) ;
99
+ const { hasProPlan } = useStore ( $userPlanFeatures ) ;
89
100
const { error, isOpen, showDialog } = useEntri ( {
90
101
domain,
91
102
dnsRecords,
@@ -99,7 +110,16 @@ export const Entri = ({ domain, dnsRecords, onClose }: EntriProps) => {
99
110
color = "neutral"
100
111
css = { { width : "100%" , flexShrink : 0 } }
101
112
type = "button"
102
- onClick = { showDialog }
113
+ onClick = { ( ) => {
114
+ // @todo temporary for testing
115
+ if ( hasProPlan || true ) {
116
+ showDialog ( ) ;
117
+ } else {
118
+ toast . error (
119
+ "Please upgrade to the Pro plan or higher to use automatic domain configuration."
120
+ ) ;
121
+ }
122
+ } }
103
123
>
104
124
Configure automatically
105
125
</ Button >
0 commit comments