Files
splitt-the-bill/app/composables/usePaymentLinkCache.ts
T
2026-07-01 15:43:18 +02:00

18 lines
541 B
TypeScript

import { readCachedPaymentLink, writeCachedPaymentLink } from '../utils/paymentLinkCache'
export function usePaymentLinkCache() {
const lastLink = useState<string | null>('payment-link-cache', () => null)
if (import.meta.client && lastLink.value === null) {
lastLink.value = readCachedPaymentLink(window.localStorage)
}
function rememberLink(link: string) {
if (!import.meta.client || !link) return
lastLink.value = link
writeCachedPaymentLink(window.localStorage, link)
}
return { lastLink, rememberLink }
}