fix(fetch-requests): update custom pages for schema changes and use PATCH for retry
- Rename format→bank in CREATE_FIELDS and TypeScript models - Add pipeline field to create form and FetchRequestCreate model - Export PipelineType from index barrel - Use new patch() method for retry instead of generic update()
This commit is contained in:
@@ -7,7 +7,7 @@ import { useNavigate } from "react-router-dom";
|
||||
import { useAppContext, useResource, ListCellRenderer, FormFieldRenderer, getApi, applyDisplayFormat } from "../../react-openapi";
|
||||
import type { FieldConfig } from "../../react-openapi";
|
||||
|
||||
const CREATE_FIELDS = ["account", "format", "start_date", "end_date", "source"];
|
||||
const CREATE_FIELDS = ["account", "bank", "pipeline", "start_date", "end_date", "source"];
|
||||
|
||||
function FetchRequestList() {
|
||||
const navigate = useNavigate();
|
||||
|
||||
@@ -9,7 +9,6 @@ import {
|
||||
Chip,
|
||||
CircularProgress,
|
||||
Alert,
|
||||
IconButton,
|
||||
Snackbar,
|
||||
} from "@mui/material";
|
||||
import ArrowBackIcon from "@mui/icons-material/ArrowBack";
|
||||
@@ -20,8 +19,8 @@ import WarningAmberIcon from "@mui/icons-material/WarningAmber";
|
||||
import PlayArrowIcon from "@mui/icons-material/PlayArrow";
|
||||
import RemoveCircleOutlineIcon from "@mui/icons-material/RemoveCircleOutline";
|
||||
import FiberManualRecordIcon from "@mui/icons-material/FiberManualRecord";
|
||||
import { useResource, useItemSse, DetailFieldRenderer, applyDisplayFormat } from "../../react-openapi";
|
||||
import { useQuery, useMutation } from "@tanstack/react-query";
|
||||
import { useResource, useItemSse, DetailFieldRenderer } from "../../react-openapi";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { RETRY_MAX, formatApiError } from "../features/fetch-requests";
|
||||
import type { FetchRequestStatus, SSEEvent, ProgressMessage } from "../features/fetch-requests";
|
||||
import { PipelineStepper } from "./components/PipelineStepper";
|
||||
@@ -71,9 +70,10 @@ function sseIcon(status: SSEEvent["status"]) {
|
||||
export default function FetchRequestDetail() {
|
||||
const { id } = useParams<{ id: string }>();
|
||||
const navigate = useNavigate();
|
||||
const { get, update, resource } = useResource("fetch-requests");
|
||||
const { get, patch, resource } = useResource("fetch-requests");
|
||||
const [stepStats, setStepStats] = useState<Record<string, number>>({});
|
||||
const [liveParsedCount, setLiveParsedCount] = useState<number | undefined>(undefined);
|
||||
const [retrying, setRetrying] = useState(false);
|
||||
const [failNotif, setFailNotif] = useState<string | null>(null);
|
||||
const feedRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
@@ -83,10 +83,6 @@ export default function FetchRequestDetail() {
|
||||
enabled: !!id,
|
||||
});
|
||||
|
||||
const updateMutation = useMutation({
|
||||
mutationFn: ({ id: rid, data }: { id: string; data: any }) => update(rid, data),
|
||||
});
|
||||
|
||||
const sseUrl = id ? `/fetch-requests/${id}/events` : null;
|
||||
const { connected: sseConnected, events: sseEvents } = useItemSse(sseUrl, {
|
||||
onEvent: (parsed: SSEEvent) => {
|
||||
@@ -150,12 +146,15 @@ export default function FetchRequestDetail() {
|
||||
}, [sseEvents]);
|
||||
|
||||
const handleRetry = async () => {
|
||||
if (!id) return;
|
||||
if (!id || !patch || retrying) return;
|
||||
setRetrying(true);
|
||||
try {
|
||||
await updateMutation.mutateAsync({ id, data: { status: "pending" } });
|
||||
await patch(id, { status: "pending" });
|
||||
refetchRequest();
|
||||
} catch (err: any) {
|
||||
setFailNotif(formatApiError(err));
|
||||
} finally {
|
||||
setRetrying(false);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -232,7 +231,7 @@ export default function FetchRequestDetail() {
|
||||
size="small"
|
||||
startIcon={<ReplayIcon />}
|
||||
onClick={handleRetry}
|
||||
disabled={updateMutation.isPending}
|
||||
disabled={retrying}
|
||||
>
|
||||
Retry
|
||||
</Button>
|
||||
|
||||
@@ -9,7 +9,7 @@ export type FetchRequestStatus =
|
||||
|
||||
export interface FileSource {
|
||||
path: string;
|
||||
format: string;
|
||||
bank: string;
|
||||
raw_lines?: string[];
|
||||
txn_blocks?: Record<string, any>;
|
||||
txn_dicts?: Record<string, any>[];
|
||||
@@ -18,7 +18,7 @@ export interface FileSource {
|
||||
}
|
||||
|
||||
export interface EmailSource {
|
||||
format: string;
|
||||
bank: string;
|
||||
from_email?: string;
|
||||
subject?: string;
|
||||
raw_terms?: string[];
|
||||
@@ -26,9 +26,12 @@ export interface EmailSource {
|
||||
txn_dicts_count?: number;
|
||||
}
|
||||
|
||||
export type PipelineType = "heuristic" | "llm" | "llama_parser";
|
||||
|
||||
export interface FetchRequestCreate {
|
||||
source: FileSource | EmailSource;
|
||||
account_name: string;
|
||||
pipeline?: PipelineType;
|
||||
payor_username?: string;
|
||||
start_date?: string;
|
||||
end_date?: string;
|
||||
|
||||
@@ -14,6 +14,7 @@ export type {
|
||||
SSEEventStep,
|
||||
SSEEventStatus,
|
||||
ProgressMessage,
|
||||
PipelineType,
|
||||
} from "./fetch-requests.models";
|
||||
export { RETRY_MAX, formatApiError } from "./fetch-requests.models";
|
||||
export {
|
||||
|
||||
Reference in New Issue
Block a user