feat: add staff role functionality with dashboard access and service management

- Implemented SidebarStaff component tests to ensure staff users see only their dashboard and services.
- Created StaffMyServicesPage to display assigned services for staff users.
- Added migration to link clinic staff rows to user accounts for ROLE_STAFF access.
- Defined StaffPermissions class for static permissions related to staff role.
- Introduced StaffRouteGuardSubscriber to restrict API access for staff users.
- Developed StaffAccountService for managing staff user accounts and linking them to clinic staff.
- Added comprehensive tests for StaffAccountService to validate user creation, mobile number handling, and account attachment.
- Implemented tests for staff dashboard access to ensure proper permissions and access control.
- Created tests for staff login context to verify correct environment visibility based on user roles.
This commit is contained in:
hamed
2026-07-30 10:18:41 +03:30
parent 6ec011e3ad
commit 57aeb40934
28 changed files with 1960 additions and 29 deletions
@@ -4,6 +4,7 @@ namespace App\ClinicService\Repository;
use App\ClinicService\Entity\ServiceItem;
use App\ClinicService\Entity\ServiceSection;
use App\Staff\Entity\ClinicStaff;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
@@ -41,6 +42,28 @@ class ServiceItemRepository extends ServiceEntityRepository
->getResult();
}
/**
* سرویس‌های فعالِ تخصیص‌یافته به یک پرسنل، محدود به محیط خودش.
*
* ردیف‌های قبل از مهاجرتِ چندپرسنلی فقط ستون تکیِ `staff` را دارند، پس هر دو
* سمت رابطه بررسی می‌شود.
*
* @return ServiceItem[]
*/
public function findByStaff(ClinicStaff $staff): array
{
return $this->createQueryBuilder('i')
->join('i.section', 's')
->leftJoin('i.staffMembers', 'm')
->where('s.entityType = :type')->setParameter('type', $staff->getEntityType())
->andWhere('s.entityId = :id')->setParameter('id', $staff->getEntityId())
->andWhere('i.active = true')
->andWhere('m = :staff OR i.staff = :staff')->setParameter('staff', $staff)
->orderBy('i.name', 'ASC')
->getQuery()
->getResult();
}
/**
* Count services per section in a single query (avoids N+1 in the section list).
*