import { createActionGroup, emptyProps, props } from '@ngrx/store';
import { JournalEntry, CreateJournalEntry, UpdateJournalEntry } from '../../models/journal-entry.model';
import { PaginationMeta } from '../../models/api.model';

export const JournalEntriesActions = createActionGroup({
  source: 'Journal Entries',
  events: {
    'Load Journal Entries': props<{ page?: number; perPage?: number; forceReload?: boolean }>(),
    'Load Journal Entries Success': props<{ entries: JournalEntry[]; meta: PaginationMeta }>(),
    'Load Journal Entries Failure': props<{ error: string }>(),
    'Load Journal Entry': props<{ id: number }>(),
    'Load Journal Entry Success': props<{ entry: JournalEntry }>(),
    'Load Journal Entry Failure': props<{ error: string }>(),
    'Create Journal Entry': props<{ entry: CreateJournalEntry }>(),
    'Create Journal Entry Success': props<{ entry: JournalEntry }>(),
    'Create Journal Entry Failure': props<{ error: string }>(),
    'Update Journal Entry': props<{ id: number; entry: UpdateJournalEntry }>(),
    'Update Journal Entry Success': props<{ entry: JournalEntry }>(),
    'Update Journal Entry Failure': props<{ error: string }>(),
    'Delete Journal Entry': props<{ id: number }>(),
    'Delete Journal Entry Success': props<{ id: number }>(),
    'Delete Journal Entry Failure': props<{ error: string }>(),
    'Approve Journal Entry': props<{ id: number }>(),
    'Approve Journal Entry Success': props<{ entry: JournalEntry }>(),
    'Approve Journal Entry Failure': props<{ error: string }>(),
    'Post Journal Entry': props<{ id: number }>(),
    'Post Journal Entry Success': props<{ entry: JournalEntry }>(),
    'Post Journal Entry Failure': props<{ error: string }>(),
    'Reverse Journal Entry': props<{ id: number; date: string }>(),
    'Reverse Journal Entry Success': props<{ entry: JournalEntry }>(),
    'Reverse Journal Entry Failure': props<{ error: string }>(),
    'Cancel Journal Entry': props<{ id: number }>(),
    'Cancel Journal Entry Success': props<{ entry: JournalEntry }>(),
    'Cancel Journal Entry Failure': props<{ error: string }>(),
    'Clear Journal Entries Error': emptyProps(),
  },
});
