Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 10, 2025

Implements the Edit Listing page for Sharers to modify active and draft listings. The page supports full CRUD operations with state transitions per business rules.

Backend Changes

Application Services

  • Extended update.ts to accept all listing fields (title, description, category, location, sharingPeriod, images) instead of just admin flags
  • Added pause.ts service for pausing listings (moves to Paused state)
  • Updated return type from void to ItemListingEntityReference for cache consistency

GraphQL Schema

  • Added UpdateItemListingInput with optional fields for partial updates
  • Added mutations: updateItemListing, pauseItemListing, deleteItemListing
  • All mutations return ItemListing for Apollo cache updates

Resolvers

  • Implemented null-safe field updates in updateItemListing
  • deleteItemListing uses soft delete pattern (sets isDeleted: true)
  • All mutations enforce authentication and ownership verification before operations
  • Added explicit ownership checks to ensure only the listing owner (sharer) can update, pause, delete, or cancel their listings

Resolver Helpers

  • Fixed PopulateUserFromField to return the full user object with userType augmented, preserving all user fields for clients

Frontend Changes

Components

  • edit-listing.container.tsx: GraphQL integration with 5 mutations (update, pause, delete, cancel), pre-populates form from query
  • edit-listing.tsx: Two-column layout (image gallery left, form right), confirmation modals for destructive actions
  • edit-listing-form.tsx: Conditionally renders Pause (Published only) and Cancel Listing (Published/Drafted/Paused) buttons based on listing state

Route Integration

  • Wired to /my-listings/user/:userId/:listingId/edit
  • Reuses ImageGallery from create-listing component

Usage

// Container fetches listing and provides CRUD operations
<EditListingContainer isAuthenticated={auth.isAuthenticated} />

// Form conditionally shows actions based on state
{canPause && <Button onClick={onPause}>Pause</Button>}
{canCancel && <Button onClick={onCancel}>Cancel Listing</Button>}

State transitions follow domain rules: Published → Paused, Published/Drafted/Paused → Cancelled, any → Deleted.

Other Fixes

  • Updated .gitignore to properly exclude **/node_modules and **/dist patterns

  • Removed accidentally committed build artifacts from packages/sthrift/service-twilio

  • Fixes Listing - Edit Listing #221

Original prompt

This section details on the original issue you should resolve

<issue_title>Listing - Edit Listing</issue_title>
<issue_description>## Context
This issue proposes the implementation of the Edit Listing page for Sharers, as depicted in the attached screenshot. This view enables users to edit details of an active or draft listing, consistent with design and requirements from the SRD/BRD documents.

References:

Requirements

  • Page must allow editing of the following listing fields:
    • Title
    • Location
    • Category (dropdown)
    • Reservation Period (date range picker)
    • Description (character count enforced)
    • Listing photos (image upload, preview, delete)
  • Listing actions:
    • Save Changes
    • Cancel
    • Delete (permanently removes listing)
    • Cancel Listing (moves to cancelled state, see SRD)
    • Pause (moves to paused state, see SRD)
  • Page layout must match the provided screenshot, including sidebar navigation, listing preview, and form controls.
  • All required fields must be validated and error states shown according to UI guidelines.
  • Permission logic must ensure only the listing owner may edit/delete/pause/cancel the listing (see BRD/SRD for rules).
  • Integrate with backend API for update, delete, pause, and cancel actions.
  • Show success/error messages for actions using Ant Design components.
  • Accessible (ARIA, keyboard navigation, semantic HTML).
  • Responsive design and proper alignment.

Additional Information

  • Use Ant Design components and Tailwind CSS for styling as described in UI Instructions.
  • Implement error and loading states using <Skeleton />, <Empty />, and Ant Design <message /> for feedback.
  • All actions must respect business logic for listing states (active, draft, cancelled, paused, deleted) as defined in the SRD/BRD.

Edit Listing Page UI Screenshot

Acceptance Criteria

  • User can edit all editable listing fields and save changes
  • User can upload/remove listing photos
  • Actions (Delete, Cancel Listing, Pause) correctly update listing state and are only enabled per business rules
  • UI matches provided screenshot and adheres to accessibility and style guidelines
  • All changes are persisted via backend API and error/success feedback is shown

For additional requirements and business rules, see:

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Summary by Sourcery

Add full Edit Listing functionality for item listings, including frontend page, GraphQL mutations, backend application services, and supporting infrastructure updates.

New Features:

  • Introduce an Edit Listing page and container that allow owners to update listing details, manage images, and perform pause, cancel, and delete actions based on listing state.
  • Expose GraphQL mutations and input types for updating, pausing, cancelling, and deleting item listings, returning updated listing data for client cache consistency.
  • Add a Twilio service package wrapper to support conversations and messaging via a typed service interface.

Bug Fixes:

  • Fix date handling for listing reservation periods by normalizing to UTC midnight and ensuring robust parsing of date-only strings.
  • Correct ListingState semantics by treating both Published and Active states as active and updating tests accordingly.
  • Improve user-field resolution in GraphQL resolvers to handle various parent shapes safely and always return a normalized user object with userType metadata.
  • Ensure the mock payment server can start reliably by probing for a free port when the default port is already in use.

Enhancements:

  • Extend the item listing update application service and tests to support updating all core fields, images, and request deletion, and to return the updated entity reference.
  • Add a dedicated pause application service with BDD tests to encapsulate pausing listings within a transaction-aware unit of work.
  • Refine create/edit listing layout and button styling for better responsiveness, spacing, and mobile behavior, and adjust home layout content width handling with a responsive sidebar margin.
  • Add Storybook stories and documentation for the Edit Listing UI to support manual QA and design review.
  • Tighten resolver helpers and value-object tests to better reflect allowed state values and requested field path handling.

Build:

  • Allow disabling Storybook in Vitest runs for the UI app to speed up coverage runs and avoid Storybook-specific configuration during test execution.
  • Introduce pnpm-level dependency overrides (e.g., node-forge) and workspace overrides to keep transitive dependencies up to date and secure.

Documentation:

  • Add detailed test case and completion summary documentation for the Edit Listing feature, covering scenarios, user journeys, and how to run the tests.

Tests:

  • Add comprehensive Vitest/BDD coverage for listing update, pause logic, listing value objects, GraphQL resolver helpers, and the Edit Listing UI and containers, including table navigation to the edit page.
  • Update SonarQube coverage exclusions to account for the new Edit Listing UI directory and generated or support files.

Copilot AI and others added 4 commits November 10, 2025 17:02
…leteItemListing

Co-authored-by: dani-vaibhav <182140623+dani-vaibhav@users.noreply.github.com>
Co-authored-by: dani-vaibhav <182140623+dani-vaibhav@users.noreply.github.com>
Co-authored-by: dani-vaibhav <182140623+dani-vaibhav@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Edit Listing page for Sharers Implement Edit Listing page with update, pause, delete, and cancel operations Nov 10, 2025
Copilot AI requested a review from dani-vaibhav November 10, 2025 17:19
@dani-vaibhav dani-vaibhav marked this pull request as ready for review November 10, 2025 17:30
@dani-vaibhav dani-vaibhav moved this from Backlog to In Progress in ShareThrift Nov 11, 2025
…le Container

- Implemented unit tests for the Edit Listing feature covering form fields, date picker, submission, navigation, button visibility, validation rules, API integration, user interactions, image handling, and form reset scenarios.
- Created tests for All Listings Table Container focusing on edit button navigation, listing data display, action handlers, query variables, table columns, error handling, pagination, filtering, search, and sorting.
- Created executable scripts for `tsc` and `tsserver` in the Twilio service package.
- Set up environment variable `NODE_PATH` to include necessary TypeScript module paths.
- Ensured compatibility with Windows environments by handling path conversion.
- Cleaned up test imports by removing unused 'vi' from vitest.
- Standardized formatting and spacing in test cases for better readability.
- Enhanced error handling in mock payment server to retry on port conflicts.
- Updated test cases to ensure proper validation and error messages for various scenarios.
- Improved date handling and validation in form submission tests.
@dani-vaibhav dani-vaibhav requested review from arif-u-ahmed and removed request for nnoce14 November 19, 2025 19:18
@jason-t-hankins
Copy link
Contributor

@sourcery-ai review

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Dec 19, 2025

Sorry @jason-t-hankins, your pull request is larger than the review limit of 150000 diff characters

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements a comprehensive Edit Listing feature for Sharers to modify their listings with full CRUD operations. The implementation spans backend GraphQL mutations, application services, domain logic, and a complete frontend UI with proper authentication and ownership verification.

Key Changes:

  • Added GraphQL mutations for update, pause, delete, and cancel operations on listings
  • Extended backend services to support partial field updates and new pause functionality
  • Implemented ownership verification to ensure only listing owners can perform actions
  • Created responsive Edit Listing UI with conditional action buttons based on listing state
  • Fixed resolver helpers to properly populate user data with userType information

Reviewed changes

Copilot reviewed 53 out of 56 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/sthrift/graphql/src/schema/types/listing/item-listing.graphql Added UpdateItemListingInput and new mutations (update, pause)
packages/sthrift/graphql/src/schema/types/listing/item-listing.resolvers.ts Implemented mutations with authentication and ownership checks
packages/sthrift/application-services/src/contexts/listing/item/update.ts Extended to accept all listing fields and return entity reference
packages/sthrift/application-services/src/contexts/listing/item/pause.ts New service for pausing listings with UoW transaction
packages/sthrift/graphql/src/schema/resolver-helper.ts Fixed PopulateUserFromField to always return full user object with userType
apps/ui-sharethrift/src/components/layouts/home/components/edit-listing/ Complete Edit Listing UI with container, form, and stories
apps/ui-sharethrift/src/components/layouts/home/my-listings/Index.tsx Added route for Edit Listing page
pnpm-lock.yaml, package.json Updated Storybook to 9.1.17, added node-forge override
.gitignore Fixed to properly exclude **/node_modules and **/dist
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

@jason-t-hankins jason-t-hankins marked this pull request as ready for review December 19, 2025 21:00
@jason-t-hankins jason-t-hankins requested a review from a team December 19, 2025 21:00
Copy link
Contributor

@jasonmorais jasonmorais left a comment

Choose a reason for hiding this comment

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

not fully done but wanted to leave you some feedback to work on tomorrow so you have something to do

<Routes>
<Route path="" element={<MyListingsMain />} />
<Route path="user/:userId" element={<MyListingsMain />} />
<Route path=":listingId/edit" element={<EditListing />} />
Copy link
Contributor

Choose a reason for hiding this comment

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

We have this weird route that both link to the same component

Copy link
Contributor

Choose a reason for hiding this comment

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

I think Vaibhav added this before I joined on the edit listing effort. I think the intention may be for admins to be able to view user's listings and be able to eventually edit them in the same way. We could either leave it for now or just remove the two excess paths from each

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 50 out of 53 changed files in this pull request and generated no new comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

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 - Edit Listing

5 participants