Skip to content

Conversation

@dani-vaibhav
Copy link

@dani-vaibhav dani-vaibhav commented Nov 5, 2025

Summary by Sourcery

Standardize import formatting and code style in the ListingInformation component

Enhancements:

  • Unify string quotes to double quotes across imports and code blocks
  • Reformat multi-line import statements and align indentation consistently
  • Adjust spacing and alignment for functions, JSX, and comments for improved readability

@dani-vaibhav dani-vaibhav linked an issue Nov 5, 2025 that may be closed by this pull request
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Nov 5, 2025

Reviewer's Guide

This PR refactors the ListingInformation component by standardizing import formatting and string quoting, reformatting function and JSX indentation, and improving overall code readability without changing any business logic.

Class diagram for ListingInformationProps interface (refactored formatting)

classDiagram
  class ListingInformationProps {
    +ItemListing listing
    +boolean userIsSharer
    +boolean isAuthenticated
    +ViewListingActiveReservationRequestForListingQuery["myActiveReservationForListing"] userReservationRequest
    +function onReserveClick?
    +function onLoginClick?
    +function onSignUpClick?
    +function onCancelClick?
    +string className?
    +object reservationDates? (startDate: Date|null, endDate: Date|null)
    +function onReservationDatesChange?
    +boolean reservationLoading?
    +boolean otherReservationsLoading?
    +Error otherReservationsError?
    +ViewListingQueryActiveByListingIdQuery["queryActiveByListingId"] otherReservations?
  }

  class ItemListing
  class ViewListingActiveReservationRequestForListingQuery
  class ViewListingQueryActiveByListingIdQuery

  ListingInformationProps --> ItemListing
  ListingInformationProps --> ViewListingActiveReservationRequestForListingQuery
  ListingInformationProps --> ViewListingQueryActiveByListingIdQuery
Loading

File-Level Changes

Change Details Files
Standardized string literal quoting
  • Replaced single quotes with double quotes for all import paths and JSX attributes
  • Unified quotes in error messages, console.log calls, and union type definitions
apps/ui-sharethrift/src/components/layouts/home/components/view-listing/listing-information/listing-information.tsx
Reformatted import statements
  • Aligned specifiers in multi-line import blocks
  • Ensured consistent grouping and ordering of imports
apps/ui-sharethrift/src/components/layouts/home/components/view-listing/listing-information/listing-information.tsx
Adjusted code indentation and spacing
  • Re-indented function parameters and body for isBetweenManual and handleDateRangeChange
  • Normalized destructuring of component props and JSX element nesting
  • Formatted long JSX props and inline styles for consistent alignment
apps/ui-sharethrift/src/components/layouts/home/components/view-listing/listing-information/listing-information.tsx

Assessment against linked issues

Issue Objective Addressed Explanation
#196 Implement the acceptance workflow for Reservation Requests, allowing sharers to view and accept incoming requests, updating status from 'Requested' to 'Accepted', and triggering messaging, events, and notifications. The PR only refactors import formatting and code readability in the listing-information component. It does not implement any logic for sharers to accept reservation requests, update statuses, trigger messaging, emit events, or send notifications.
#196 Prevent double booking by ensuring only one accepted request per item for overlapping timeframes. No logic is added or changed in the PR to prevent double booking or enforce business rules regarding overlapping reservations. The changes are limited to code formatting.
#196 Update system documentation to clarify the acceptance workflow and notification logic. The PR does not include any documentation updates. It only modifies code formatting and does not address documentation related to the acceptance workflow or notification logic.

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

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • Looks like there are leftover console.log calls for debugging; please remove them before merging.
  • The lengthy IIFE blocks for rendering the reservation period and button could be extracted into smaller subcomponents to make the JSX more readable and maintainable.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Looks like there are leftover console.log calls for debugging; please remove them before merging.
- The lengthy IIFE blocks for rendering the reservation period and button could be extracted into smaller subcomponents to make the JSX more readable and maintainable.

## Individual Comments

### Comment 1
<location> `apps/ui-sharethrift/src/components/layouts/home/components/view-listing/listing-information/listing-information.tsx:93-95` </location>
<code_context>
-		'user reservation request',
-		userReservationRequest?.reservationPeriodEnd,
-	);
+  console.log("is authenticated", isAuthenticated);
+  console.log(
+    "user reservation request",
+    userReservationRequest?.reservationPeriodEnd
+  );
</code_context>

<issue_to_address>
**suggestion:** Remove or replace console.log statements with a more robust logging solution.

Console.log statements in production may expose sensitive information and clutter logs. Please remove them or switch to a secure logging method.

Suggested implementation:

```typescript
  import logger from 'utils/logger';

  logger.info("is authenticated", isAuthenticated);
  logger.info(
    "user reservation request",
    userReservationRequest?.reservationPeriodEnd
  );

```

- Ensure you have a `logger` utility available at `utils/logger`. If not, you may need to create one or use a logging library such as `loglevel`, `winston`, or similar.
- If you do not want any logging in production, you can conditionally log based on environment variables or remove these lines entirely.
- Remove the import and usage if you decide not to log at all.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +93 to +95
console.log("is authenticated", isAuthenticated);
console.log(
"user reservation request",
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Remove or replace console.log statements with a more robust logging solution.

Console.log statements in production may expose sensitive information and clutter logs. Please remove them or switch to a secure logging method.

Suggested implementation:

  import logger from 'utils/logger';

  logger.info("is authenticated", isAuthenticated);
  logger.info(
    "user reservation request",
    userReservationRequest?.reservationPeriodEnd
  );
  • Ensure you have a logger utility available at utils/logger. If not, you may need to create one or use a logging library such as loglevel, winston, or similar.
  • If you do not want any logging in production, you can conditionally log based on environment variables or remove these lines entirely.
  • Remove the import and usage if you decide not to log at all.

@github-project-automation github-project-automation bot moved this to Backlog in ShareThrift Nov 5, 2025
@dani-vaibhav dani-vaibhav moved this from Backlog to In Progress in ShareThrift Nov 5, 2025
@dani-vaibhav
Copy link
Author

@copilot

Perfect 👌 — here’s a ready-to-paste PR body template that combines both:

  1. a developer-friendly technical brief (the long version)

  2. a Copilot-friendly command block (the short version)

You can paste this entire block into your Pull Request description for #257.
Then post a separate Copilot comment afterward (shown at the bottom).


🧭 Pull Request #257 – Implement “Accept Request / Reject Request” Functionality

🔗 References


🧩 Goal

Sharers must be able to accept or reject incoming reservation requests.
Default state → Pending.

UI status → actions mapping

Status Actions
Pending Accept • Reject
Accepted Close • Message
Rejected Delete • Archive
Expired Archive

When a reservation is accepted, all other overlapping pending requests for the same listing must automatically become Rejected.


🏗️ Implementation Plan

1. Domain Layer packages/sthrift/domain/src/domain/contexts/reservation-request/

  • Extend reservation-request.ts

    • Verify accept()REQUESTED → ACCEPTED

    • Add reject()REQUESTED → REJECTED

    • Emit ReservationAccepted / ReservationRejected events

    • Preserve idempotency and permission checks via ReservationRequestPassport

2. Application Services packages/sthrift/application-services/.../reservation-request/

Create:

accept.ts
reject.ts
reject-overlapping.ts

Each should:

  • Load reservation from repo

  • Verify sharer authorization

  • Prevent overlapping accepted reservations

  • Persist via UoW transaction

  • Emit domain events

  • Trigger overlap rejection logic (reject-overlapping.ts)

3. GraphQL Layer packages/sthrift/graphql/src/schema/types/reservation-request/

Add mutations:

extend type Mutation {
  acceptReservationRequest(reservationRequestId: ID!): AcceptReservationRequestResult!
  rejectReservationRequest(reservationRequestId: ID!): RejectReservationRequestResult!
}

Resolvers must:

  • Authenticate via context.applicationServices.verifiedUser.verifiedJwt.email

  • Call application services

  • Return { success, reservationRequest, errorMessage }

4. UI Layer apps/ui-sharethrift/src/pages/my-listings.tsx

  • Display status → actions table as shown above

  • Wire buttons to GraphQL mutations

  • Add loading states + optimistic updates

  • Auto-mark expired reservations (end < today)

5. Testing

  • Extend reservation-request.aggregate.test.ts for accept/reject and overlap scenarios

  • Add unit tests for accept.ts and reject.ts

  • Verify GraphQL mutation responses

6. Quality and Instrumentation

  • Enforce Biome lint + strict TS

  • Add OpenTelemetry spans

  • Use kebab-case file names, camelCase variables

  • Document new services in domain README


✅ Acceptance Criteria

  • Domain transitions work as intended

  • Overlapping requests auto-rejected

  • GraphQL mutations exposed and tested

  • UI actions match status

  • All unit and integration tests pass


🧠 Development Notes

  • Run pnpm run build --ws --if-present then pnpm test

  • Local dev uses Azurite storage emulator

  • Use VS Code tasks func: host start and npm watch (functions)


🤖 Copilot Assignment Block

Paste this comment separately on the PR thread (not inside the PR body):

@copilot #196
#fetch https://github.com/orgs/simnova/projects/5/views/1?filterQuery=week%3A%22Week+2%22&pane=issue&itemId=133173606&issue=simnova%7Csharethrift%7C196
#fetch https://github.com/simnova/sharethrift/pull/257

@copilot /plan

Implement the “Accept Request” and “Reject Request” functionality (Issue #196) using DDD and CellixJS patterns:

  • Domain updates for accept()/reject()
  • New application services accept.ts, reject.ts, reject-overlapping.ts
  • GraphQL mutations for accept/reject
  • UI (My Listings → Requests) dynamic actions based on status
  • Auto-reject overlapping requests
  • Add unit and integration tests
  • Follow Biome + strict TS + OpenTelemetry instrumentation

🏁 Result

✅ Human reviewers see the full technical plan
✅ Copilot understands the scope and fetches context automatically
✅ Both code and documentation stay in sync


Would you like me to make a “mini Copilot summary block” (under 500 characters) for labeling the PR or adding to the project board (so Copilot and humans instantly know what this PR does)?

Perfect 👌 — here’s a **ready-to-paste PR body template** that combines both:
  1. a developer-friendly technical brief (the long version)
  2. a Copilot-friendly command block (the short version)

You can paste this entire block into your Pull Request description for #257.
Then post a separate Copilot comment afterward (shown at the bottom).


🧭 Pull Request #257 – Implement “Accept Request / Reject Request” Functionality

🔗 References


🧩 Goal

Sharers must be able to accept or reject incoming reservation requests.
Default state → Pending.

UI status → actions mapping

Status Actions
Pending Accept • Reject
Accepted Close • Message
Rejected Delete • Archive
Expired Archive

When a reservation is accepted, all other overlapping pending requests for the same listing must automatically become Rejected.


🏗️ Implementation Plan

1. Domain Layer packages/sthrift/domain/src/domain/contexts/reservation-request/

  • Extend reservation-request.ts

    • Verify accept()REQUESTED → ACCEPTED
    • Add reject()REQUESTED → REJECTED
    • Emit ReservationAccepted / ReservationRejected events
    • Preserve idempotency and permission checks via ReservationRequestPassport

2. Application Services packages/sthrift/application-services/.../reservation-request/

Create:

accept.ts
reject.ts
reject-overlapping.ts

Each should:

  • Load reservation from repo
  • Verify sharer authorization
  • Prevent overlapping accepted reservations
  • Persist via UoW transaction
  • Emit domain events
  • Trigger overlap rejection logic (reject-overlapping.ts)

3. GraphQL Layer packages/sthrift/graphql/src/schema/types/reservation-request/

Add mutations:

extend type Mutation {
  acceptReservationRequest(reservationRequestId: ID!): AcceptReservationRequestResult!
  rejectReservationRequest(reservationRequestId: ID!): RejectReservationRequestResult!
}

Resolvers must:

  • Authenticate via context.applicationServices.verifiedUser.verifiedJwt.email
  • Call application services
  • Return { success, reservationRequest, errorMessage }

4. UI Layer apps/ui-sharethrift/src/pages/my-listings.tsx

  • Display status → actions table as shown above
  • Wire buttons to GraphQL mutations
  • Add loading states + optimistic updates
  • Auto-mark expired reservations (end < today)

5. Testing

  • Extend reservation-request.aggregate.test.ts for accept/reject and overlap scenarios
  • Add unit tests for accept.ts and reject.ts
  • Verify GraphQL mutation responses

6. Quality and Instrumentation

  • Enforce Biome lint + strict TS
  • Add OpenTelemetry spans
  • Use kebab-case file names, camelCase variables
  • Document new services in domain README

✅ Acceptance Criteria

  • Domain transitions work as intended
  • Overlapping requests auto-rejected
  • GraphQL mutations exposed and tested
  • UI actions match status
  • All unit and integration tests pass

🧠 Development Notes

  • Run pnpm run build --ws --if-present then pnpm test
  • Local dev uses Azurite storage emulator
  • Use VS Code tasks func: host start and npm watch (functions)

🤖 Copilot Assignment Block

Paste this comment separately on the PR thread (not inside the PR body):

@copilot #196
#fetch https://github.com/orgs/simnova/projects/5/views/1?filterQuery=week%3A%22Week+2%22&pane=issue&itemId=133173606&issue=simnova%7Csharethrift%7C196
#fetch https://github.com/simnova/sharethrift/pull/257

@copilot /plan

Implement the “Accept Request” and “Reject Request” functionality (Issue #196) using DDD and CellixJS patterns:

- Domain updates for accept()/reject()
- New application services `accept.ts`, `reject.ts`, `reject-overlapping.ts`
- GraphQL mutations for accept/reject
- UI (My Listings → Requests) dynamic actions based on status
- Auto-reject overlapping requests
- Add unit and integration tests
- Follow Biome + strict TS + OpenTelemetry instrumentation

Copy link
Contributor

Copilot AI commented Nov 5, 2025

@dani-vaibhav I've opened a new pull request, #258, to work on those changes. Once the pull request is ready, I'll request review from you.

@github-project-automation github-project-automation bot moved this from In Progress to Done in ShareThrift Nov 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Reservation Request - Accept Request

2 participants