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

interface AnimationsSlice {
    isRewardAnimationVisible: boolean;
    rewardAmount: number;
}

const initialState: AnimationsSlice = {
    isRewardAnimationVisible: false,
    rewardAmount: 0
}

export const animationsSlice = createSlice({
    name: 'animations',
    initialState,
    reducers: {
        showReward: (state, action: PayloadAction<{ reward: number }>) => {
            state.rewardAmount = action.payload.reward;
            state.isRewardAnimationVisible = true;
        },
        hideReward: (state) => {
            state.isRewardAnimationVisible = false;
            state.rewardAmount = 0;
        }
    }
})

export const {showReward, hideReward} = animationsSlice.actions;
export default animationsSlice.reducer;