| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- 'use server';
- import { DatabaseCintasImportProcessor } from '@/app/lib/excel-import/database-cintas-import-processor';
- export async function processCintasImport(importId: number) {
- try {
- console.log(`Starting Cintas import processing for import ID: ${importId}`);
-
- const processor = new DatabaseCintasImportProcessor();
-
- // Process the import using database Cintas import processor
- const result = await processor.processCintasImport(importId);
-
- console.log('Cintas import processing completed:', result);
- return result;
-
- } catch (error) {
- console.error('Error processing Cintas import:', error);
- return {
- success: false,
- error: error instanceof Error ? error.message : 'Failed to process Cintas import'
- };
- }
- }
- export async function validateCintasImport(importId: number) {
- try {
- const processor = new DatabaseCintasImportProcessor();
-
- // For validation, we can use the same processor to check if the import can be processed
- const importRecord = await processor['prisma'].import.findUnique({
- where: { id: importId }
- });
-
- if (!importRecord) {
- return {
- valid: false,
- errors: ['Import record not found']
- };
- }
-
- return {
- valid: true,
- errors: []
- };
-
- } catch (error) {
- console.error('Error validating Cintas import:', error);
- return {
- valid: false,
- errors: [error instanceof Error ? error.message : 'Failed to validate Cintas import']
- };
- }
- }
|