@@ -40,11 +40,13 @@ import {
4040 CardHeader ,
4141 CardTitle ,
4242} from "~/components/ui/card" ;
43+
4344import { useNewWhim } from "~/hooks/use-new-whim" ;
4445
4546export function LandingSecretForm ( ) {
4647 const { mutate : newWhim , isPending } = useNewWhim ( ) ;
4748 const [ message , setMessage ] = useState ( "" ) ;
49+ const [ maxAttempts , setMaxAttempts ] = useState ( 1 ) ;
4850 const [ isDialogOpen , setIsDialogOpen ] = useState ( false ) ;
4951 const [ isConfirmDialogOpen , setIsConfirmDialogOpen ] = useState ( false ) ;
5052 const [ whimResult , setWhimResult ] = useState < {
@@ -62,12 +64,13 @@ export function LandingSecretForm() {
6264 setIsConfirmDialogOpen ( false ) ;
6365
6466 newWhim (
65- { message } ,
67+ { message, maxAttempts } ,
6668 {
6769 onSuccess : ( data : { id : string ; otp : string } ) => {
6870 setWhimResult ( data ) ;
6971 setIsDialogOpen ( true ) ;
7072 setMessage ( "" ) ; // Clear the form
73+ setMaxAttempts ( 1 ) ; // Reset to default
7174 } ,
7275 }
7376 ) ;
@@ -120,14 +123,50 @@ export function LandingSecretForm() {
120123 />
121124 </ div >
122125
126+ { /* Max Attempts Selection */ }
127+ < div >
128+ < label className = "block text-sm font-medium text-slate-700 dark:text-slate-300 mb-3" >
129+ Access Limit
130+ </ label >
131+ < div className = "grid grid-cols-5 gap-2" >
132+ { [ 1 , 2 , 3 , 5 , 10 ] . map ( num => (
133+ < Button
134+ key = { num }
135+ type = "button"
136+ variant = { maxAttempts === num ? "default" : "outline" }
137+ size = "sm"
138+ onClick = { ( ) => setMaxAttempts ( num ) }
139+ disabled = { isPending }
140+ className = { `text-xs ${
141+ maxAttempts === num
142+ ? "bg-indigo-600 hover:bg-indigo-700 text-white"
143+ : "hover:bg-slate-50 dark:hover:bg-slate-700"
144+ } `}
145+ >
146+ { num }
147+ </ Button >
148+ ) ) }
149+ </ div >
150+ < p className = "text-xs text-slate-500 dark:text-slate-400 mt-2" >
151+ Number of times this whim can be accessed before
152+ self-destructing
153+ </ p >
154+ </ div >
155+
123156 < div className = "bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-3" >
124157 < div className = "flex items-start gap-2" >
125158 < Eye className = "w-4 h-4 text-blue-600 dark:text-blue-400 mt-0.5 flex-shrink-0" />
126159 < div className = "text-sm text-blue-800 dark:text-blue-200" >
127- < p className = "font-medium mb-1" > One-Time Access</ p >
160+ < p className = "font-medium mb-1" >
161+ { maxAttempts === 1
162+ ? "One-Time Access"
163+ : `${ maxAttempts } -Time Access` }
164+ </ p >
128165 < p className = "text-blue-700 dark:text-blue-300" >
129- Your secret will be permanently destroyed the moment someone
130- opens the link, even if it hasn't reached the expiry time.
166+ Your secret will be permanently destroyed after being
167+ accessed{ " " }
168+ { maxAttempts === 1 ? "once" : `${ maxAttempts } times` } , even
169+ if it hasn't reached the expiry time.
131170 </ p >
132171 </ div >
133172 </ div >
@@ -164,10 +203,10 @@ export function LandingSecretForm() {
164203 </ Tooltip >
165204 </ CardContent >
166205
167- < CardFooter className = "justify-center pt-3 pb-5 text-slate-500 dark:text-slate-400" >
206+ < CardFooter className = "justify-center -mb-2 -mt-3 text-slate-500 dark:text-slate-400" >
168207 < Shield className = "size-3 mr-1" />
169208 < p className = "text-sm" >
170- Your whim is encrypted • OTP protected • One-time access
209+ Your whim is encrypted • OTP protected • Limited access
171210 </ p >
172211 </ CardFooter >
173212 </ Card >
@@ -185,9 +224,9 @@ export function LandingSecretForm() {
185224 </ AlertDialogTitle >
186225 < AlertDialogDescription className = "text-left" >
187226 You're about to create a whim with the following message. This
188- secret will be encrypted and will{ " " }
189- < strong > self-destruct immediately </ strong > after being viewed
190- once.
227+ secret will be encrypted and will < strong > self-destruct </ strong > { " " }
228+ after being accessed { " " }
229+ { maxAttempts === 1 ? " once" : ` ${ maxAttempts } times` } .
191230 </ AlertDialogDescription >
192231 </ AlertDialogHeader >
193232
0 commit comments