Fuckaway Windows line endings

This commit is contained in:
HugeFrog24
2026-02-11 18:17:50 +01:00
parent 39cbf58dbd
commit dd9bb4a24b
31 changed files with 1858 additions and 681 deletions

View File

@@ -0,0 +1,93 @@
'use client';
import { useEffect, useState } from 'react';
import { useRouter } from 'next/navigation';
import { useTranslations } from 'next-intl';
import { useFeature } from '../../../providers/FeatureProvider';
export default function CheckoutCancelPage() {
const router = useRouter();
const t = useTranslations('ui');
const paymentsEnabled = useFeature('paymentsEnabled');
const [countdown, setCountdown] = useState(5);
// Redirect home immediately if payments are disabled
useEffect(() => {
if (!paymentsEnabled) {
router.replace('/');
}
}, [paymentsEnabled, router]);
useEffect(() => {
if (!paymentsEnabled) return;
// Countdown timer to redirect to home
const timer = setInterval(() => {
setCountdown((prev) => {
if (prev <= 1) {
clearInterval(timer);
router.push('/');
return 0;
}
return prev - 1;
});
}, 1000);
return () => clearInterval(timer);
}, [router, paymentsEnabled]);
if (!paymentsEnabled) {
return null;
}
const handleGoBack = () => {
router.push('/');
};
return (
<div className="min-h-screen bg-gradient-to-br from-gray-50 to-gray-100 dark:from-gray-900 dark:to-gray-800 flex items-center justify-center p-4">
<div className="max-w-md w-full bg-white dark:bg-gray-800 rounded-lg shadow-xl p-8 text-center">
{/* Cancel Icon */}
<div className="w-16 h-16 mx-auto mb-6 bg-gray-100 dark:bg-gray-700 rounded-full flex items-center justify-center">
<svg className="w-8 h-8 text-gray-600 dark:text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
</svg>
</div>
{/* Cancel Message */}
<h1 className="text-2xl font-bold text-gray-900 dark:text-white mb-4">
{t('checkout.cancel.title')}
</h1>
<p className="text-gray-600 dark:text-gray-300 mb-6">
{t('checkout.cancel.message')}
</p>
<p className="text-gray-500 dark:text-gray-400 mb-6">
{t('checkout.cancel.tryAgain')}
</p>
{/* Action Buttons */}
<div className="space-y-3">
<button
onClick={handleGoBack}
className="w-full px-6 py-3 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors font-medium"
>
{t('checkout.cancel.backToApp')}
</button>
<p className="text-sm text-gray-500 dark:text-gray-400">
{t('checkout.cancel.redirecting', { countdown })}
</p>
</div>
{/* Help Info */}
<div className="mt-8 pt-6 border-t border-gray-200 dark:border-gray-700">
<p className="text-xs text-gray-500 dark:text-gray-400">
{t('checkout.cancel.needHelp')}
</p>
</div>
</div>
</div>
);
}

View File

@@ -0,0 +1,124 @@
'use client';
import { useEffect, useState } from 'react';
import { useSearchParams, useRouter } from 'next/navigation';
import { useTranslations } from 'next-intl';
import { appConfig } from '../../../config/app';
import { SkinId } from '../../../types';
import { useLocalizedSkinName } from '../../../hooks/useLocalizedSkinName';
import { useFeature } from '../../../providers/FeatureProvider';
export default function CheckoutSuccessPage() {
const searchParams = useSearchParams();
const router = useRouter();
const t = useTranslations('ui');
const getLocalizedSkinName = useLocalizedSkinName();
const paymentsEnabled = useFeature('paymentsEnabled');
const [countdown, setCountdown] = useState(5);
const skinId = searchParams.get('skin') as SkinId;
const skin = skinId ? appConfig.skins[skinId] : null;
const skinName = skinId ? getLocalizedSkinName(skinId) : '';
// Redirect home immediately if payments are disabled
useEffect(() => {
if (!paymentsEnabled) {
router.replace('/');
}
}, [paymentsEnabled, router]);
useEffect(() => {
if (!paymentsEnabled) return;
// Countdown timer to redirect to home
const timer = setInterval(() => {
setCountdown((prev) => {
if (prev <= 1) {
clearInterval(timer);
// Redirect to home with the purchased skin
const params = new URLSearchParams();
if (skinId && skinId !== appConfig.defaultSkin) {
params.set('skin', skinId);
}
const newUrl = `/${params.toString() ? '?' + params.toString() : ''}`;
router.push(newUrl);
return 0;
}
return prev - 1;
});
}, 1000);
return () => clearInterval(timer);
}, [skinId, router, paymentsEnabled]);
if (!paymentsEnabled) {
return null;
}
const handleGoToApp = () => {
const params = new URLSearchParams();
if (skinId && skinId !== appConfig.defaultSkin) {
params.set('skin', skinId);
}
const newUrl = `/${params.toString() ? '?' + params.toString() : ''}`;
router.push(newUrl);
};
return (
<div className="min-h-screen bg-gradient-to-br from-green-50 to-blue-50 dark:from-gray-900 dark:to-gray-800 flex items-center justify-center p-4">
<div className="max-w-md w-full bg-white dark:bg-gray-800 rounded-lg shadow-xl p-8 text-center">
{/* Success Icon */}
<div className="w-16 h-16 mx-auto mb-6 bg-green-100 dark:bg-green-900 rounded-full flex items-center justify-center">
<svg className="w-8 h-8 text-green-600 dark:text-green-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M5 13l4 4L19 7" />
</svg>
</div>
{/* Success Message */}
<h1 className="text-2xl font-bold text-gray-900 dark:text-white mb-4">
{t('checkout.success.title')}
</h1>
{skin && (
<div className="mb-6">
<div className="w-20 h-20 mx-auto mb-4 bg-gray-100 dark:bg-gray-700 rounded-lg flex items-center justify-center">
<img
src={skin.normal}
alt={skinName}
className="w-16 h-16"
/>
</div>
<p className="text-gray-600 dark:text-gray-300">
{t('checkout.success.unlockedSkin', { skinName })}
</p>
</div>
)}
<p className="text-gray-500 dark:text-gray-400 mb-6">
{t('checkout.success.thankYou')}
</p>
{/* Action Buttons */}
<div className="space-y-3">
<button
onClick={handleGoToApp}
className="w-full px-6 py-3 bg-green-600 hover:bg-green-700 text-white rounded-lg transition-colors font-medium"
>
{t('checkout.success.goToApp')}
</button>
<p className="text-sm text-gray-500 dark:text-gray-400">
{t('checkout.success.redirecting', { countdown })}
</p>
</div>
{/* Receipt Info */}
<div className="mt-8 pt-6 border-t border-gray-200 dark:border-gray-700">
<p className="text-xs text-gray-500 dark:text-gray-400">
{t('checkout.success.receiptSent')}
</p>
</div>
</div>
</div>
);
}

View File

@@ -31,17 +31,14 @@ export default function Home() {
const getLocalizedSkinName = useLocalizedSkinName();
const t = useTranslations('ui');
// Check if device motion is available and handle permissions
const requestMotionPermission = async () => {
if (typeof window === 'undefined') return;
// Check if device motion is available
if (!('DeviceMotionEvent' in window)) {
setMotionPermission('denied');
return;
}
// Request permission on iOS devices
if ('requestPermission' in DeviceMotionEvent) {
try {
// @ts-expect-error - TypeScript doesn't know about requestPermission
@@ -52,39 +49,32 @@ export default function Home() {
setMotionPermission('denied');
}
} else {
// Android or desktop - no permission needed
setMotionPermission('granted');
}
};
const triggerShake = useCallback((intensity: number) => {
// Use ref instead of state to prevent race conditions
if (!isAnimatingRef.current) {
// Clear any existing timeout
if (animationTimeoutRef.current) {
clearTimeout(animationTimeoutRef.current);
}
// Start shake animation
isAnimatingRef.current = true;
animationStartTimeRef.current = Date.now(); // Track when animation starts
animationStartTimeRef.current = Date.now();
setIsAnimating(true);
setIsShaken(true);
setShakeIntensity(intensity);
setShakeCount(count => count + 1);
// Reset shake after configured duration
animationTimeoutRef.current = setTimeout(() => {
setIsShaken(false);
setShakeIntensity(0);
setIsAnimating(false);
isAnimatingRef.current = false;
// Process next shake in queue if any
setShakeQueue(prev => {
if (prev.length > 0) {
const [nextIntensity, ...rest] = prev;
// Small delay before triggering next shake to ensure clean transition
setTimeout(() => {
triggerShake(nextIntensity);
}, 16);
@@ -94,17 +84,15 @@ export default function Home() {
});
}, shakeConfig.animations.shakeReset);
} else {
// Only queue if we're not at the start of the animation
const timeSinceStart = Date.now() - animationStartTimeRef.current;
if (timeSinceStart > 100) { // Only queue if animation has been running for a bit
if (timeSinceStart > 100) {
setShakeQueue(prev => {
// Hard limit at 1 item
if (prev.length >= 1) return prev;
return [...prev, intensity];
});
}
}
}, []); // Remove isAnimating from dependencies since we're using ref
}, []);
useEffect(() => {
const handleKeyPress = (event: KeyboardEvent) => {
@@ -133,7 +121,6 @@ export default function Home() {
}
};
// Only add motion listener if permission is granted
if (typeof window !== 'undefined') {
if (motionPermission === 'granted' && 'DeviceMotionEvent' in window) {
window.addEventListener('devicemotion', handleMotion);
@@ -151,20 +138,17 @@ export default function Home() {
};
}, [lastUpdate, motionPermission, triggerShake]);
// Initial permission check
useEffect(() => {
requestMotionPermission();
}, []);
const handleClick = () => {
// Trigger haptic feedback for tap interaction
if ('vibrate' in navigator) {
navigator.vibrate(50); // Short 50ms vibration
}
triggerShake(shakeConfig.defaultTriggerIntensity);
};
// Add cleanup in the component
useEffect(() => {
return () => {
if (animationTimeoutRef.current) {
@@ -249,3 +233,4 @@ export default function Home() {
</div>
);
}