feat(frontend): wire Vite app to FastAPI parser with NDJSON streaming + Upload page
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
import { create } from "zustand";
|
||||
import {
|
||||
sampleActivity,
|
||||
sampleClaims,
|
||||
sampleProviders,
|
||||
sampleRemittances,
|
||||
} from "@/data/sampleData";
|
||||
import type {
|
||||
Activity,
|
||||
Claim,
|
||||
ParsedBatch,
|
||||
Provider,
|
||||
Remittance,
|
||||
} from "@/types";
|
||||
|
||||
interface AppState {
|
||||
// Legacy in-memory store used by the existing pages.
|
||||
claims: Claim[];
|
||||
providers: Provider[];
|
||||
remittances: Remittance[];
|
||||
activity: Activity[];
|
||||
|
||||
addClaim: (claim: Claim) => void;
|
||||
addActivity: (entry: Activity) => void;
|
||||
|
||||
// Parsed-batch slice — populated by the Upload page when the user uploads
|
||||
// a real EDI file through the FastAPI backend. Independent of the legacy
|
||||
// store above so the existing pages keep working with sample data.
|
||||
parsedBatches: ParsedBatch[];
|
||||
activeBatchId: string | null;
|
||||
addParsedBatch: (batch: ParsedBatch) => void;
|
||||
setActiveBatchId: (id: string | null) => void;
|
||||
}
|
||||
|
||||
export const useAppStore = create<AppState>((set) => ({
|
||||
claims: sampleClaims,
|
||||
providers: sampleProviders,
|
||||
remittances: sampleRemittances,
|
||||
activity: sampleActivity,
|
||||
|
||||
addClaim: (claim) =>
|
||||
set((s) => ({
|
||||
claims: [claim, ...s.claims],
|
||||
activity: [
|
||||
{
|
||||
id: `ACT-${claim.id}`,
|
||||
kind: "claim_submitted",
|
||||
message: `Submitted ${claim.id} · ${claim.patientName}`,
|
||||
timestamp: claim.submissionDate,
|
||||
npi: claim.providerNpi,
|
||||
amount: claim.billedAmount,
|
||||
},
|
||||
...s.activity,
|
||||
],
|
||||
})),
|
||||
|
||||
addActivity: (entry) => set((s) => ({ activity: [entry, ...s.activity] })),
|
||||
|
||||
parsedBatches: [],
|
||||
activeBatchId: null,
|
||||
addParsedBatch: (batch) =>
|
||||
set((s) => ({
|
||||
parsedBatches: [batch, ...s.parsedBatches],
|
||||
activeBatchId: batch.id,
|
||||
})),
|
||||
setActiveBatchId: (id) => set({ activeBatchId: id }),
|
||||
}));
|
||||
Reference in New Issue
Block a user