Skip to content

Conversation

@arif-u-ahmed
Copy link
Contributor

@arif-u-ahmed arif-u-ahmed commented Nov 17, 2025

Summary

Implements pause listing functionality for sharers, allowing them to pause active listings which removes them from search results while retaining reservation history.

Changes

  • Added pause application service (pause.ts) following cancel pattern
  • Added pauseItemListing GraphQL mutation and resolver
  • Updated UI components with pause button and confirmation modal (Popconfirm)
  • Added state mapping for domain states to UI statuses
  • Filtered paused listings from reservers' search results in itemListings query

Implementation Details

  • Application service uses Unit of Work pattern with transaction scoping
  • GraphQL mutation includes authentication checks
  • UI uses Ant Design Popconfirm for confirmation modal
  • Paused listings are automatically excluded from search results for reservers
  • State mapping converts domain states (Published → Active, etc.) for UI display

Testing

  • All files pass linting
  • GraphQL types generated successfully
  • Unit tests and Storybook updates added

Related

Closes #42

Checklist

  • Code follows project patterns and conventions
  • GraphQL types generated
  • No linting errors
  • Follows instruction markdown requirements
  • Unit tests added
  • Storybook stories updated

Summary by Sourcery

Enable sharers to pause active listings by adding backend service, GraphQL mutation, and UI controls while filtering paused listings from search results and standardizing status display.

New Features:

  • Implement pause listing application service with transactional Unit of Work
  • Add pauseItemListing GraphQL mutation and resolver with authentication
  • Introduce pause button and confirmation modal in My Listings UI

Bug Fixes:

  • Exclude paused listings from itemListings query results for reservers

Enhancements:

  • Map domain listing states to consistent UI statuses

- Add pause application service following cancel pattern
- Add pauseItemListing GraphQL mutation and resolver
- Update UI components with pause button and confirmation modal
- Filter paused listings from reservers' search results
- Add state mapping for domain to UI status conversion

Implements pause listing feature per issue #42 requirements.
Allows sharers to pause active listings, removing them from search
results while retaining reservation history.
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Nov 17, 2025

Reviewer's Guide

This PR adds a ‘pause listing’ feature by introducing a new application service with transaction scoping, extending the GraphQL API with a pauseItemListing mutation and filtering logic, and integrating the pause action into the client UI with state mapping and confirmation dialogs.

Sequence diagram for pausing a listing via GraphQL mutation

sequenceDiagram
actor User
participant UI
participant GraphQL
participant ApplicationService
participant DataSource
User->>UI: Clicks "Pause" button
UI->>GraphQL: pauseItemListing(id)
GraphQL->>ApplicationService: pause({ id })
ApplicationService->>DataSource: withScopedTransaction(repo)
DataSource->>ApplicationService: getById(id)
ApplicationService->>DataSource: listing.pause() & repo.save(listing)
DataSource-->>ApplicationService: Paused listing entity
ApplicationService-->>GraphQL: Paused listing entity
GraphQL-->>UI: Paused listing entity
UI-->>User: Show success message
Loading

Class diagram for ItemListingApplicationService and pause command

classDiagram
    class ItemListingApplicationService {
      +cancel(command)
      +pause(command)
      +queryPaged(command)
      +update(command)
      // ... other methods
    }
    class ItemListingPauseCommand {
      +id: string
    }
    ItemListingApplicationService --> ItemListingPauseCommand
    class ItemListing {
      +pause()
      +state: string
      // ... other fields and methods
    }
    ItemListingApplicationService --> ItemListing
    ItemListingPauseCommand --> ItemListing
Loading

File-Level Changes

Change Details Files
Introduce pause functionality in application service
  • Create ItemListingPauseCommand and pause handler using Unit of Work pattern
  • Throw errors if listing not found or pause fails
  • Expose pause method in ItemListing application service index
packages/sthrift/application-services/src/contexts/listing/item/pause.ts
packages/sthrift/application-services/src/contexts/listing/item/index.ts
Extend GraphQL API with pauseItemListing and filter logic
  • Add pauseItemListing mutation to schema
  • Implement pauseItemListing resolver with authentication check
  • Filter out listings with state ‘Paused’ in itemListings query
packages/sthrift/graphql/src/schema/types/listing/item-listing.graphql
packages/sthrift/graphql/src/schema/types/listing/item-listing.resolvers.ts
Integrate pauseItemListing mutation on client
  • Add pauseItemListing GraphQL mutation fragment
  • Use useMutation hook with success and error handlers
  • Refetch listings after pause completes
apps/ui-sharethrift/src/components/layouts/home/my-listings/components/all-listings-table.container.tsx
apps/ui-sharethrift/src/components/layouts/home/my-listings/components/all-listings-table.container.graphql
Add Pause action UI with confirmation modal
  • Wrap Pause button in Ant Design Popconfirm for both table and card views
  • Trigger onAction('pause', id) on confirm
  • Display success and error messages on pause completion
apps/ui-sharethrift/src/components/layouts/home/my-listings/components/all-listings-card.tsx
apps/ui-sharethrift/src/components/layouts/home/my-listings/components/all-listings-table.tsx
Map domain listing states to UI statuses
  • Implement mapDomainStateToUIStatus function for state-to-status translation
  • Use mapped status in listings table container
apps/ui-sharethrift/src/components/layouts/home/my-listings/components/all-listings-table.container.tsx

Assessment against linked issues

Issue Objective Addressed Explanation
#42 Implement pause listing functionality so that a Sharer can pause their own listing from the management UI, with a confirmation modal, and only the owner can perform this action.
#42 When paused, the listing must change state from active to paused, be removed from search/browse results for reservers, and retain all reservation history.
#42 Integrate with backend API to update listing state, send notification, and show success/error feedback using Ant Design message, following accessibility, error, and loading patterns as for Edit Listing.

Possibly linked issues

  • Listing - Pause Listing #42: The PR implements the core pause listing functionality, including UI, backend mutations, state changes, and removal from search results, directly addressing the issue's requirements.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

sourcery-ai[bot]

This comment was marked as outdated.

@arif-u-ahmed arif-u-ahmed marked this pull request as draft November 17, 2025 18:08
@arif-u-ahmed arif-u-ahmed self-assigned this Nov 17, 2025
- Add GraphQL resolver tests for pauseItemListing mutation
- Add application service unit tests for pause functionality
- Add container component tests with state mapping verification
- Update Storybook stories with pause action scenarios
- Add feature file scenarios for pause listing resolver

Completes test coverage requirements per instruction markdowns.

This comment was marked as outdated.

Resolved conflicts in pnpm-lock.yaml:
- Kept rimraf@^6.1.0 (security upgrade from feature branch)
- Kept only glob@11.1.0 (removed glob@10.4.5 per feature branch security override)
Resolved conflicts in:
- application-services/src/contexts/listing/item/index.ts
  * Merged pause, delete, update, and unblock methods
- graphql/src/schema/types/listing/item-listing.graphql
  * Added pauseItemListing alongside cancelItemListing and deleteItemListing
  * Updated cancelItemListing and deleteItemListing to return ItemListingMutationResult
- graphql/src/schema/types/listing/item-listing.resolvers.ts
  * Added pauseItemListing mutation resolver
  * Fixed cancelItemListing and deleteItemListing to return proper mutation result structure
  * Kept filtering of paused listings in itemListings query
- graphql/src/schema/types/listing/item-listing.resolvers.test.ts
  * Merged mock context to include all methods (pause, deleteListings, unblock)
  * Added pause listing test scenarios
- ui-sharethrift/src/components/layouts/home/my-listings/components/all-listings-table.container.graphql
  * Merged pauseItemListing, cancelItemListing, and deleteItemListing mutations
- ui-sharethrift/src/components/layouts/home/my-listings/components/all-listings-table.container.tsx
  * Integrated pause, cancel, and delete mutations
  * Kept mapDomainStateToUIStatus helper for state mapping

Regenerated GraphQL types via pnpm run gen
- Removed unused mapDomainStateToUIStatus function causing TS6133 error
- Function was not being used anywhere in the component
- Fixes Azure Pipeline build failure
- Inline immediately returned variable in pauseItemListing resolver
- Add ownership verification to pause listing functionality
  - Only the listing owner (sharer) can pause their listing
  - Prevents unauthorized users from pausing listings
- Optimize paused listing filtering by pushing to database layer
  - Move filter from in-memory to MongoDB query using $nin operator
  - Improves performance by avoiding loading all listings into memory
  - Add excludeStates parameter to ItemListingQueryAllCommand

Security: Implements authorization check for pause action
Performance: Database-level filtering instead of application-level
…atures

- Update queryAll expectations to include excludeStates: ['Paused']
- Update pause expectations to include userEmail parameter
- Fixes tests after implementing Sourcery code review suggestions
Resolved conflicts by merging both pause listing and delete listing features:
- Kept pause listing functionality from feature branch
- Integrated delete listing and other updates from main
- Updated dependencies to match main branch versions
- Merged test scripts and build configurations
- Preserved both pause and delete mutations in GraphQL schema
- Combined handlers for both actions in UI components

Conflicts resolved in:
- Package files (root, apps, packages)
- GraphQL schema and resolvers
- Application service layer
- UI components and containers
- Test files
- pnpm-lock.yaml (accepted from main)
…ure/pause-listing

Resolved conflicts from remote changes:
- Updated pause mutation to include userEmail parameter
- Improved paused listing filtering to use database-level exclusion
- Merged formatting and code style updates
- Integrated query-all with excludeStates support

All pause listing functionality preserved and enhanced.
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.

Listing - Pause Listing

2 participants