Refactor hooks and contexts for improved state management and modularity
Some checks are pending
Deploy to Test Environment / deploy-to-test (push) Has started running

- Updated `useActiveDeals` hook to include reset functionality for API calls.
- Enhanced `useApi` hook to provide a reset method for clearing state.
- Refactored `useAuth`, `useFlyers`, `useMasterItems`, `useModal`, and `useUserData` hooks to utilize context providers for better state management.
- Created new context files: `AuthContext`, `FlyersContext`, `MasterItemsContext`, `ModalContext`, and `UserDataContext` to encapsulate related state and logic.
- Updated tests for hooks to accommodate changes in context structure and reset functionality.
- Adjusted imports in `index.tsx` to reflect new context structure.
This commit is contained in:
2025-12-14 20:08:15 -08:00
parent d3e546d02f
commit 8274f4c871
21 changed files with 397 additions and 345 deletions

View File

@@ -1,5 +1,5 @@
// src/services/db/user.db.test.ts
import { describe, it, expect, vi, beforeEach, afterEach, type Mock } from 'vitest';
import { describe, it, expect, vi, beforeEach, afterEach, Mock } from 'vitest';
import { PoolClient } from 'pg';
// Mock the logger to prevent stderr noise during tests
@@ -458,10 +458,11 @@ describe('User DB Service', () => {
describe('exportUserData', () => {
// Import the mocked withTransaction helper
let withTransaction: any;
let withTransaction: Mock;
beforeEach(async () => {
const connDb = await import('./connection.db');
withTransaction = connDb.withTransaction;
// Cast to Mock for type-safe access to mock properties
withTransaction = connDb.withTransaction as Mock;
});
it('should call profile, watched items, and shopping list functions', async () => {