55  ShieldCheckIcon , 
66  XMarkIcon , 
77}  from  "@heroicons/react/20/solid" ; 
8- import  {  ArrowDownCircleIcon  }  from  "@heroicons/react/24/outline" ; 
8+ import  {  ArrowDownCircleIcon ,   ArrowUpCircleIcon  }  from  "@heroicons/react/24/outline" ; 
99import  {  Form ,  useLocation ,  useNavigation  }  from  "@remix-run/react" ; 
1010import  {  ActionFunctionArgs  }  from  "@remix-run/server-runtime" ; 
1111import  {  uiComponent  }  from  "@team-plain/typescript-sdk" ; 
@@ -633,6 +633,11 @@ export function TierPro({
633633  const  navigation  =  useNavigation ( ) ; 
634634  const  formAction  =  `/resources/orgs/${ organizationSlug }  /select-plan` ; 
635635  const  isLoading  =  navigation . formAction  ===  formAction ; 
636+   const  [ isDialogOpen ,  setIsDialogOpen ]  =  useState ( false ) ; 
637+ 
638+   useEffect ( ( )  =>  { 
639+     setIsDialogOpen ( false ) ; 
640+   } ,  [ subscription ] ) ; 
636641
637642  return  ( 
638643    < TierContainer > 
@@ -645,27 +650,66 @@ export function TierPro({
645650          < input  type = "hidden"  name = "type"  value = "paid"  /> 
646651          < input  type = "hidden"  name = "planCode"  value = { plan . code }  /> 
647652          < input  type = "hidden"  name = "callerPath"  value = { location . pathname }  /> 
648-           < Button 
649-             variant = "tertiary/large" 
650-             fullWidth 
651-             form = "subscribe-pro" 
652-             className = "text-md font-medium" 
653-             disabled = { 
654-               isLoading  || 
655-               ( subscription ?. plan ?. code  ===  plan . code  &&  subscription . canceledAt  ===  undefined ) 
656-             } 
657-             LeadingIcon = { 
658-               isLoading  &&  navigation . formData ?. get ( "planCode" )  ===  plan . code  ? Spinner  : undefined 
659-             } 
660-           > 
661-             { subscription ?. plan  ===  undefined 
662-               ? "Select plan" 
663-               : subscription . plan . type  ===  "free"  ||  subscription . canceledAt  !==  undefined 
664-               ? `Upgrade to ${ plan . title }  ` 
665-               : subscription . plan . code  ===  plan . code 
666-               ? "Current plan" 
667-               : `Upgrade to ${ plan . title }  ` } 
668-           </ Button > 
653+           { subscription ?. plan  !==  undefined  && 
654+           subscription ?. plan ?. title  ===  "Hobby"  && 
655+           subscription . canceledAt  ===  undefined  ? ( 
656+             < Dialog  open = { isDialogOpen }  onOpenChange = { setIsDialogOpen }  key = "upgrade" > 
657+               < DialogTrigger  asChild > 
658+                 < Button  variant = "tertiary/large"  fullWidth  className = "text-md font-medium" > 
659+                   { `Upgrade to ${ plan . title }  ` } 
660+                 </ Button > 
661+               </ DialogTrigger > 
662+               < DialogContent  className = "sm:max-w-md" > 
663+                 < DialogHeader > Upgrade plan?</ DialogHeader > 
664+                 < div  className = "mb-2 mt-4 flex items-start gap-3" > 
665+                   < span > 
666+                     < ArrowUpCircleIcon  className = "size-12 text-primary"  /> 
667+                   </ span > 
668+                   < Paragraph  variant = "base/bright"  className = "text-text-bright" > 
669+                     Are you sure you want to upgrade to the Pro plan? You will be charged the new
670+                     plan price for the remainder of this month on a pro rata basis.
671+                   </ Paragraph > 
672+                 </ div > 
673+                 < DialogFooter > 
674+                   < Button  variant = "tertiary/medium"  onClick = { ( )  =>  setIsDialogOpen ( false ) } > 
675+                     Cancel
676+                   </ Button > 
677+                   < Button 
678+                     variant = "primary/medium" 
679+                     disabled = { isLoading } 
680+                     LeadingIcon = { isLoading  ? ( )  =>  < Spinner  color = "dark"  />  : undefined } 
681+                     form = "subscribe-pro" 
682+                   > 
683+                     { `Upgrade to ${ plan . title }  ` } 
684+                   </ Button > 
685+                 </ DialogFooter > 
686+               </ DialogContent > 
687+             </ Dialog > 
688+           )  : ( 
689+             < Button 
690+               variant = "tertiary/large" 
691+               fullWidth 
692+               form = "subscribe-pro" 
693+               className = "text-md font-medium" 
694+               disabled = { 
695+                 isLoading  || 
696+                 ( subscription ?. plan ?. code  ===  plan . code  &&  subscription . canceledAt  ===  undefined ) 
697+               } 
698+               LeadingIcon = { 
699+                 isLoading  &&  navigation . formData ?. get ( "planCode" )  ===  plan . code 
700+                   ? Spinner 
701+                   : undefined 
702+               } 
703+             > 
704+               { subscription ?. plan  ===  undefined 
705+                 ? "Select plan" 
706+                 : subscription . plan . type  ===  "free"  ||  subscription . canceledAt  !==  undefined 
707+                 ? `Upgrade to ${ plan . title }  ` 
708+                 : subscription . plan . code  ===  plan . code 
709+                 ? "Current plan" 
710+                 : `Upgrade to ${ plan . title }  ` } 
711+             </ Button > 
712+           ) } 
669713        </ div > 
670714      </ Form > 
671715      < ul  className = "flex flex-col gap-2.5" > 
0 commit comments