Skip to content

Comments

[SSF-125] Move Food Request Fields#100

Open
Tarun-Nagesh wants to merge 8 commits intomainfrom
TN/SSF-125-move-food-request-fields
Open

[SSF-125] Move Food Request Fields#100
Tarun-Nagesh wants to merge 8 commits intomainfrom
TN/SSF-125-move-food-request-fields

Conversation

@Tarun-Nagesh
Copy link

ℹ️ Issue

Closes SSF-125

📝 Description

Moved delivery confirmation fields from Food Requests to Orders and implemented request status logic. This change reflects where delivery details are specific to individual orders instead of the entire request.

Backend Changes:

  1. Created TypeORM migration to move dateReceived, feedback, and photos fields from food_requests table to orders table
  2. Added status field to FoodRequest entity with enum values ACTIVE and CLOSED
  3. Moved confirm delivery endpoint from requests to orders: POST /api/orders/:orderId/confirm-delivery (previously POST /api/requests/:requestId/confirm-delivery)
  4. Implemented automatic request status updates - request closes when all its orders are delivered
  5. Fixed TypeScript compilation by defining local MulterFile interface in aws-s3.service.ts (could be changed later with tsconfig fix instead)

✔️ Verification

  1. Ran migration with yarn typeorm:migrate
  2. Tested confirm delivery endpoint via PowerShell
  3. All tests passing (added new tests for confirm delivery logic)

Copy link

@dburkhart07 dburkhart07 left a comment

Choose a reason for hiding this comment

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

Some initial comments. Good first pass though! 🥇

Copy link

@dburkhart07 dburkhart07 left a comment

Choose a reason for hiding this comment

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

few more small things. looks great so far!!

@@ -0,0 +1,5 @@
export class ConfirmDeliveryDto {
dateReceived: string;
feedback: string;

Choose a reason for hiding this comment

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

i think the feedback is still optional when we send this over. correct me if im wrong.


it('should upload photos and confirm delivery with all fields', async () => {
const orderId = 1;
const body = {

Choose a reason for hiding this comment

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

can we type this?

dateReceived: new Date().toISOString(),
feedback: 'Great delivery!',
};
const mockFiles = [

Choose a reason for hiding this comment

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

can we type this too?

});

// Check if all orders for this request are delivered
const allDelivered = updatedRequest.orders.every(

Choose a reason for hiding this comment

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

since we are using a testing database, we should know the outcome of this. we should not have a conditional, but rather simulate a test where this order is marked as delivered. maybe we have 2 tests, one where the order is delivered, but the request isnt fulfilled (status is active still), and another where it does get closed by this last order being fulfilled. the second test described here is already below, so lets just remove the conitionals and go with the first option.

)
async confirmDelivery(
@Param('orderId', ParseIntPipe) orderId: number,
@Body() body: ConfirmDeliveryDto,

Choose a reason for hiding this comment

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

Can we not parse the body in the controller, and instead parse it in the service fucntion, for consistency?

.execute();
}

async confirmDelivery(

Choose a reason for hiding this comment

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

take in the dto, validate each field, and then do this assigning

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants