@@ -9,7 +9,6 @@ import { Input } from "@/components/ui/input";
99import {
1010 Card ,
1111 CardContent ,
12- CardDescription ,
1312 CardHeader ,
1413 CardTitle ,
1514} from "@/components/ui/card" ;
@@ -21,6 +20,7 @@ import {
2120 SelectValue ,
2221} from "@/components/ui/select" ;
2322import { StravaConnectButton } from "@/components/integrations/strava-connect-button" ;
23+ import { parseDateOnlyToUtcMs } from "@/lib/date-only" ;
2424import {
2525 CheckCircle2 ,
2626 UserPlus ,
@@ -35,12 +35,22 @@ import {
3535 ChevronUp ,
3636} from "lucide-react" ;
3737
38+ function getOnboardingTitle ( startDate : string ) : string {
39+ const startMs = parseDateOnlyToUtcMs ( startDate ) ;
40+ const now = Date . now ( ) ;
41+ const daysUntilStart = Math . ceil ( ( startMs - now ) / ( 1000 * 60 * 60 * 24 ) ) ;
42+ if ( daysUntilStart > 1 ) return `${ daysUntilStart } days until the challenge` ;
43+ if ( daysUntilStart === 1 ) return "Challenge starts tomorrow" ;
44+ return "Getting started" ;
45+ }
46+
3847interface OnboardingCardProps {
3948 challengeId : string ;
4049 userId : string ;
50+ challengeStartDate : string ;
4151}
4252
43- export function OnboardingCard ( { challengeId, userId } : OnboardingCardProps ) {
53+ export function OnboardingCard ( { challengeId, userId, challengeStartDate } : OnboardingCardProps ) {
4454 const [ dismissed , setDismissed ] = useState ( false ) ;
4555 const [ expandedStep , setExpandedStep ] = useState < number | null > ( null ) ;
4656
@@ -127,13 +137,6 @@ export function OnboardingCard({ challengeId, userId }: OnboardingCardProps) {
127137 } ,
128138 ] ;
129139
130- const completedCount = steps . filter ( ( s ) => s . complete ) . length ;
131- // Don't count the invite step in total since it's never "complete"
132- const completableCount = steps . filter ( ( s ) => s . key !== "invite" ) . length ;
133- const completedCompletable = steps . filter (
134- ( s ) => s . key !== "invite" && s . complete
135- ) . length ;
136-
137140 const toggleStep = ( index : number ) => {
138141 setExpandedStep ( expandedStep === index ? null : index ) ;
139142 } ;
@@ -143,10 +146,7 @@ export function OnboardingCard({ challengeId, userId }: OnboardingCardProps) {
143146 < CardHeader className = "pb-3" >
144147 < div className = "flex items-center justify-between" >
145148 < div >
146- < CardTitle className = "text-base" > Get ready for the challenge</ CardTitle >
147- < CardDescription >
148- { completedCompletable } /{ completableCount } steps completed
149- </ CardDescription >
149+ < CardTitle className = "text-base" > { getOnboardingTitle ( challengeStartDate ) } </ CardTitle >
150150 </ div >
151151 { allCompletableStepsDone && (
152152 < Button
0 commit comments