fix: splits monitor widget types to complete and active

This commit is contained in:
2025-06-01 14:32:15 -05:00
parent b17313c8fb
commit 08d28d9a4f
4 changed files with 45 additions and 10 deletions

View File

@@ -16,6 +16,9 @@ final class MonitorList extends AbstractController
use PaginateTrait;
#[LiveProp(writable: true)]
public string $type;
#[LiveProp(writable: true)]
public bool $isWidget = true;
@@ -24,8 +27,34 @@ final class MonitorList extends AbstractController
) {}
#[LiveAction]
public function getUserMonitors()
public function getMonitors()
{
return $this->monitorRepository->getUserMonitorsPaginated($this->getUser(), $this->pageNumber, $this->perPage);
if ($this->type === "active") {
return $this->getActiveUserMonitors();
} elseif ($this->type === "complete") {
return $this->getCompleteUserMonitors();
}
return [];
}
#[LiveAction]
public function getActiveUserMonitors()
{
return $this->asPaginator($this->monitorRepository->createQueryBuilder('m')
->andWhere('m.status IN (:statuses)')
->setParameter('statuses', ['New', 'In Progress'])
->getQuery()
);
}
#[LiveAction]
public function getCompleteUserMonitors()
{
return $this->asPaginator($this->monitorRepository->createQueryBuilder('m')
->andWhere('m.status = :status')
->setParameter('status', 'Complete')
->getQuery()
);
}
}