# Task 07 - Bids For project 1. Implement biding submit feature each project should have bids submitted by freelancers, client should accept one of them each freelancer needs to provide the following when submit a bid: * Proposed Price: A numerical value representing the freelancer's bid. * Notes: A string value for any additional comments or details from the freelancer. The proposed price and notes should be included in the request body as JSON. For example: ```jsonld { "proposedPrice": 500.0, "notes": "I can complete this project in 10 days with high quality." } ``` Endpoint path: `/api/mobile/v1/projects/{id}/bids` Design: - You need to create a new table called `bids` - bid object: id(pk), projectId(fk), feelancerId(fk), proposed_price, notes, status(possible values: pending, approved), submittedAt, ApprovedAt - each new bid submitted, its default status is `pending` - when the client approves a bid, status should be updated to `approved`, ApprovedAt should be DateTime of approval by client. Endpoint `/api/mobile/v1/projects/{id}/bids`, Http verb is `POST` Body: json ```jsonld { "proposedPrice": 500.0, "notes": "I can complete this project in 10 days with high quality." } ``` **Request Validation:** * Bids submit should be done only by user role "Freelancer", return 403 if user type role is not "Freelancer" * Validate that the proposed price is within acceptable bounds (e.g., not negative). * Validate that the proposed price is always less than last bids submitted, example below: let's suppose project bugdet is 1000 $ - First bid submit propsed price should be less than 1000, let's suppose it is 900 $ - next bid submit, should check proposed price of last bid which is 900 $, then new proposed price of this bid submit should be less than 900 $, and so on for next bids submission. 2. Implement approval on bid by the client after several submissions done by freelancers, the client should be able to approve on one of them, for this needs, we should implement endpoint to allow the user to do that: 2.1 We should change response of project to include list of bids for a client. `api/mobile/v1/projects/{id}` to get projects details + list of bids(order asending by proposed price) now the project have status `available` and list of bids, each bid should be shown like in the screenshot below User can approve one of them by calling endpoint: Design: - Endpoint path: `api/mobile/v1/projects/{pid}/bids/{bid}/approve`, - Http verb is PUT or PATCH - Validation: - Authorize only clients to use this endpoint - pid is project id and should be found in db and its status should be `available` - bid is bid id that is belong to the pid, it should be found and not approved yet. - Logic: - Once the bids approved, project status should be updated to `closed` - once the bids approved, the bid status should be updated to `approved` + approvedAt should be take the datetime of the approval 3. Projects Tasks/Milestones once the project approved, the client should be able to define some milstones/tasks for the project, let's do this by imeplemnt: - Create Tasks table in db with below columns: - Id(pk), projectId(fk), Name, Status(to-do, in-progress, in-review, done), deadlineAt(datetime), completedAt, notes - client can create task for a project using below endpoint: endpoint path: `api/mobile/v1/projects/{id}/tasks` Http verb: POST Body: ```jsonld Name:"Wireframing", DeadlineAt: Datetime ``` Notes: - default status for the task is `to-do` - to update the status of task: - endpoint path: `api/mobile/v1/tasks/{id}`, PUT or PATCH - Body: json have (newStatus), possible values(one of the above) - Endpoint could be used by client of freelancer later on. ![image](https://hackmd.io/_uploads/r1N_NXYMJl.png)