/*
 * File: aiAnalysisSlice.ts
 * Description: Redux slice for AI analysis state management
 * Design & Developed by Tech4Biz Solutions
 * Copyright (c) Spurrin Innovations. All rights reserved.
 */

import { createSlice, PayloadAction } from '@reduxjs/toolkit';

interface AIAnalysisState {
  findings: string;
  confidence: number;
  loading: boolean;
}

const initialState: AIAnalysisState = {
  findings: '',
  confidence: 0,
  loading: false,
};

/**
 * aiAnalysisSlice for managing AI findings and confidence
 */
const aiAnalysisSlice = createSlice({
  name: 'aiAnalysis',
  initialState,
  reducers: {
    setFindings(state, action: PayloadAction<string>) {
      state.findings = action.payload;
    },
    setConfidence(state, action: PayloadAction<number>) {
      state.confidence = action.payload;
    },
    setLoading(state, action: PayloadAction<boolean>) {
      state.loading = action.payload;
    },
    clearAnalysis(state) {
      state.findings = '';
      state.confidence = 0;
    },
  },
});

export const {
  setFindings,
  setConfidence,
  setLoading,
  clearAnalysis,
} = aiAnalysisSlice.actions;

export default aiAnalysisSlice.reducer;

/*
 * End of File: aiAnalysisSlice.ts
 * Design & Developed by Tech4Biz Solutions
 * Copyright (c) Spurrin Innovations. All rights reserved.
 */ 