feat(sales): enhance opportunity management and add CW integration
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { optima } from "$lib";
|
||||
import { json } from "@sveltejs/kit";
|
||||
import type { RequestHandler } from "./$types";
|
||||
|
||||
/** GET /api/companies/[id]/details — fetch company with contacts and address */
|
||||
export const GET: RequestHandler = async ({ params, locals }) => {
|
||||
const accessToken = locals.session?.accessToken;
|
||||
if (!accessToken) {
|
||||
return json({ data: null }, { status: 401 });
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await optima.company.fetch(accessToken, params.id, {
|
||||
includeAllContacts: true,
|
||||
includeAddress: true,
|
||||
});
|
||||
return json({ data: result?.data ?? null });
|
||||
} catch (err) {
|
||||
console.error("[api/companies/details] Failed:", err);
|
||||
return json({ data: null }, { status: 500 });
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user