change 'default' to 'isDefault' whatsapp field on frontend

This commit is contained in:
canove
2020-09-20 11:12:32 -03:00
parent aa6f116514
commit 0f0d9470c5
5 changed files with 39 additions and 55 deletions

View File

@@ -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);

View File

@@ -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;