@@ -326,7 +305,7 @@ export function Giveaways() {
)}
{/* Safety Filter */}
- {filters.status === 'active' && (
+ {status === 'active' && (
Safety:
@@ -413,27 +392,6 @@ export function Giveaways() {
);
}
-interface FilterButtonProps {
- active: boolean;
- onClick: () => void;
- children: React.ReactNode;
-}
-
-function FilterButton({ active, onClick, children }: FilterButtonProps) {
- return (
-
- );
-}
-
interface GiveawayCardProps {
giveaway: Giveaway;
onEnter: () => void;
diff --git a/frontend/src/stores/giveawayFiltersStore.test.ts b/frontend/src/stores/giveawayFiltersStore.test.ts
index f7e21a7..8b9f4a9 100644
--- a/frontend/src/stores/giveawayFiltersStore.test.ts
+++ b/frontend/src/stores/giveawayFiltersStore.test.ts
@@ -19,7 +19,7 @@ describe('giveawayFiltersStore', () => {
it('starts with default filters', () => {
const { filters } = useGiveawayFiltersStore.getState();
- expect(filters).toEqual({ status: 'active', limit: 20 });
+ expect(filters).toEqual({ limit: 20 });
});
it('merges partial updates', () => {
@@ -27,18 +27,18 @@ describe('giveawayFiltersStore', () => {
useGiveawayFiltersStore.getState().setFilters({ minChance: 0.5, endingWithin: 6 });
const { filters } = useGiveawayFiltersStore.getState();
- expect(filters.status).toBe('active');
+ expect(filters.limit).toBe(20);
expect(filters.minScore).toBe(7);
expect(filters.minChance).toBe(0.5);
expect(filters.endingWithin).toBe(6);
});
it('persists filters to localStorage', () => {
- useGiveawayFiltersStore.getState().setFilters({ minScore: 8, status: 'wishlist' });
+ useGiveawayFiltersStore.getState().setFilters({ minScore: 8, safetyFilter: 'safe' });
const persisted = lastPersistedState();
expect(persisted.filters.minScore).toBe(8);
- expect(persisted.filters.status).toBe('wishlist');
+ expect(persisted.filters.safetyFilter).toBe('safe');
});
it('does not persist the search query', () => {
@@ -56,7 +56,6 @@ describe('giveawayFiltersStore', () => {
useGiveawayFiltersStore.getState().resetFilters();
expect(useGiveawayFiltersStore.getState().filters).toEqual({
- status: 'active',
limit: 20,
});
});
diff --git a/frontend/src/stores/giveawayFiltersStore.ts b/frontend/src/stores/giveawayFiltersStore.ts
index eaa02d2..429a68f 100644
--- a/frontend/src/stores/giveawayFiltersStore.ts
+++ b/frontend/src/stores/giveawayFiltersStore.ts
@@ -2,7 +2,9 @@ import { create } from 'zustand';
import { persist } from 'zustand/middleware';
import type { GiveawayFilters } from '@/hooks/useGiveaways';
-type PersistedFilters = Omit;
+// The status (active/wishlist/entered) comes from the route, not the store —
+// each status is its own page in the sidebar.
+type PersistedFilters = Omit;
interface GiveawayFiltersState {
filters: PersistedFilters;
@@ -11,17 +13,16 @@ interface GiveawayFiltersState {
}
const DEFAULT_FILTERS: PersistedFilters = {
- status: 'active',
limit: 20,
};
/**
* Giveaways page filter store with localStorage persistence.
*
- * Keeps the selected tab, score/safety/chance/time filters across visits so
- * they don't have to be re-applied every time the page is opened. The search
- * query is deliberately NOT persisted (a stale search silently filtering the
- * list is more confusing than helpful).
+ * Keeps the score/safety/chance/time filters across visits so they don't
+ * have to be re-applied every time the page is opened. The search query is
+ * deliberately NOT persisted (a stale search silently filtering the list is
+ * more confusing than helpful).
*/
export const useGiveawayFiltersStore = create()(
persist(
@@ -33,6 +34,19 @@ export const useGiveawayFiltersStore = create()(
}),
{
name: 'giveaway-filters',
+ // v1: the selected tab (status) moved out of the store and into the
+ // route; strip it from state persisted by v0.
+ version: 1,
+ migrate: (persisted) => {
+ const state = persisted as {
+ filters?: PersistedFilters & { status?: string; search?: string };
+ };
+ if (state?.filters) {
+ delete state.filters.status;
+ delete state.filters.search;
+ }
+ return state as { filters: PersistedFilters & { search: undefined } };
+ },
partialize: (state) => ({
filters: { ...state.filters, search: undefined },
}),
diff --git a/frontend/src/types/index.ts b/frontend/src/types/index.ts
index 02d60b5..f4f97f9 100644
--- a/frontend/src/types/index.ts
+++ b/frontend/src/types/index.ts
@@ -222,6 +222,10 @@ export interface HealthCheck {
export interface ScanResult {
new: number;
updated: number;
+ wishlist_new?: number;
+ wishlist_updated?: number;
+ dlc_new?: number;
+ dlc_updated?: number;
pages_scanned: number;
scan_time: number;
skipped?: boolean;