require full bid data on update

This commit is contained in:
Yisroel Baum 2025-12-03 21:31:45 +02:00
parent 9e2e6d9449
commit 14e77d2885
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
4 changed files with 16 additions and 12 deletions

View file

@ -1,7 +1,6 @@
# TODO # TODO
- Make UpdateBid use case
- Make GetBidsOfFreightOrder use case - Make GetBidsOfFreightOrder use case
- Dashboard: - Dashboard:
- Show open requests use case - Show open requests use case

View file

@ -13,10 +13,10 @@ class UpdateBid
public function execute(UpdateBidRequest $dto): void public function execute(UpdateBidRequest $dto): void
{ {
$bid = $this->bidRepo->find($dto->bidId); $bid = $this->bidRepo->find($dto->bidId);
$bid->setCost($dto->data['cost']); $bid->setCost($dto->cost);
$bid->setIsClosed($dto->data['isClosed']); $bid->setIsClosed($dto->isClosed);
$bid->setNotes($dto->data['notes']); $bid->setNotes($dto->notes);
$bid->setFileAttachments($dto->data['fileAttachments']); $bid->setFileAttachments($dto->fileAttachments);
$this->bidRepo->save($bid); $this->bidRepo->save($bid);
} }
} }

View file

@ -4,8 +4,14 @@ namespace FreightQuote\Bid\UseCases;
class UpdateBidRequest class UpdateBidRequest
{ {
/**
* @param string[] $fileAttachments
*/
public function __construct( public function __construct(
public int $bidId, public int $bidId,
public array $data, public int $cost,
public bool $isClosed,
public string $notes,
public array $fileAttachments,
) {} ) {}
} }

View file

@ -19,12 +19,11 @@ class UpdateBidTest extends TestCase
$useCase = new UpdateBid($bidRepo); $useCase = new UpdateBid($bidRepo);
$dto = new UpdateBidRequest( $dto = new UpdateBidRequest(
bidId: 0, bidId: 0,
data: [ isClosed: true,
'isClosed' => true, cost: 1,
'cost' => 1, notes: 'some notes',
'notes' => 'some notes', fileAttachments: ['/path/to/file'],
'fileAttachments' => ['/path/to/file']
],
); );
$useCase->execute($dto); $useCase->execute($dto);
$bid = $bidRepo->find(0); $bid = $bidRepo->find(0);