import { createSlice, PayloadAction } from "@reduxjs/toolkit"; import { RawEvent, TaggedRawEvent } from "@snort/nostr"; interface NoteCreatorStore { show: boolean; note: string; error: string; active: boolean; preview?: RawEvent; replyTo?: TaggedRawEvent; showAdvanced: boolean; selectedCustomRelays: false | Array; zapForward: string; sensitive: string; pollOptions?: Array; otherEvents: Array; } const InitState: NoteCreatorStore = { show: false, note: "", error: "", active: false, showAdvanced: false, selectedCustomRelays: false, zapForward: "", sensitive: "", otherEvents: [], }; const NoteCreatorSlice = createSlice({ name: "NoteCreator", initialState: InitState, reducers: { setShow: (state, action: PayloadAction) => { state.show = action.payload; }, setNote: (state, action: PayloadAction) => { state.note = action.payload; }, setError: (state, action: PayloadAction) => { state.error = action.payload; }, setActive: (state, action: PayloadAction) => { state.active = action.payload; }, setPreview: (state, action: PayloadAction) => { state.preview = action.payload; }, setReplyTo: (state, action: PayloadAction) => { state.replyTo = action.payload; }, setShowAdvanced: (state, action: PayloadAction) => { state.showAdvanced = action.payload; }, setSelectedCustomRelays: (state, action: PayloadAction>) => { state.selectedCustomRelays = action.payload; }, setZapForward: (state, action: PayloadAction) => { state.zapForward = action.payload; }, setSensitive: (state, action: PayloadAction) => { state.sensitive = action.payload; }, setPollOptions: (state, action: PayloadAction | undefined>) => { state.pollOptions = action.payload; }, setOtherEvents: (state, action: PayloadAction>) => { state.otherEvents = action.payload; }, reset: () => InitState, }, }); export const { setShow, setNote, setError, setActive, setPreview, setReplyTo, setShowAdvanced, setSelectedCustomRelays, setZapForward, setSensitive, setPollOptions, setOtherEvents, reset, } = NoteCreatorSlice.actions; export const reducer = NoteCreatorSlice.reducer;