- Updated the form builder to allow users to create new forms with additional fields for category and group, improving organization and usability. - Introduced an empty state in the form builder to guide users in creating new forms. - Enhanced the management page with new filters for category and group, allowing for better form organization and retrieval. - Updated the database schema to include new fields for form category, tags, and group, along with corresponding API adjustments for form creation and updates. - Improved the user interface with better handling of form descriptions and added visual indicators for categories and groups in the forms table.
50 lines
1.1 KiB
JavaScript
50 lines
1.1 KiB
JavaScript
import { PrismaClient } from '@prisma/client';
|
|
|
|
// Initialize Prisma client
|
|
const prisma = new PrismaClient();
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
try {
|
|
// Get all active forms
|
|
const forms = await prisma.form.findMany({
|
|
where: {
|
|
formStatus: 'active'
|
|
},
|
|
orderBy: {
|
|
formCreatedDate: 'desc'
|
|
},
|
|
select: {
|
|
formID: true,
|
|
formUUID: true,
|
|
formName: true,
|
|
formDescription: true,
|
|
formStatus: true,
|
|
formCreatedDate: true,
|
|
formModifiedDate: true,
|
|
formCategory: true,
|
|
formGroup: true,
|
|
formTags: true,
|
|
// Don't include the full components data to keep response size small
|
|
creator: {
|
|
select: {
|
|
userID: true,
|
|
userFullName: true
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
return {
|
|
success: true,
|
|
forms
|
|
};
|
|
} catch (error) {
|
|
console.error('Error fetching forms:', error);
|
|
|
|
return {
|
|
success: false,
|
|
error: 'Failed to fetch forms',
|
|
details: process.env.NODE_ENV === 'development' ? error.message : undefined
|
|
};
|
|
}
|
|
});
|