Skip to content

Feature/saved terms mvp#33

Open
TimFau wants to merge 36 commits intomasterfrom
feature/saved-terms-mvp
Open

Feature/saved terms mvp#33
TimFau wants to merge 36 commits intomasterfrom
feature/saved-terms-mvp

Conversation

@TimFau
Copy link
Owner

@TimFau TimFau commented Jun 11, 2025

No description provided.

TimFau added 3 commits June 10, 2025 08:00
- Added SaveToBank component to handle saving terms with user authentication.
- Integrated CHECK_TERM_SAVED query to check if a term is already saved.
- Updated FlashCard component to include SaveToBank for saving terms directly from flashcards.
- Removed deprecated SaveTestButton component to streamline functionality.
…erms

- Introduced BATCH_UPDATE_TERMS, UPDATE_MULTIPLE_TERMS, and SAVE_MULTIPLE_TERMS mutations to handle batch operations for saving and updating terms.
- Enhanced DeckCard component to support saving multiple terms from a deck to the user's word bank with progress indication.
- Updated SaveToBank component to accommodate batch saving functionality, allowing for multiple terms to be saved in a single operation.
@TimFau TimFau self-assigned this Jun 11, 2025
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

- Replaced BATCH_UPDATE_TERMS with SAVE_MULTIPLE_TERMS for batch saving functionality.
- Adjusted the mutation to include a status field for newly created terms.
- Enhanced comments for clarity on batch operations.
cursor[bot]

This comment was marked as outdated.

TimFau added 6 commits June 11, 2025 08:11
…information

- Updated SAVE_TERM mutation to accept a user parameter for tracking saved terms.
- Modified SaveToBank component to pass the authenticated user's ID when saving terms.
- Adjusted DeckCard component to include user information in the term saving process.
- Removed batch saving functionality from SaveToBank for a streamlined single term save operation.
…ty with additional metadata

- Updated SAVE_TERM mutation to include new parameters for source deck ID, source term key, source definition, sync preference, and last synced timestamp.
- Modified DeckCard component to create saved term inputs with enhanced metadata for better tracking.
- Adjusted SaveToBank component to accept and combine additional metadata when saving terms.
- Introduced SavedTerm type definitions to standardize term input structure across components.
… saving

- Added CHECK_SYNCED_DECK query to verify if a deck is already synced before saving.
- Introduced CREATE_SYNCED_DECK mutation to create a record for synced decks.
- Updated DeckCard component to handle synced deck checks and create synced deck records upon saving terms.
- Enhanced user feedback by disabling the save button if the deck is already synced.
- Extract term bank logic into useTermBank custom hook
- Create dedicated TermBankDialog component
- Add proper TypeScript interfaces for GraphQL responses
- Improve error handling and state management
- Remove duplicate code and unused variables
- Add better type safety across term bank operations

This refactor improves code organization, maintainability, and type safety
while keeping the same functionality. The changes follow React + GraphQL +
TypeScript best practices by:
- Separating concerns between UI and business logic
- Using proper TypeScript types instead of any
- Centralizing term bank operations in a reusable hook
- Improving component composition and reusability
- Updated DeckCard component to use the term bank hook for state management
- Removed local state variables for dialog and saving state
- Ensured the save dialog closes properly after saving a deck
- Improved progress indicator to reflect saving state from the hook

This fix addresses the issue where the save confirmation dialog would not close after completing the save operation, enhancing user experience and ensuring proper state management.
cursor[bot]

This comment was marked as outdated.

- Implemented the Word Bank page to display all saved terms from the user's Word Bank.
- Added GraphQL query to fetch saved terms with pagination.
- Created SavedTermCard component to show term details including term, definition, language, and source deck ID.
- Integrated loading and error states for better user experience.
- Updated navigation to include a link to the Word Bank page.
cursor[bot]

This comment was marked as outdated.

TimFau added 2 commits June 12, 2025 23:25
- Created a dedicated login page to handle session expiration with a clear message.
- Updated AuthContext to manage session expiration and redirect users appropriately.
- Implemented Apollo Client error handling for 401 errors, triggering logout and redirecting to the login page.
- Refactored App component to expose AuthContext for Apollo error handling.
- Enhanced Login component to work as both a modal and standalone page.
- Removed duplicate Apollo Client configuration and ensured proper context usage for navigation.
- Fixed routing issues by ensuring BrowserRouter wraps the AuthContextProvider.
- Updated the hasMore calculation to check if the last fetch returned fewer than TERMS_PER_PAGE items.
- Handled potential undefined values for data and saved_terms to avoid TypeScript errors.
cursor[bot]

This comment was marked as outdated.

…ent linter errors

- Updated the pagination logic to correctly determine if more terms are available based on the last fetch results.
- Added a state variable `hasMore` to track the availability of more results.
- Removed unnecessary `component` prop from the Grid item to resolve TypeScript linter errors.
cursor[bot]

This comment was marked as outdated.

TimFau added 4 commits June 13, 2025 07:43
- Removed the call to open the login modal when rendering the Login component.
- Consolidated navigation logic into a single useEffect to prevent duplicate redirects.
- Ensured session expiry warning is still displayed when applicable.
- Refactored SAVE_TERM mutation to associate saved terms with existing users by ID.
- Updated SAVE_MULTIPLE_TERMS mutation to accept user ID as an object with an `id` property.
- Modified GET_SAVED_TERM_KEYS query to filter by source_deck.deck_id instead of source_deck.id.
- Adjusted SavedTermInput type to reflect changes in user and source_deck structures.
- Enhanced SaveToBank and useTermBank components to construct mutation variables correctly.
- Added validation checks for user ID and deck ID in SaveToBank component.
- Resolved GraphQL validation errors related to ID types and structures.
cursor[bot]

This comment was marked as outdated.

Added a robust check in the `prepareTermsForSaving` function to ensure that terms are not saved multiple times when saving both individual terms and entire decks. This check accounts for terms in both translation directions.
cursor[bot]

This comment was marked as outdated.

…th redirect to non-existing route

- Removed manual user assignment in SAVE_TERM and SAVE_MULTIPLE_TERMS mutations to rely on Directus's default user_created field.
- Updated related components and hooks to eliminate userId passing.
- Added "Save Deck to Term Bank" feature for created decks, allowing users to save terms directly from their decks.
cursor[bot]

This comment was marked as outdated.

- Introduced GET_DECK_BY_SHEET_ID query to retrieve deck details by ID.
- Updated SAVE_TERM mutation to use deck UUID for saving terms.
- Enhanced SaveToBank component to fetch deck information before saving terms.
- Modified SavedTermCard to navigate using both deck ID and name.
- Added GET_SAVED_TERMS query to fetch saved terms with detailed deck information.
- Removed deprecated savedTerms queries and updated types accordingly.
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@TimFau TimFau mentioned this pull request Jun 15, 2025
- Updated `useTermBank` to ensure terms are saved with the correct target language.
- Removed reliance on external packages for language checking.
- Adjusted logic in `FlashCard` to correctly determine and pass the target language.
- Ensured that the `language` field in saved terms reflects the target language instead of defaulting to English.
cursor[bot]

This comment was marked as outdated.

TimFau added 3 commits June 16, 2025 07:26
Added checks to ensure `deck.Language1` and `deck.Language2` are strings before calling `toLowerCase()`. This prevents potential runtime TypeErrors and ensures consistent behavior when determining the target language for the Word Bank.
…okups

The `getLanguageCode` function's direct lookup for language codes was failing due to case mismatches. The mapping of language names to ISO 639-1 codes has been updated to use lowercase keys, improving the efficiency of exact matches.
cursor[bot]

This comment was marked as outdated.

TimFau added 2 commits June 17, 2025 08:52
- Created SavedTermsReview component to facilitate the review of saved terms.
- Integrated state management for tracking current term, user responses, and session progress.
- Added functionality to fetch saved terms using GraphQL queries.
- Implemented flashcard UI for displaying terms and definitions with user interaction.
- Enhanced user experience with session progress tracking and response recording.
# Conflicts:
#	src/layouts/Main.tsx
cursor[bot]

This comment was marked as outdated.

TimFau added 2 commits June 17, 2025 19:22
- Added a dropdown to select the review direction (English → Translation or Translation → English) in the ReviewSession configuration.
- Updated flashcard display logic to reflect the selected review direction.
…e UI with flashCard

- Introduced AutoSpeakToggle for enabling automatic speech of questions during review sessions.
- Added StackedFlashCard component for improved flashcard UI, allowing users to reveal answers and pronounce questions.
- Updated ReviewSession to integrate new components and manage auto-speak preferences.
- Enhanced exit confirmation dialog to support dynamic titles and labels based on review context.
- Refactored styles for review page to utilize shared flashcard styles.
@TimFau
Copy link
Owner Author

TimFau commented Jun 18, 2025

bugbot run

cursor[bot]

This comment was marked as outdated.

- Updated SaveToBank component to use 'network-only' fetch policies for improved data consistency.
- Modified ReviewSession hook to accept userId as a parameter, ensuring user-specific data is fetched.
- Enhanced useReviewSession to include userToken in the context for secure API requests.
- Updated WordBankPage to implement 'network-only' fetch policies and include authorization headers for data operations.
temp
@TimFau
Copy link
Owner Author

TimFau commented Jun 18, 2025

bugbot run

cursor[bot]

This comment was marked as outdated.

…ession

Aligns the header casing with other GraphQL requests to ensure consistent authentication handling and avoid potential failures caused by case-sensitive HTTP header checks.
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Vite Alias Change Breaks Existing Imports

The Vite alias for 'hooks' was changed from src/hooks.ts to src/hooks (a directory). This breaks existing imports, such as import { useAppSelector, useAppDispatch } from 'hooks' (found in files like Header.tsx and UserHome.tsx), because they now attempt to resolve to src/hooks/index.ts, which does not exist, causing compilation errors.

vite.config.ts#L20-L21

store: resolve(__dirname, 'src/store'),
hooks: resolve(__dirname, 'src/hooks'),

Fix in Cursor


Was this report helpful? Give feedback by reacting with 👍 or 👎

…ries

# added utils/srs.ts with SM-2 algorithm
# enriched saved_terms schema usage (next_review_at, interval, ease_factor, repetition)
# new/update GraphQL ops: SAVE_TERM, UPDATE_SRS_DATA, GET__DUE_SAVED_TERMS
# created/updated SRS defaults on term save & bulk import
# enhanced review flow (useReviewSession, UI) to fetch only due cards, apply SM-2, and persist results
# guarded CHECK_TERM_SAVED with auth token via lazy query to avoid public-role validation errors
# updated TypeScript types to include SRS fields
#fixed date/string scalar mismatch in due-term queries
# BREAKING CHANGE: existing saved_terms rows need SRS fields populated (or use null-is-due filter)
@TimFau
Copy link
Owner Author

TimFau commented Jun 20, 2025

bugbot review

@TimFau
Copy link
Owner Author

TimFau commented Jun 20, 2025

bugbot run

TimFau added 2 commits June 20, 2025 22:11
Added a check to skip the GraphQL query in the useReviewSession hook until the authentication state is fully loaded and a valid user token is available. This prevents validation errors caused by unauthenticated requests after a full-page refresh.
• removed unused imports, props and state:
  – SaveToBank: `createSavedTermInput`, `metadata`
  – useTermBank: `userId` prop
  – useReviewSession: `userId` prop and `responses` state
  – Review/index: unused React import

• updated call-sites to match new hook signatures (DeckCard, ReviewSession)

• adjusted WordBank page for MUI v7:
  – replaced deprecated `item={true}` usage
  – introduced temporary `MGrid` alias (typed as any) to bypass strict Grid typings

• build now completes successfully (`yarn predeploy` passes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant