package de.cannamanage.api.dto.staff;

import de.cannamanage.domain.entity.StaffAccount;
import de.cannamanage.domain.entity.User;
import de.cannamanage.domain.enums.StaffPermission;

import java.time.Instant;
import java.util.Set;
import java.util.UUID;

/**
 * Response DTO for staff member information.
 */
public record StaffResponse(
        UUID id,
        UUID userId,
        String email,
        String displayName,
        Set<StaffPermission> permissions,
        String templateName,
        boolean active,
        boolean preventionOfficer,
        Instant createdAt
) {
    public static StaffResponse from(StaffAccount staff, User user) {
        return new StaffResponse(
                staff.getId(),
                staff.getUserId(),
                user.getEmail(),
                staff.getDisplayName(),
                staff.getGrantedPermissions(),
                null, // templateName not stored; permissions are expanded
                staff.isActive(),
                staff.isPreventionOfficer(),
                staff.getCreatedAt()
        );
    }

    public static StaffResponse from(StaffAccount staff, String email) {
        return new StaffResponse(
                staff.getId(),
                staff.getUserId(),
                email,
                staff.getDisplayName(),
                staff.getGrantedPermissions(),
                null,
                staff.isActive(),
                staff.isPreventionOfficer(),
                staff.getCreatedAt()
        );
    }
}
