Skip to content

Commit

Permalink
fix(MPDZBS-877): fix reserve appointment validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Fink authored and Thomas Fink committed Dec 2, 2024
1 parent 8528769 commit daf1593
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class ValidationService

public static function validateServiceLocationCombination(int $officeId, array $serviceIds): array
{

$availableServices = ZmsApiFacadeService::getServicesProvidedAtOffice($officeId);
$availableServiceIds = array_map(function ($service) {
return $service['id'];
Expand Down
56 changes: 28 additions & 28 deletions zmscitizenapi/src/Zmscitizenapi/Services/ZmsApiFacadeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,34 +357,34 @@ public static function getServicesByOfficeIds(array $officeIds): array
*
*/

public static function getServicesProvidedAtOffice(int $officeId): array
{

$requestRelationList = ZmsApiClientService::getRequestRelationList();

$requestRelationArray = [];
foreach ($requestRelationList as $relation) {
$requestRelationArray[] = $relation;
}

$serviceIds = array_filter($requestRelationArray, function ($relation) use ($officeId) {
return $relation->provider->id === $officeId;
});

$serviceIds = array_map(function ($relation) {
return $relation->request->id;
}, $serviceIds);

$requestList = ZmsApiClientService::getServices() ?? [];
$requestArray = [];
foreach ($requestList as $request) {
$requestArray[] = $request;
}

return array_filter($requestArray, function ($request) use ($serviceIds) {
return in_array($request->id, $serviceIds);
});
}
public static function getServicesProvidedAtOffice(int $officeId): array
{
$requestRelationList = ZmsApiClientService::getRequestRelationList();

$requestRelationArray = [];
foreach ($requestRelationList as $relation) {
$requestRelationArray[] = $relation;
}

$serviceIds = array_filter($requestRelationArray, function ($relation) use ($officeId) {
return $relation->provider->id === $officeId || (string)$relation->provider->id === (string)$officeId;
});

$serviceIds = array_map(function ($relation) {
return $relation->request->id;
}, $serviceIds);

$requestList = ZmsApiClientService::getServices() ?? [];
$requestArray = [];
foreach ($requestList as $request) {
$requestArray[] = $request;
}

return array_filter($requestArray, function ($request) use ($serviceIds) {
return in_array($request->id, $serviceIds);
});
}

public static function getBookableFreeDays(array $queryParams): array
{
Expand Down

0 comments on commit daf1593

Please sign in to comment.