feat: update ClinicDetailPage and ClinicsPage for address handling and UI improvements
This commit is contained in:
@@ -504,6 +504,12 @@ class AdminApiController extends BaseController
|
||||
$this->em->persist($user);
|
||||
}
|
||||
|
||||
$roles = $user->getRoles();
|
||||
if (!in_array('ROLE_CLINIC', $roles, true)) {
|
||||
$roles[] = 'ROLE_CLINIC';
|
||||
$user->setRoles(array_values(array_unique($roles)));
|
||||
}
|
||||
|
||||
$clinic = new Clinic($user);
|
||||
$clinic->setName($name);
|
||||
if (!empty($data['telephone'])) $clinic->setTelephone($data['telephone']);
|
||||
|
||||
@@ -567,6 +567,10 @@ class ClinicController extends BaseController
|
||||
return $this->error(ErrorCodes::ERR_AUTH_006, 'دسترسی ممنوع', 403);
|
||||
}
|
||||
|
||||
if ($this->addressRepo->countByClinic($clinic->getId()) > 0) {
|
||||
return $this->error(ErrorCodes::ERR_CONFLICT_001, 'این کلینیک قبلاً آدرس دارد. برای ویرایش از endpoint PATCH استفاده کنید', 409);
|
||||
}
|
||||
|
||||
$data = json_decode($request->getContent(), true) ?? [];
|
||||
$address = DoctorAddress::forClinic($clinic->getId());
|
||||
$this->hydrateClinicAddress($address, $data);
|
||||
@@ -618,11 +622,6 @@ class ClinicController extends BaseController
|
||||
return $this->error(ErrorCodes::ERR_VALIDATION_002, 'آدرس یافت نشد', 404);
|
||||
}
|
||||
|
||||
$remaining = $this->addressRepo->countByClinic($clinic->getId());
|
||||
if ($remaining <= 1) {
|
||||
return $this->error(ErrorCodes::ERR_CONFLICT_001, 'کلینیک باید حداقل یک آدرس داشته باشد', 409);
|
||||
}
|
||||
|
||||
$this->addressRepo->remove($address);
|
||||
|
||||
return $this->success(['message' => 'آدرس با موفقیت حذف شد']);
|
||||
|
||||
Reference in New Issue
Block a user