|
@@ -5,18 +5,23 @@ import { previewReportThunk } from './previewReportThunk';
|
|
|
interface DiagnosticReportState {
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
|
report: any;
|
|
|
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
|
+ previewResponse: any;
|
|
|
isPreviewing: boolean;
|
|
|
isSaving: boolean;
|
|
|
isFinished: boolean;
|
|
|
visible: boolean;
|
|
|
+ needsPreview: boolean;
|
|
|
}
|
|
|
|
|
|
const initialState: DiagnosticReportState = {
|
|
|
report: null,
|
|
|
+ previewResponse: null,
|
|
|
isPreviewing: false,
|
|
|
isSaving: false,
|
|
|
isFinished: false,
|
|
|
visible: false,
|
|
|
+ needsPreview: false,
|
|
|
};
|
|
|
|
|
|
const diagnosticReportSlice = createSlice({
|
|
@@ -32,6 +37,9 @@ const diagnosticReportSlice = createSlice({
|
|
|
toggleVisible(state) {
|
|
|
state.visible = !state.visible;
|
|
|
},
|
|
|
+ setNeedsPreview(state, action: PayloadAction<boolean>) {
|
|
|
+ state.needsPreview = action.payload;
|
|
|
+ },
|
|
|
},
|
|
|
extraReducers: (builder) => {
|
|
|
builder
|
|
@@ -48,8 +56,10 @@ const diagnosticReportSlice = createSlice({
|
|
|
.addCase(previewReportThunk.pending, (state) => {
|
|
|
state.isPreviewing = true;
|
|
|
})
|
|
|
- .addCase(previewReportThunk.fulfilled, (state) => {
|
|
|
+ .addCase(previewReportThunk.fulfilled, (state, action) => {
|
|
|
state.isPreviewing = false;
|
|
|
+ state.needsPreview = true;
|
|
|
+ state.previewResponse = action.payload; // Store the response in the new field
|
|
|
})
|
|
|
.addCase(previewReportThunk.rejected, (state) => {
|
|
|
state.isPreviewing = false;
|
|
@@ -57,6 +67,6 @@ const diagnosticReportSlice = createSlice({
|
|
|
},
|
|
|
});
|
|
|
|
|
|
-export const { finishReport, setVisible, toggleVisible } =
|
|
|
+export const { finishReport, setVisible, toggleVisible, setNeedsPreview } =
|
|
|
diagnosticReportSlice.actions;
|
|
|
export default diagnosticReportSlice.reducer;
|