Skip to content

Commit 1ec6827

Browse files
committed
add KYC bug, more Checkout Friction, break likes
this is my favorite commit.
1 parent 264405e commit 1ec6827

4 files changed

Lines changed: 715 additions & 216 deletions

File tree

‎app/checkout/payment/page.tsx‎

Lines changed: 79 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ export default function CheckoutPage() {
1818
const [isProcessing, setIsProcessing] = useState(false);
1919
const [orderComplete, setOrderComplete] = useState(false);
2020

21+
// State for moving checkout button
22+
const [checkoutButtonVisible, setCheckoutButtonVisible] = useState(true);
23+
const [buttonPosition, setButtonPosition] = useState(0); // 0 = default, 1-4 = alternate positions
24+
2125
// Form states
2226
const [email, setEmail] = useState("");
2327
const [firstName, setFirstName] = useState("");
@@ -46,6 +50,42 @@ export default function CheckoutPage() {
4650
}
4751
}, [currentStep]);
4852

53+
// THE MOVING CHECKOUT BUTTON! 🐛
54+
// Button disappears and reappears in a new location every 5 seconds (only on step 3)
55+
useEffect(() => {
56+
if (currentStep !== 3 || isProcessing || orderComplete) return;
57+
58+
const interval = setInterval(() => {
59+
// Hide button
60+
setCheckoutButtonVisible(false);
61+
62+
// Track button disappearance
63+
if (typeof window !== 'undefined' && window.mixpanel) {
64+
window.mixpanel.track('Checkout Button Disappeared', {
65+
order_value: orderTotal,
66+
previous_position: buttonPosition
67+
});
68+
}
69+
70+
// After 500ms, show in new position
71+
setTimeout(() => {
72+
const newPosition = Math.floor(Math.random() *85); // 0-4 random positions
73+
setButtonPosition(newPosition);
74+
setCheckoutButtonVisible(true);
75+
76+
// Track button reappearance
77+
if (typeof window !== 'undefined' && window.mixpanel) {
78+
window.mixpanel.track('Checkout Button Appeared', {
79+
order_value: orderTotal,
80+
new_position: newPosition
81+
});
82+
}
83+
}, 500);
84+
}, 2500); // Every 2.5 seconds
85+
86+
return () => clearInterval(interval);
87+
}, [currentStep, isProcessing, orderComplete, buttonPosition]);
88+
4989
const handleSubmitPayment = () => {
5090
setIsProcessing(true);
5191

@@ -226,7 +266,7 @@ export default function CheckoutPage() {
226266

227267
{/* Step 3: Payment */}
228268
{currentStep === 3 && (
229-
<div className="space-y-6">
269+
<div className="space-y-6 relative min-h-[500px]">
230270
<h2 className="text-xl font-semibold">Payment Information</h2>
231271
<div className="flex items-center gap-2 mb-4">
232272
<ShieldCheckIcon className="h-5 w-5 text-green-500" />
@@ -249,6 +289,8 @@ export default function CheckoutPage() {
249289
onChange={(e) => setCvv(e.target.value)}
250290
/>
251291
</div>
292+
293+
{/* Back Button - Always visible */}
252294
<div className="flex gap-4">
253295
<Button
254296
variant="outline"
@@ -257,14 +299,43 @@ export default function CheckoutPage() {
257299
>
258300
Back
259301
</Button>
260-
<Button
261-
onClick={handleSubmitPayment}
262-
disabled={!cardNumber || !expiryDate || !cvv || isProcessing}
263-
className="bg-[#07B096] hover:bg-[#07B096]/90"
302+
</div>
303+
304+
{/* Moving Checkout Button - Appears in different positions */}
305+
{checkoutButtonVisible && (
306+
<div
307+
className={`absolute transition-all duration-300 ${
308+
buttonPosition === 0 ? 'top-64 left-0' : ''
309+
} ${
310+
buttonPosition === 1 ? 'top-64 right-0' : ''
311+
} ${
312+
buttonPosition === 2 ? 'top-96 left-1/4' : ''
313+
} ${
314+
buttonPosition === 3 ? 'top-96 right-1/4' : ''
315+
} ${
316+
buttonPosition === 4 ? 'top-80 left-1/2 -translate-x-1/2' : ''
317+
}`}
318+
style={{
319+
opacity: checkoutButtonVisible ? 1 : 0,
320+
transform: checkoutButtonVisible ? 'scale(1)' : 'scale(0.8)'
321+
}}
264322
>
265-
<CreditCardIcon className="h-4 w-4 mr-2" />
266-
{isProcessing ? "Processing..." : `Complete Order ($${orderTotal.toFixed(2)})`}
267-
</Button>
323+
<Button
324+
onClick={handleSubmitPayment}
325+
disabled={!cardNumber || !expiryDate || !cvv || isProcessing}
326+
className="bg-[#07B096] hover:bg-[#07B096]/90 shadow-lg"
327+
>
328+
<CreditCardIcon className="h-4 w-4 mr-2" />
329+
{isProcessing ? "Processing..." : `Complete Order ($${orderTotal.toFixed(2)})`}
330+
</Button>
331+
</div>
332+
)}
333+
334+
{/* Demo Note */}
335+
<div className="mt-8 p-4 bg-yellow-50 border border-yellow-200 rounded-lg">
336+
<p className="text-sm text-yellow-800">
337+
💡 <strong>Demo Note:</strong> The checkout button disappears and reappears in a random location every 5 seconds to simulate a frustrating UX bug that analytics can help identify!
338+
</p>
268339
</div>
269340
</div>
270341
)}

0 commit comments

Comments
 (0)