Replace entire repo content with correct code from /root/shahikitchen-website/
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import type { WishlistRepository } from '@/domain/wishlist/repository';
|
||||
import type { WishlistItem } from '@/domain/wishlist/entities';
|
||||
import { STORAGE_KEYS } from '@/domain/shared/constants';
|
||||
|
||||
export class LocalStorageWishlistRepository implements WishlistRepository {
|
||||
load(): WishlistItem[] {
|
||||
if (typeof window === 'undefined') return [];
|
||||
|
||||
const raw = localStorage.getItem(STORAGE_KEYS.wishlist);
|
||||
if (!raw) return [];
|
||||
|
||||
try {
|
||||
const parsed = JSON.parse(raw) as WishlistItem[];
|
||||
return Array.isArray(parsed) ? parsed : [];
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
save(items: WishlistItem[]): void {
|
||||
if (typeof window === 'undefined') return;
|
||||
localStorage.setItem(STORAGE_KEYS.wishlist, JSON.stringify(items));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user