mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-19 12:19:16 +00:00
chore: split ticket in multiple componentts
This commit is contained in:
@@ -4,6 +4,7 @@ import { getIO } from "../libs/socket";
|
||||
import CreateTicketService from "../services/TicketServices/CreateTicketService";
|
||||
import DeleteTicketService from "../services/TicketServices/DeleteTicketService";
|
||||
import ListTicketsService from "../services/TicketServices/ListTicketsService";
|
||||
import ShowTicketService from "../services/TicketServices/ShowTicketService";
|
||||
import UpdateTicketService from "../services/TicketServices/UpdateTicketService";
|
||||
|
||||
type IndexQuery = {
|
||||
@@ -60,6 +61,14 @@ export const store = async (req: Request, res: Response): Promise<Response> => {
|
||||
return res.status(200).json(ticket);
|
||||
};
|
||||
|
||||
export const show = async (req: Request, res: Response): Promise<Response> => {
|
||||
const { ticketId } = req.params;
|
||||
|
||||
const contact = await ShowTicketService(ticketId);
|
||||
|
||||
return res.status(200).json(contact);
|
||||
};
|
||||
|
||||
export const update = async (
|
||||
req: Request,
|
||||
res: Response
|
||||
|
||||
@@ -7,6 +7,8 @@ const ticketRoutes = express.Router();
|
||||
|
||||
ticketRoutes.get("/tickets", isAuth, TicketController.index);
|
||||
|
||||
ticketRoutes.get("/tickets/:ticketId", isAuth, TicketController.show);
|
||||
|
||||
ticketRoutes.post("/tickets", isAuth, TicketController.store);
|
||||
|
||||
ticketRoutes.put("/tickets/:ticketId", isAuth, TicketController.update);
|
||||
|
||||
@@ -56,8 +56,12 @@ const UpdateContactService = async ({
|
||||
await contact.update({
|
||||
name,
|
||||
number,
|
||||
email,
|
||||
extraInfo
|
||||
email
|
||||
});
|
||||
|
||||
await contact.reload({
|
||||
attributes: ["id", "name", "number", "email", "profilePicUrl"],
|
||||
include: ["extraInfo"]
|
||||
});
|
||||
|
||||
return contact;
|
||||
|
||||
@@ -27,19 +27,26 @@ const verifyContact = async (
|
||||
msgContact: WbotContact,
|
||||
profilePicUrl: string
|
||||
): Promise<Contact> => {
|
||||
const io = getIO();
|
||||
|
||||
let contact = await Contact.findOne({
|
||||
where: { number: msgContact.id.user }
|
||||
});
|
||||
|
||||
if (contact) {
|
||||
await contact.update({ profilePicUrl });
|
||||
|
||||
io.emit("contact", {
|
||||
action: "update",
|
||||
contact
|
||||
});
|
||||
} else {
|
||||
contact = await Contact.create({
|
||||
name: msgContact.name || msgContact.pushname || msgContact.id.user,
|
||||
number: msgContact.id.user,
|
||||
profilePicUrl
|
||||
});
|
||||
const io = getIO();
|
||||
|
||||
io.emit("contact", {
|
||||
action: "create",
|
||||
contact
|
||||
|
||||
Reference in New Issue
Block a user