/**
 * topicsSlice — CLAUDE.md defined slice.
 * Topics/hashtags browsing state.
 */
import { createSlice } from "@reduxjs/toolkit";
import type { RootState } from "@/store/store";

interface Topic {
  id: number;
  name: string;
  total_used: number;
  status: number;
}

interface TopicsState {
  items: Topic[];
  isLoading: boolean;
  error: string | null;
}

const initialState: TopicsState = {
  items: [],
  isLoading: false,
  error: null,
};

export const topicsSlice = createSlice({
  name: "topics",
  initialState,
  reducers: {
    setTopics: (state, action) => {
      state.items = action.payload;
    },
  },
});

export const { setTopics } = topicsSlice.actions;
export default topicsSlice.reducer;

export const selectTopics        = (s: RootState) => s.topics.items;
export const selectTopicsLoading = (s: RootState) => s.topics.isLoading;
