mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-18 19:59:20 +00:00
feat: added socket io to queues page
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { Request, Response } from "express";
|
||||
import { getIO } from "../libs/socket";
|
||||
import CreateQueueService from "../services/QueueService/CreateQueueService";
|
||||
import DeleteQueueService from "../services/QueueService/DeleteQueueService";
|
||||
import ListQueuesService from "../services/QueueService/ListQueuesService";
|
||||
@@ -16,6 +17,12 @@ export const store = async (req: Request, res: Response): Promise<Response> => {
|
||||
|
||||
const queue = await CreateQueueService({ name, color, greetingMessage });
|
||||
|
||||
const io = getIO();
|
||||
io.emit("queue", {
|
||||
action: "update",
|
||||
queue
|
||||
});
|
||||
|
||||
return res.status(200).json(queue);
|
||||
};
|
||||
|
||||
@@ -35,6 +42,12 @@ export const update = async (
|
||||
|
||||
const queue = await UpdateQueueService(queueId, req.body);
|
||||
|
||||
const io = getIO();
|
||||
io.emit("queue", {
|
||||
action: "update",
|
||||
queue
|
||||
});
|
||||
|
||||
return res.status(201).json(queue);
|
||||
};
|
||||
|
||||
@@ -46,5 +59,11 @@ export const remove = async (
|
||||
|
||||
await DeleteQueueService(queueId);
|
||||
|
||||
const io = getIO();
|
||||
io.emit("queue", {
|
||||
action: "delete",
|
||||
queueId: +queueId
|
||||
});
|
||||
|
||||
return res.status(200).send();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user