@@ -242,13 +242,16 @@ const $usedProFeatures = computed(
242242
243243const Publish = ( {
244244 project,
245- refresh ,
245+ timesLeft ,
246246 disabled,
247+ refresh,
247248} : {
248249 project : Project ;
249- refresh : ( ) => Promise < void > ;
250+ timesLeft : number ;
250251 disabled : boolean ;
252+ refresh : ( ) => Promise < void > ;
251253} ) => {
254+ const { maxPublishesAllowedPerUser } = useStore ( $userPlanFeatures ) ;
252255 const [ publishError , setPublishError ] = useState <
253256 undefined | JSX . Element | string
254257 > ( ) ;
@@ -379,6 +382,19 @@ const Publish = ({
379382 } ;
380383
381384 if ( status === "PUBLISHED" ) {
385+ toast . success (
386+ < >
387+ The project has been successfully published. The project is
388+ successfully published.{ " " }
389+ { hasProPlan === false && (
390+ < div >
391+ On the free plan, you have { timesLeft } out of{ " " }
392+ { maxPublishesAllowedPerUser } daily publications remaining. The
393+ counter resets tomorrow.
394+ </ div >
395+ ) }
396+ </ >
397+ ) ;
382398 break ;
383399 }
384400
@@ -601,6 +617,18 @@ const useCanAddDomain = () => {
601617 return { canAddDomain, maxDomainsAllowedPerUser } ;
602618} ;
603619
620+ const useUserPublishCount = ( ) => {
621+ const { load, data } = trpcClient . project . userPublishCount . useQuery ( ) ;
622+ const { maxPublishesAllowedPerUser } = useStore ( $userPlanFeatures ) ;
623+ useEffect ( ( ) => {
624+ load ( ) ;
625+ } , [ load ] ) ;
626+ return {
627+ userPublishCount : data ?. success ? data . data : 0 ,
628+ maxPublishesAllowedPerUser,
629+ } ;
630+ } ;
631+
604632const refreshProject = async ( ) => {
605633 const result = await nativeClient . domain . project . query (
606634 {
@@ -634,11 +662,29 @@ const Content = (props: {
634662 const projectState = "idle" ;
635663
636664 const { canAddDomain, maxDomainsAllowedPerUser } = useCanAddDomain ( ) ;
665+ const { userPublishCount, maxPublishesAllowedPerUser } =
666+ useUserPublishCount ( ) ;
637667
638668 return (
639669 < form >
640670 < ScrollArea >
641- { usedProFeatures . size > 0 && hasProPlan === false ? (
671+ { userPublishCount >= maxPublishesAllowedPerUser ? (
672+ < PanelBanner >
673+ < Text variant = "regularBold" >
674+ Upgrade to publish more than { maxPublishesAllowedPerUser } times
675+ per day:
676+ </ Text >
677+ < Link
678+ className = { buttonStyle ( { color : "gradient" } ) }
679+ color = "contrast"
680+ underline = "none"
681+ href = "https://webstudio.is/pricing"
682+ target = "_blank"
683+ >
684+ Upgrade
685+ </ Link >
686+ </ PanelBanner >
687+ ) : usedProFeatures . size > 0 && hasProPlan === false ? (
642688 < PanelBanner >
643689 < img
644690 src = { cmsUpgradeBanner }
@@ -719,7 +765,11 @@ const Content = (props: {
719765 < Publish
720766 project = { project }
721767 refresh = { refreshProject }
722- disabled = { usedProFeatures . size > 0 && hasProPlan === false }
768+ timesLeft = { maxPublishesAllowedPerUser - userPublishCount }
769+ disabled = {
770+ ( usedProFeatures . size > 0 && hasProPlan === false ) ||
771+ userPublishCount >= maxPublishesAllowedPerUser
772+ }
723773 />
724774 </ Flex >
725775 </ form >
0 commit comments