import { createActionGroup, emptyProps, props } from '@ngrx/store';
import { UserListItem } from '../../models/user.model';
import { UpdateUser } from '../../models/user.model';
import { PaginationMeta } from '../../models/api.model';

export const UsersActions = createActionGroup({
  source: 'Users',
  events: {
    'Load Users': props<{ page?: number; perPage?: number; forceReload?: boolean }>(),
    'Load Users Success': props<{ users: UserListItem[]; meta: PaginationMeta }>(),
    'Load Users Failure': props<{ error: string }>(),
    'Create User': props<{ user: any }>(),
    'Create User Success': props<{ user: UserListItem }>(),
    'Create User Failure': props<{ error: string }>(),
    'Update User': props<{ id: number; user: UpdateUser }>(),
    'Update User Success': props<{ user: UserListItem }>(),
    'Update User Failure': props<{ error: string }>(),
    'Delete User': props<{ id: number }>(),
    'Delete User Success': props<{ id: number }>(),
    'Delete User Failure': props<{ error: string }>(),
    'Clear Users Error': emptyProps(),
  },
});
