11import * as entri from "entrijs" ;
22import { 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" ;
410import { trpcClient } from "~/shared/trpc/trpc-client" ;
11+ import { useStore } from "@nanostores/react" ;
12+ import { $userPlanFeatures } from "~/shared/nano-states" ;
13+ import { extractCname } from "./cname" ;
514
615// https://developers.entri.com/docs/install
716type DnsRecord = {
@@ -69,7 +78,8 @@ const useEntri = ({ domain, dnsRecords, onClose }: EntriProps) => {
6978 token : data . token ,
7079 dnsRecords,
7180 prefilledDomain : domain ,
72- wwwRedirect : true ,
81+ // add redirect to www only when registered domain has www subdomain
82+ wwwRedirect : extractCname ( domain ) === "www" ,
7383 } ) ;
7484 }
7585 } ) ;
@@ -86,6 +96,7 @@ const useEntri = ({ domain, dnsRecords, onClose }: EntriProps) => {
8696
8797export const Entri = ( { domain, dnsRecords, onClose } : EntriProps ) => {
8898 entriGlobalStyles ( ) ;
99+ const { hasProPlan } = useStore ( $userPlanFeatures ) ;
89100 const { error, isOpen, showDialog } = useEntri ( {
90101 domain,
91102 dnsRecords,
@@ -99,7 +110,16 @@ export const Entri = ({ domain, dnsRecords, onClose }: EntriProps) => {
99110 color = "neutral"
100111 css = { { width : "100%" , flexShrink : 0 } }
101112 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+ } }
103123 >
104124 Configure automatically
105125 </ Button >
0 commit comments