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

export type SupportedLocale = 'id' | 'cn';

interface LocaleState {
  currentLocale: SupportedLocale;
}

const initialState: LocaleState = {
  currentLocale: 'id', // Default to Indonesian
};

export const localeSlice = createSlice({
  name: "locale",
  initialState,
  reducers: {
    setLocale: (state, action: PayloadAction<SupportedLocale>) => {
      state.currentLocale = action.payload;
    },
  },
});

export const { setLocale } = localeSlice.actions;
export default localeSlice.reducer;