Initial commit

This commit is contained in:
Krisztu
2026-02-25 09:15:58 +01:00
commit 5addd560c6
16 changed files with 9794 additions and 0 deletions

39
store/eventsSlice.ts Normal file
View File

@@ -0,0 +1,39 @@
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
interface Event {
id: string;
name: string;
description: string;
date: string;
}
interface EventsState {
events: Event[];
favorites: string[];
}
const initialState: EventsState = {
events: [],
favorites: [],
};
const eventsSlice = createSlice({
name: 'events',
initialState,
reducers: {
setEvents: (state, action: PayloadAction<Event[]>) => {
state.events = action.payload;
},
toggleFavorite: (state, action: PayloadAction<string>) => {
const index = state.favorites.indexOf(action.payload);
if (index > -1) {
state.favorites.splice(index, 1);
} else {
state.favorites.push(action.payload);
}
},
},
});
export const { setEvents, toggleFavorite } = eventsSlice.actions;
export default eventsSlice.reducer;