more refactor

This commit is contained in:
Shreyaschorge
2025-07-07 20:19:22 +05:30
parent cc84b0a882
commit bbc8d81613
8 changed files with 896 additions and 892 deletions

25
src/lib/localStorage.ts Normal file
View File

@@ -0,0 +1,25 @@
export function setItem<T>(key: string, value: T) {
try {
localStorage.setItem(key, JSON.stringify(value));
} catch (error) {
console.warn('Failed to save item:', error);
}
}
export function getItem<T>(key: string): T | null {
try {
const stored = localStorage.getItem(key);
return stored ? JSON.parse(stored) : null;
} catch (error) {
console.warn('Failed to load item:', error);
return null;
}
}
export function removeItem(key: string) {
try {
localStorage.removeItem(key);
} catch (error) {
console.warn('Failed to remove item:', error);
}
}