mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-19 12:19:16 +00:00
change 'default' to 'isDefault' whatsapp field on frontend
This commit is contained in:
@@ -12,18 +12,18 @@ import UpdateWhatsAppService from "../services/WhatsappService/UpdateWhatsAppSer
|
||||
// import wbotMessageListener from "../services/wbotMessageListener";
|
||||
// import wbotMonitor from "../services/wbotMonitor";
|
||||
|
||||
export const index = async (req: Request, res: Response): Promise<Response> => {
|
||||
const whatsapps = await ListWhatsAppsService();
|
||||
|
||||
return res.status(200).json(whatsapps);
|
||||
};
|
||||
|
||||
interface WhatsappData {
|
||||
name: string;
|
||||
status?: string;
|
||||
isDefault?: boolean;
|
||||
}
|
||||
|
||||
export const index = async (req: Request, res: Response): Promise<Response> => {
|
||||
const whatsapps = await ListWhatsAppsService();
|
||||
|
||||
return res.status(200).json(whatsapps);
|
||||
};
|
||||
|
||||
export const store = async (req: Request, res: Response): Promise<Response> => {
|
||||
// const io = getIO();
|
||||
|
||||
@@ -53,7 +53,9 @@ export const store = async (req: Request, res: Response): Promise<Response> => {
|
||||
export const show = async (req: Request, res: Response): Promise<Response> => {
|
||||
const { whatsappId } = req.params;
|
||||
|
||||
const whatsapp = await FindWhatsAppService({ where: { id: +whatsappId } });
|
||||
console.log(whatsappId);
|
||||
|
||||
const whatsapp = await FindWhatsAppService(whatsappId);
|
||||
|
||||
return res.status(200).json(whatsapp);
|
||||
};
|
||||
|
||||
@@ -1,24 +1,10 @@
|
||||
import Whatsapp from "../../models/Whatsapp";
|
||||
import AppError from "../../errors/AppError";
|
||||
|
||||
interface WhereParams {
|
||||
id?: number;
|
||||
name?: string;
|
||||
isDefault?: boolean;
|
||||
}
|
||||
|
||||
interface Request {
|
||||
where?: WhereParams;
|
||||
}
|
||||
|
||||
const FindWhatsAppService = async ({
|
||||
where
|
||||
}: Request): Promise<Whatsapp | undefined> => {
|
||||
const whereCondition = { ...where };
|
||||
|
||||
const whatsapp = await Whatsapp.findOne({
|
||||
where: whereCondition
|
||||
});
|
||||
const FindWhatsAppService = async (
|
||||
id: string | number
|
||||
): Promise<Whatsapp | undefined> => {
|
||||
const whatsapp = await Whatsapp.findByPk(id);
|
||||
|
||||
if (!whatsapp) {
|
||||
throw new AppError("No whatsapp found with this conditions.", 404);
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
import Whatsapp from "../../models/Whatsapp";
|
||||
|
||||
interface Response {
|
||||
whatsapps: Whatsapp[];
|
||||
}
|
||||
|
||||
const ListWhatsAppsService = async (): Promise<Response> => {
|
||||
const ListWhatsAppsService = async (): Promise<Whatsapp[]> => {
|
||||
const whatsapps = await Whatsapp.findAll();
|
||||
|
||||
return { whatsapps };
|
||||
return whatsapps;
|
||||
};
|
||||
|
||||
export default ListWhatsAppsService;
|
||||
|
||||
Reference in New Issue
Block a user