Update various configuration files, components, and assets; enhance notification system and API endpoints; improve documentation and styles across the application.
This commit is contained in:
38
server/api/notifications/segments.get.js
Normal file
38
server/api/notifications/segments.get.js
Normal file
@@ -0,0 +1,38 @@
|
||||
import prisma from "~/server/utils/prisma";
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
try {
|
||||
// Fetch active user segments
|
||||
const segments = await prisma.user_segments.findMany({
|
||||
where: {
|
||||
is_active: true,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
value: true,
|
||||
description: true,
|
||||
},
|
||||
orderBy: {
|
||||
name: "asc",
|
||||
},
|
||||
});
|
||||
|
||||
return segments.map((segment) => ({
|
||||
id: segment.id,
|
||||
name: segment.name,
|
||||
value: segment.value,
|
||||
description: segment.description,
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error("Error fetching segments:", error);
|
||||
throw createError({
|
||||
statusCode: 500,
|
||||
statusMessage: "Failed to fetch user segments",
|
||||
data: {
|
||||
error: error.message,
|
||||
},
|
||||
});
|
||||
} finally {
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user