diff --git a/backend/src/controllers/QuickMessageController.ts b/backend/src/controllers/QuickMessageController.ts index 8664fe7e..2cb60d49 100644 --- a/backend/src/controllers/QuickMessageController.ts +++ b/backend/src/controllers/QuickMessageController.ts @@ -25,11 +25,6 @@ type StoreData = { userId: number | number; }; -type FindParams = { - companyId: string; - userId: string; -}; - export const index = async (req: Request, res: Response): Promise => { const { searchParam, pageNumber, userId } = req.query as IndexQuery; const { companyId } = req.user; @@ -139,8 +134,7 @@ export const findList = async ( req: Request, res: Response ): Promise => { - const params = req.query as FindParams; - const records: QuickMessage[] = await FindService(params); + const records: QuickMessage[] = await FindService({userId: parseInt(req.user.id,10), companyId: req.user.companyId}); return res.status(200).json(records); }; diff --git a/backend/src/services/QuickMessageService/FindService.ts b/backend/src/services/QuickMessageService/FindService.ts index 2361e983..4bf34391 100644 --- a/backend/src/services/QuickMessageService/FindService.ts +++ b/backend/src/services/QuickMessageService/FindService.ts @@ -1,16 +1,16 @@ import { Op } from "sequelize"; import QuickMessage from "../../models/QuickMessage"; import Company from "../../models/Company"; -import CheckSettings, { GetCompanySetting } from "../../helpers/CheckSettings"; +import { GetCompanySetting } from "../../helpers/CheckSettings"; type Params = { - companyId: string; - userId: string; + companyId: number; + userId: number; }; type QuickMessageWhere = { - companyId: string; - userId?: string; + companyId: number; + userId?: number; } const FindService = async ({ companyId, userId }: Params): Promise => { @@ -18,7 +18,7 @@ const FindService = async ({ companyId, userId }: Params): Promise { useEffect(() => { async function fetchData() { - const companyId = localStorage.getItem("companyId"); - const messages = await listQuickMessages({ companyId, userId: user.id }); + const messages = await listQuickMessages(); const options = messages.map((m) => { let truncatedMessage = m.message; if (isString(truncatedMessage) && truncatedMessage.length > 35) { diff --git a/frontend/src/hooks/useQuickMessages/index.js b/frontend/src/hooks/useQuickMessages/index.js index d9ddd5fc..e2234ffd 100644 --- a/frontend/src/hooks/useQuickMessages/index.js +++ b/frontend/src/hooks/useQuickMessages/index.js @@ -28,11 +28,10 @@ const useQuickMessages = () => { return data; } - const list = async (params) => { + const list = async () => { const { data } = await api.request({ url: '/quick-messages/list', method: 'GET', - params }); return data; }