Fix Subtraction Game link

The Subtraction Game link and copy link functionality have been fixed.
This commit is contained in:
gpt-engineer-app[bot] 2025-08-22 11:20:42 +00:00
parent eb41d56dc0
commit b6dddec259
2 changed files with 19 additions and 5 deletions

View file

@ -83,6 +83,7 @@ const App = () => (
<Route path="/themes/advanced-algorithms" element={<AdvancedAlgorithms />} /> <Route path="/themes/advanced-algorithms" element={<AdvancedAlgorithms />} />
<Route path="/themes/data-structures" element={<DataStructures />} /> <Route path="/themes/data-structures" element={<DataStructures />} />
<Route path="/themes/games" element={<Games />} /> <Route path="/themes/games" element={<Games />} />
<Route path="/themes/games/subtraction-game" element={<SubtractionGamePage />} />
<Route path="/themes/games/sim" element={<GameOfSimPage />} /> <Route path="/themes/games/sim" element={<GameOfSimPage />} />
<Route path="/themes/cards-math" element={<CardsMath />} /> <Route path="/themes/cards-math" element={<CardsMath />} />
<Route path="/themes/puzzles" element={<Puzzles />} /> <Route path="/themes/puzzles" element={<Puzzles />} />

View file

@ -45,7 +45,10 @@ const SocialShare: React.FC<SocialShareProps> = ({
}, [shareData.url, isOpen, toast]); }, [shareData.url, isOpen, toast]);
const copyToClipboard = async (text: string) => { const copyToClipboard = async (text: string) => {
console.log('Copy to clipboard called with text:', text);
if (!rateLimiter.isAllowed('clipboard', 10, 60000)) { if (!rateLimiter.isAllowed('clipboard', 10, 60000)) {
console.log('Rate limit exceeded for clipboard');
toast({ toast({
title: "Too many attempts", title: "Too many attempts",
description: "Please wait before copying again", description: "Please wait before copying again",
@ -55,8 +58,11 @@ const SocialShare: React.FC<SocialShareProps> = ({
} }
try { try {
console.log('Attempting to copy to clipboard...');
// Check if clipboard API is available // Check if clipboard API is available
if (!navigator.clipboard) { if (!navigator.clipboard) {
console.log('Clipboard API not available, using fallback');
// Fallback for older browsers or insecure contexts // Fallback for older browsers or insecure contexts
const textArea = document.createElement('textarea'); const textArea = document.createElement('textarea');
textArea.value = text; textArea.value = text;
@ -68,11 +74,16 @@ const SocialShare: React.FC<SocialShareProps> = ({
textArea.select(); textArea.select();
try { try {
document.execCommand('copy'); const success = document.execCommand('copy');
toast({ console.log('Fallback copy result:', success);
title: "Copied!", if (success) {
description: "Link copied to clipboard", toast({
}); title: "Copied!",
description: "Link copied to clipboard",
});
} else {
throw new Error('Copy command failed');
}
} catch (err) { } catch (err) {
console.error('Fallback copy failed:', err); console.error('Fallback copy failed:', err);
toast({ toast({
@ -86,7 +97,9 @@ const SocialShare: React.FC<SocialShareProps> = ({
return; return;
} }
console.log('Using modern clipboard API');
await navigator.clipboard.writeText(text); await navigator.clipboard.writeText(text);
console.log('Copy successful');
toast({ toast({
title: "Copied!", title: "Copied!",
description: "Link copied to clipboard", description: "Link copied to clipboard",