@@ -70,6 +70,7 @@ import {
7070import { toast } from '@/hooks/use-toast' ;
7171import { string } from 'zod' ;
7272import { Avatar , AvatarFallback , AvatarImage } from "@/components/ui/avatar" ;
73+ import { useRouter } from 'next/navigation' ;
7374
7475interface CorporateChallengeDetailsProps {
7576 challenge : CorporateChallenge | null ;
@@ -221,7 +222,7 @@ export default function CorporateChallengeDetails({
221222 const [ deleteAnnouncementId , setDeleteAnnouncementId ] = useState < string | null > ( null ) ;
222223 const [ isFetchingAnnouncements , setIsFetchingAnnouncements ] = useState ( false ) ;
223224 const [ hasAgreed , setHasAgreed ] = useState ( false ) ;
224-
225+ const router = useRouter ( ) ;
225226 const handleScrollCapture = ( e : React . UIEvent < HTMLDivElement > ) => {
226227 const el = e . currentTarget ;
227228 setScrolled ( el . scrollTop > 0 ) ;
@@ -407,11 +408,11 @@ export default function CorporateChallengeDetails({
407408 let tooltipContent = null ;
408409 if ( ! isLoggedIn ) {
409410 tooltipContent = < p > Please login to view the problem statement's</ p > ;
410- } // else if (!hasSubscription) {
411- // tooltipContent = (
412- // <p>Subscribe to a plan to view and submit the solution</p>
413- // );
414- else if ( isOtherUsers ) {
411+ } else if ( ! hasSubscription ) {
412+ tooltipContent = (
413+ < p > Subscribe to a plan to view and submit the solution</ p >
414+ ) ;
415+ } else if ( isOtherUsers ) {
415416 tooltipContent = (
416417 < p > { "Solution submission is not allowed for your role." } </ p >
417418 )
@@ -471,13 +472,25 @@ export default function CorporateChallengeDetails({
471472 < div >
472473
473474 < DialogTitle className = "text-3xl font-bold font-headline text-left" >
474- { challenge . company_name ? < span className = 'text-black' > { challenge . company_name . replace ( / x / gi, '█' ) } </ span > : '' }
475+ { challenge . company_name ? (
476+ < span className = "text-black blur-sm" > { challenge . company_name } </ span >
477+ ) : '' }
475478 </ DialogTitle >
476479 < div className = "text-left flex flex-col gap-2" >
477480 < DialogDescription className = "line-clamp-3" >
478481 { challenge . company_description }
479482 </ DialogDescription >
480- < p className = "text-sm text-muted-foreground" > A challenge by { challenge . company_name ? challenge . company_name . replace ( / x / gi, '█' ) : '' } { challenge . affiliated_by && < span className = "text-muted-foreground font-bold font-headline" > (Affiliated By { challenge . affiliated_by } )</ span > } </ p >
483+ < p className = "text-sm text-muted-foreground" >
484+ A challenge by{ ' ' }
485+ { challenge . company_name ? (
486+ < span className = "blur-sm" > { challenge . company_name } </ span >
487+ ) : '' } { ' ' }
488+ { challenge . affiliated_by && (
489+ < span className = "text-muted-foreground font-bold font-headline" >
490+ (Affiliated By { challenge . affiliated_by } )
491+ </ span >
492+ ) }
493+ </ p >
481494 </ div >
482495 </ div >
483496 </ div >
@@ -870,46 +883,59 @@ export default function CorporateChallengeDetails({
870883 < TooltipProvider >
871884 < Tooltip >
872885 < TooltipTrigger asChild >
873- { isChallengeExpiredOrStopped ? (
874- < div />
875- ) : isOtherUsers ? (
876- < div className = "flex gap-4 w-full justify-center" >
877- < Button disabled className = "bg-gray-400 cursor-not-allowed" >
878- Not Allowed
879- </ Button >
880- </ div >
881- ) : isAllowedFounder || isLoggedIn ? (
882- < Button
883- size = "lg"
884- className = "bg-accent hover:bg-accent/90 text-accent-foreground"
885- onClick = { ( ) => {
886- if ( hasAgreed ) {
887- setShowSubmissionForm ( true ) ;
888- } else {
889- setShowTermsDialog ( true ) ;
890- }
891- handleApplyClick ( challenge . id )
892- } }
893- disabled = { isDisabled || isSolutionSubmitted }
894- >
895- < Rocket className = "mr-2 h-5 w-5" />
896- { isSolutionSubmitted ? "Solution Submitted" : "Solve This Challenge" }
897- </ Button >
898- ) : (
899- < div className = "flex gap-4 w-full justify-center mt-4" >
900- < Button onClick = { ( ) => setActiveView ( "login" ) } > Login</ Button >
901-
886+ < div className = "inline-block" >
887+ { isChallengeExpiredOrStopped ? (
888+ < div />
889+ ) : isOtherUsers ? (
890+ < div className = "flex gap-4 w-full justify-center" >
891+ < Button disabled className = "bg-gray-400 cursor-not-allowed" >
892+ Not Allowed
893+ </ Button >
894+ </ div >
895+ ) : isAllowedFounder || isLoggedIn ? (
902896 < Button
903- onClick = { ( ) => setActiveView ( "signup" ) }
897+ size = "lg"
904898 className = "bg-accent hover:bg-accent/90 text-accent-foreground"
899+ onClick = { ( ) => {
900+ if ( ! hasSubscription ) {
901+ toast ( {
902+ title : "Subscription Required" ,
903+ description : "Please subscribe to a plan to access this challenge" ,
904+ variant : "default" ,
905+ } ) ;
906+ router . push ( '/pricing' ) ;
907+ return ;
908+ }
909+ if ( hasAgreed ) {
910+ setShowSubmissionForm ( true ) ;
911+ } else {
912+ setShowTermsDialog ( true ) ;
913+ }
914+ handleApplyClick ( challenge . id )
915+ } }
916+ disabled = { isDisabled || isSolutionSubmitted }
905917 >
906- Sign Up
918+ < Rocket className = "mr-2 h-5 w-5" />
919+ { isSolutionSubmitted ? "Solution Submitted" : "Solve This Challenge" }
907920 </ Button >
908- </ div >
909- ) }
921+ ) : (
922+ < div className = "flex gap-4 w-full justify-center mt-4" >
923+ < Button onClick = { ( ) => setActiveView ( "login" ) } > Login</ Button >
924+ < Button
925+ onClick = { ( ) => setActiveView ( "signup" ) }
926+ className = "bg-accent hover:bg-accent/90 text-accent-foreground"
927+ >
928+ Sign Up
929+ </ Button >
930+ </ div >
931+ ) }
932+ </ div >
910933 </ TooltipTrigger >
911-
912- { isDisabled && < TooltipContent > { tooltipContent } </ TooltipContent > }
934+ { isDisabled && ! isChallengeExpiredOrStopped && (
935+ < TooltipContent side = "top" align = "center" >
936+ { tooltipContent }
937+ </ TooltipContent >
938+ ) }
913939 </ Tooltip >
914940 </ TooltipProvider >
915941
0 commit comments