csv push to local files implemented
This commit is contained in:
parent
6d6b2a3f9c
commit
4d0079c7fc
@ -10,7 +10,7 @@ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/com
|
|||||||
import { Badge } from '@/components/ui/badge';
|
import { Badge } from '@/components/ui/badge';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Progress } from '@/components/ui/progress';
|
import { Progress } from '@/components/ui/progress';
|
||||||
import { TrendingUp, Clock, CheckCircle, CircleCheckBig, Upload, Mail, Download, Receipt, Activity, AlertTriangle, AlertOctagon, XCircle, History, ChevronDown, ChevronUp, RefreshCw, RotateCw, Eye, FileSpreadsheet, X, Loader2 } from 'lucide-react';
|
import { TrendingUp, Clock, CheckCircle, CheckCircle2, CircleCheckBig, Upload, Mail, Download, Receipt, Activity, AlertTriangle, AlertOctagon, XCircle, History, ChevronDown, ChevronUp, RefreshCw, RotateCw, Eye, FileSpreadsheet, X, Loader2 } from 'lucide-react';
|
||||||
import { formatDateTime, formatDateDDMMYYYY } from '@/utils/dateFormatter';
|
import { formatDateTime, formatDateDDMMYYYY } from '@/utils/dateFormatter';
|
||||||
import { formatHoursMinutes } from '@/utils/slaTracker';
|
import { formatHoursMinutes } from '@/utils/slaTracker';
|
||||||
import {
|
import {
|
||||||
@ -26,7 +26,7 @@ import {
|
|||||||
// InitiatorActionModal - Removed, using direct buttons instead
|
// InitiatorActionModal - Removed, using direct buttons instead
|
||||||
} from './modals';
|
} from './modals';
|
||||||
import { toast } from 'sonner';
|
import { toast } from 'sonner';
|
||||||
import { submitProposal, updateIODetails, submitCompletion, updateEInvoice, sendCreditNoteToDealer } from '@/services/dealerClaimApi';
|
import { submitProposal, updateIODetails, submitCompletion, updateEInvoice, sendCreditNoteToDealer, retriggerWFMPush } from '@/services/dealerClaimApi';
|
||||||
import { getWorkflowDetails, approveLevel, rejectLevel, handleInitiatorAction, getWorkflowHistory } from '@/services/workflowApi';
|
import { getWorkflowDetails, approveLevel, rejectLevel, handleInitiatorAction, getWorkflowHistory } from '@/services/workflowApi';
|
||||||
import { uploadDocument } from '@/services/documentApi';
|
import { uploadDocument } from '@/services/documentApi';
|
||||||
import { TokenManager } from '@/utils/tokenManager';
|
import { TokenManager } from '@/utils/tokenManager';
|
||||||
@ -1766,19 +1766,88 @@ export function DealerClaimWorkflowTab({
|
|||||||
})()}
|
})()}
|
||||||
{/* CSV Export Button (Requestor Claim Approval) */}
|
{/* CSV Export Button (Requestor Claim Approval) */}
|
||||||
{(() => {
|
{(() => {
|
||||||
const isRequestorClaimStep = (step.levelName || step.title || '').toLowerCase().includes('requestor claim') ||
|
const isInvoiceStep = (step.levelName || step.title || '').toLowerCase().includes('requestor claim') ||
|
||||||
(step.levelName || step.title || '').toLowerCase().includes('requestor - claim');
|
(step.levelName || step.title || '').toLowerCase().includes('requestor - claim') ||
|
||||||
const hasInvoice = request?.invoice || (request?.irn && step.status === 'approved');
|
(step.levelName || step.title || '').toLowerCase().includes('e-invoice') ||
|
||||||
return isRequestorClaimStep && hasInvoice && (
|
(step.levelName || step.title || '').toLowerCase().includes('invoice generation');
|
||||||
|
|
||||||
|
const invoice = request?.invoice || request?.claimDetails?.invoice;
|
||||||
|
const hasInvoice = !!invoice || (request?.irn && step.status === 'approved');
|
||||||
|
if (!isInvoiceStep || !hasInvoice) return null;
|
||||||
|
|
||||||
|
const wfmStatus = invoice?.wfmPushStatus;
|
||||||
|
const wfmError = invoice?.wfmPushError;
|
||||||
|
|
||||||
|
const handleRetrigger = async (e: React.MouseEvent) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
try {
|
||||||
|
toast.loading('Retriggering WFM push...');
|
||||||
|
await retriggerWFMPush(request.id || request.requestId);
|
||||||
|
toast.dismiss();
|
||||||
|
toast.success('WFM push re-triggered successfully');
|
||||||
|
// Optionally refresh data
|
||||||
|
if (typeof (request as any).refresh === 'function') {
|
||||||
|
(request as any).refresh();
|
||||||
|
} else {
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
toast.dismiss();
|
||||||
|
toast.error('Failed to re-trigger WFM push');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex items-center gap-1 ml-1">
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
className="h-6 w-6 p-0 hover:bg-emerald-100 ml-1"
|
className="h-6 w-6 p-0 hover:bg-emerald-100"
|
||||||
title="Export CSV"
|
title="Export CSV"
|
||||||
onClick={handleDownloadCSV}
|
onClick={handleDownloadCSV}
|
||||||
>
|
>
|
||||||
<FileSpreadsheet className="w-3.5 h-3.5 text-emerald-600" />
|
<FileSpreadsheet className="w-3.5 h-3.5 text-emerald-600" />
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
|
{/* WFM Push Status Icon */}
|
||||||
|
{wfmStatus === 'SUCCESS' && (
|
||||||
|
<div className="flex items-center justify-center h-6 w-6 rounded-full bg-green-50" title="Pushed to WFM successfully">
|
||||||
|
<CheckCircle2 className="w-3.5 h-3.5 text-green-600" />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{wfmStatus === 'FAILED' && (
|
||||||
|
<div className="flex items-center gap-1">
|
||||||
|
<div className="flex items-center justify-center h-6 w-6 rounded-full bg-red-50" title={`WFM Push Failed: ${wfmError || 'Unknown error'}`}>
|
||||||
|
<XCircle className="w-3.5 h-3.5 text-red-600" />
|
||||||
|
</div>
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
className="h-6 px-2 text-[10px] text-red-600 border-red-200 hover:bg-red-50"
|
||||||
|
onClick={handleRetrigger}
|
||||||
|
>
|
||||||
|
Retry Push
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{(wfmStatus === 'PENDING' || !wfmStatus) && (
|
||||||
|
<div className="flex items-center gap-1">
|
||||||
|
<div className="flex items-center justify-center h-6 w-6 rounded-full bg-gray-50" title="WFM Push Pending">
|
||||||
|
<Clock className="w-3.5 h-3.5 text-gray-400" />
|
||||||
|
</div>
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
className="h-6 px-2 text-[10px] text-blue-600 border-blue-200 hover:bg-blue-50"
|
||||||
|
onClick={handleRetrigger}
|
||||||
|
>
|
||||||
|
Push Now
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
})()}
|
})()}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -331,7 +331,7 @@ export function useRequestDetails(
|
|||||||
internalOrders: internalOrders || [],
|
internalOrders: internalOrders || [],
|
||||||
// New normalized tables (also available via claimDetails for backward compatibility)
|
// New normalized tables (also available via claimDetails for backward compatibility)
|
||||||
budgetTracking: (claimDetails as any)?.budgetTracking || null,
|
budgetTracking: (claimDetails as any)?.budgetTracking || null,
|
||||||
invoice: (claimDetails as any)?.invoice || null,
|
invoice: claimDetails?.invoice || (claimDetails as any)?.invoice || null,
|
||||||
creditNote: (claimDetails as any)?.creditNote || null,
|
creditNote: (claimDetails as any)?.creditNote || null,
|
||||||
completionExpenses: (claimDetails as any)?.completionExpenses || null,
|
completionExpenses: (claimDetails as any)?.completionExpenses || null,
|
||||||
};
|
};
|
||||||
@ -599,7 +599,7 @@ export function useRequestDetails(
|
|||||||
internalOrders: internalOrders || [],
|
internalOrders: internalOrders || [],
|
||||||
// New normalized tables (also available via claimDetails for backward compatibility)
|
// New normalized tables (also available via claimDetails for backward compatibility)
|
||||||
budgetTracking: (claimDetails as any)?.budgetTracking || null,
|
budgetTracking: (claimDetails as any)?.budgetTracking || null,
|
||||||
invoice: (claimDetails as any)?.invoice || null,
|
invoice: claimDetails?.invoice || (claimDetails as any)?.invoice || null,
|
||||||
creditNote: (claimDetails as any)?.creditNote || null,
|
creditNote: (claimDetails as any)?.creditNote || null,
|
||||||
completionExpenses: (claimDetails as any)?.completionExpenses || null,
|
completionExpenses: (claimDetails as any)?.completionExpenses || null,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -401,3 +401,16 @@ export async function getDealerDashboard(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Re-trigger WFM CSV push
|
||||||
|
* POST /api/v1/dealer-claims/:requestId/wfm/retrigger
|
||||||
|
*/
|
||||||
|
export async function retriggerWFMPush(requestId: string): Promise<any> {
|
||||||
|
try {
|
||||||
|
const response = await apiClient.post(`/dealer-claims/${requestId}/wfm/retrigger`);
|
||||||
|
return response.data?.data || response.data;
|
||||||
|
} catch (error: any) {
|
||||||
|
console.error('[DealerClaimAPI] Error re-triggering WFM push:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user