WhatsApp/Signal/Formstack/admin updates

This commit is contained in:
Darren Clarke 2025-11-21 14:55:28 +01:00
parent bcecf61a46
commit d0cc5a21de
451 changed files with 16139 additions and 39623 deletions

View file

@ -1,14 +1,20 @@
"use server";
import { executeREST } from "app/_lib/zammad";
import { createLogger } from "@link-stack/logger";
export const getAgentsAction = async () => {
const logger = createLogger('link-users');
export const getAgentsAction = async (groupID: number) => {
try {
const users = await executeREST({
path: "/api/v1/users",
const group = await executeREST({
path: `/api/v1/groups/${groupID}`,
});
const { user_ids: groupUserIDs } = group;
const path = `/api/v1/users/search?query=role_ids:2&limit=1000`;
const users = await executeREST({ path });
const agents =
users?.filter((user: any) => user.role_ids.includes(2)) ?? [];
users?.filter((user: any) => groupUserIDs.includes(user.id)) ?? [];
const formattedAgents = agents
.map((agent: any) => ({
label: `${agent.firstname} ${agent.lastname}`,
@ -18,7 +24,7 @@ export const getAgentsAction = async () => {
return formattedAgents;
} catch (e) {
console.error(e.message);
logger.error({ error: e }, "Error occurred");
return [];
}
};
@ -39,7 +45,7 @@ export const getCustomersAction = async () => {
return formattedCustomers;
} catch (e) {
console.error(e.message);
logger.error({ error: e }, "Error occurred");
return [];
}
};
@ -49,7 +55,6 @@ export const getUsersAction = async () => {
const users = await executeREST({
path: "/api/v1/users",
});
console.log({ users });
const formattedUsers = users
.map((customer: any) => ({
label: customer.login,
@ -59,7 +64,7 @@ export const getUsersAction = async () => {
return formattedUsers;
} catch (e) {
console.error(e.message);
logger.error({ error: e }, "Error occurred");
return [];
}
};