import {createAction, createActionGroup, emptyProps, props} from "@ngrx/store";
import {List} from "../../../../../../mastodon-api/src/lib/interfaces/public/list";
import {Account} from "../../../../../../mastodon-api/src/lib/interfaces/public/account";

export const MastodonApiActions = createActionGroup({
    source: 'Mastodon API',
    events: {
        'Load Lists': emptyProps(),
        'Load Followings': emptyProps(),
        'Load Accounts For List': emptyProps(),
        'Lists Loaded': props<{ lists: ReadonlyArray<List> }>(),
        'Lists Loaded Error': emptyProps(),
        'Account Ids for Lists Loaded': props<{ mappings: { [listId: string]: string[] } }>(),
        'Followings Loaded': props<{ followings: ReadonlyArray<Account> }>(),
        'Followings Loaded Error': props<{ error: string }>(),
    }
});

export const ListActions = createActionGroup({
    source: 'List',
    events: {
        'Add Account to List': props<{ accountId: string, listId: string }>(),
        'Add Account to List Success': emptyProps(),
        'Add Account to List Error': emptyProps(),
        'Remove Account from List': props<{ accountId: string, listId: string }>(),
        'Remove Account from List Success': emptyProps(),
        'Remove Account from List Error': emptyProps(),
    },
});

export const FiltersActions = createActionGroup({
    source: 'Filters',
    events: {
        'Set Username': props<{ username: string }>(),
        'Set Free Text': props<{ freeText: ReadonlyArray<string> }>(),
        'Set Lists': props<{ lists: ReadonlyArray<string> }>(),
        'Set Unlisted': props<{ unlisted: boolean }>(),
        'Clear Filters': emptyProps(),
    },
})
