trash models added, first attempt for remainign issues

This commit is contained in:
IGNY8 VPS (Salman)
2026-01-12 13:39:42 +00:00
parent 28cb698579
commit 7d4d309677
20 changed files with 1084 additions and 106 deletions

View File

@@ -4,7 +4,7 @@
* Clean UI without cluttered "Currently Processing" and "Up Next" sections
*/
import React, { useEffect, useState } from 'react';
import { automationService, ProcessingState, AutomationRun, PipelineStage } from '../../services/automationService';
import { automationService, ProcessingState, AutomationRun, PipelineStage, CurrentProcessingResponse } from '../../services/automationService';
import { useToast } from '../ui/toast/ToastContainer';
import Button from '../ui/button/Button';
import IconButton from '../ui/button/IconButton';
@@ -98,6 +98,7 @@ const CurrentProcessingCard: React.FC<CurrentProcessingCardProps> = ({
pipelineOverview,
}) => {
const [processingState, setProcessingState] = useState<ProcessingState | null>(null);
const [totalCreditsUsed, setTotalCreditsUsed] = useState<number>(currentRun.total_credits_used);
const [isPausing, setIsPausing] = useState(false);
const [isResuming, setIsResuming] = useState(false);
const [isCancelling, setIsCancelling] = useState(false);
@@ -110,12 +111,21 @@ const CurrentProcessingCard: React.FC<CurrentProcessingCardProps> = ({
const fetchState = async () => {
try {
const state = await automationService.getCurrentProcessing(siteId, runId);
const response = await automationService.getCurrentProcessing(siteId, runId);
if (!isMounted) return;
setProcessingState(state);
if (response) {
// Update processing state from nested state object
setProcessingState(response.state);
// Update credits from the response
if (response.total_credits_used !== undefined) {
setTotalCreditsUsed(response.total_credits_used);
}
}
// If stage completed, trigger update
if (state && state.processed_items >= state.total_items && state.total_items > 0) {
if (response?.state && response.state.processed_items >= response.state.total_items && response.state.total_items > 0) {
onUpdate();
}
} catch (err) {
@@ -323,7 +333,7 @@ const CurrentProcessingCard: React.FC<CurrentProcessingCardProps> = ({
<BoltIcon className="w-4 h-4 text-warning-500" />
<span className="text-xs font-medium text-gray-500 uppercase">Credits</span>
</div>
<span className="text-base font-bold text-warning-600">{currentRun.total_credits_used}</span>
<span className="text-base font-bold text-warning-600">{totalCreditsUsed}</span>
</div>
<div className="bg-white dark:bg-gray-800 rounded-xl px-3 py-2.5 border border-gray-200 dark:border-gray-700 flex items-center justify-between">