diff --git a/src/Controller/DefaultController.php b/src/Controller/DefaultController.php index faba9b0..885bd68 100644 --- a/src/Controller/DefaultController.php +++ b/src/Controller/DefaultController.php @@ -65,10 +65,10 @@ public function ajaxUpdate( ServicoServiceInterface $servicoService, FilaServiceInterface $filaService, ): Response { - $envelope = new Envelope(); /** @var UsuarioInterface */ $usuario = $this->getUser(); $unidade = $usuario->getLotacao()->getUnidade(); + $envelope = new Envelope(timezone: $unidade->getDateTimeZone()); $data = []; $param = $request->get('ids', ''); @@ -113,18 +113,16 @@ public function infoSenha( throw $this->createNotFoundException(); } - $envelope = new Envelope(); - /** @var UsuarioInterface */ $usuario = $this->getUser(); $unidade = $usuario->getLotacao()->getUnidade(); $this->checkAtendimento($unidade, $atendimento, $translator); - $data = $atendimento->jsonSerialize(); - $envelope->setData($data); - - return $this->json($envelope); + return $this->json(new Envelope( + timezone: $unidade->getDateTimeZone(), + data: $atendimento->jsonSerialize(), + )); } /** @@ -133,17 +131,17 @@ public function infoSenha( #[Route("/buscar", name: "buscar", methods: ["GET"])] public function buscar(Request $request, AtendimentoServiceInterface $atendimentoService): Response { - $envelope = new Envelope(); - /** @var UsuarioInterface */ $usuario = $this->getUser(); $unidade = $usuario->getLotacao()->getUnidade(); $numero = $request->get('numero'); $atendimentos = $atendimentoService->buscaAtendimentos($unidade, $numero); - $envelope->setData($atendimentos); - return $this->json($envelope); + return $this->json(new Envelope( + timezone: $unidade->getDateTimeZone(), + data: $atendimentos, + )); } /** @@ -162,11 +160,10 @@ public function transferir( throw $this->createNotFoundException(); } - $envelope = new Envelope(); - /** @var UsuarioInterface */ $usuario = $this->getUser(); $unidade = $usuario->getLotacao()->getUnidade(); + $envelope = new Envelope(timezone: $unidade->getDateTimeZone()); $this->checkAtendimento($unidade, $atendimento, $translator); @@ -206,10 +203,10 @@ public function reativar( throw $this->createNotFoundException(); } - $envelope = new Envelope(); /** @var UsuarioInterface */ $usuario = $this->getUser(); $unidade = $usuario->getLotacao()->getUnidade(); + $envelope = new Envelope(timezone: $unidade->getDateTimeZone()); $statuses = [AtendimentoServiceInterface::SENHA_CANCELADA, AtendimentoServiceInterface::NAO_COMPARECEU]; if ($atendimento->getUnidade()->getId() !== $unidade->getId()) { @@ -251,11 +248,10 @@ public function cancelar( throw $this->createNotFoundException(); } - $envelope = new Envelope(); - /** @var UsuarioInterface */ $usuario = $this->getUser(); $unidade = $usuario->getLotacao()->getUnidade(); + $envelope = new Envelope(timezone: $unidade->getDateTimeZone()); $this->checkAtendimento($unidade, $atendimento, $translator); $atendimentoService->cancelar($atendimento, $usuario);