corrad-bp/server/api/roles/index.get.js
Afiq cf3a2c1a58 Add Repeating Table Component and Enhance Form Builder Functionality
- Introduced a new RepeatingTable component for structured data collection, allowing users to add, edit, and delete records dynamically.
- Enhanced FormBuilderComponents to include the RepeatingTable in the available components list with default properties.
- Updated FormBuilderFieldSettingsModal to support configuration options for the RepeatingTable, including button texts, record limits, and display settings.
- Implemented data management functions for updating table data and handling dynamic list items in the FormBuilder.
- Improved ComponentPreview to render the RepeatingTable component correctly in preview mode.
- Enhanced user experience with intuitive UI elements and responsive design for the new table component.
- Updated documentation to reflect the addition of the RepeatingTable and its configuration options.
2025-05-31 10:45:56 +08:00

36 lines
749 B
JavaScript

import { PrismaClient } from '@prisma/client';
export default defineEventHandler(async (event) => {
try {
const prisma = new PrismaClient();
// Get all active roles
const roles = await prisma.role.findMany({
where: {
roleStatus: 'ACTIVE' // Using ACTIVE to match database convention
},
select: {
roleID: true,
roleName: true,
roleDescription: true
},
orderBy: {
roleName: 'asc'
}
});
await prisma.$disconnect();
return {
success: true,
roles: roles
};
} catch (error) {
console.error('Error fetching roles:', error);
return {
success: false,
error: 'Failed to fetch roles'
};
}
});