fix redeem link

This commit is contained in:
dohsimpson
2025-01-27 18:43:15 -05:00
parent b62cf77ba8
commit 7065d5694b
4 changed files with 32 additions and 1 deletions

View File

@@ -1,5 +1,11 @@
# Changelog
## Version 0.1.29
### Fixed
- actually working redeem link for wishlist items (#52)
## Version 0.1.28
### Added

View File

@@ -9,6 +9,8 @@ import WishlistItem from './WishlistItem'
import AddEditWishlistItemModal from './AddEditWishlistItemModal'
import ConfirmDialog from './ConfirmDialog'
import { WishlistItemType } from '@/lib/types'
import { openWindow } from '@/lib/utils'
import { toast } from '@/hooks/use-toast'
export default function WishlistManager() {
const {
@@ -62,6 +64,19 @@ export default function WishlistManager() {
setTimeout(() => {
setRecentlyRedeemedId(null)
}, 3000)
if (item.link) {
setTimeout(() => {
const opened = openWindow(item.link!)
if (!opened) {
toast({
title: "Popup Blocked",
description: "Please allow popups to open the link",
variant: "destructive"
})
}
}, 300)
}
}
}

View File

@@ -286,4 +286,14 @@ export const playSound = (soundPath: string = '/sounds/timer-end.wav') => {
audio.play().catch(error => {
console.error('Error playing sound:', error)
})
}
// open a new window (client side only, must be run in browser)
export const openWindow = (url: string): boolean => {
const newWindow = window.open(url, '_blank')
if (newWindow === null) {
// Popup was blocked
return false
}
return true
}

View File

@@ -1,6 +1,6 @@
{
"name": "habittrove",
"version": "0.1.28",
"version": "0.1.29",
"private": true,
"scripts": {
"dev": "next dev --turbopack",