export interface BaseState { favorites: FavoritesState; } export interface Favorite { artist: string; category: FavoriteCategory; dateAdded: string; duration?: number; id: string; image: string; instrument: FavoriteInstrument; numActivities?: number; slug: string; title: string; type: FavoriteType; } export enum FavoriteCategory { COURSE = 'course', LESSON = 'lesson', PRACTICE_SHEET = 'practice-sheet', } export enum FavoriteInstrument { BASS = 'bass', GUITAR = 'guitar', UKULELE = 'ukulele', } export enum FavoriteType { SONG = 'song', RIFF = 'riff', SKILL = 'skill', } export type FavoritesAlert = { didSet: boolean; isVisible: boolean; }; export type FavoritesError = null | string; export enum FavoritesFiltersSortByOptions { ALPHABETICAL = 'alphabetical', RECENT = 'recent', REVERSE_ALPHABETICAL = 'reverse-alphabetical', } export type FavoritesKeys = { [key: string]: boolean }; export interface FavoritesFilters { category: string | FavoriteCategory | null; instrument: string | FavoriteInstrument | null; sortBy: string | FavoritesFiltersSortByOptions; type: string | FavoriteType | null; } export enum FavoritesSourcePaths { COURSE_DETAIL = 'Course Detail', FAVORITES_PAGE = 'Favorites Page', LESSON_DETAIL = 'Lesson Detail', MY_PATH = 'My Path', PRACTICE_SHEET_DETAIL = 'Practice Sheet Detail', } export interface FavoritesState { alert: FavoritesAlert; data: Favorite[] | []; error: FavoritesError; filters: FavoritesFilters; keys: FavoritesKeys; loading: boolean; } export enum FavoritesActionTypes { GET_FAVORITES_ERROR = 'GET_FAVORITES_ERROR', GET_FAVORITES_LOADING = 'GET_FAVORITES_LOADING', GET_FAVORITES_SUCCESS = 'GET_FAVORITES_SUCCESS', SET_FAVORITE_ERROR = 'SET_FAVORITE_ERROR', SET_FAVORITE_SUCCESS = 'SET_FAVORITE_SUCCESS', SET_FAVORITE_FROM_FAVORITE = 'SET_FAVORITE_FROM_FAVORITE', SET_FAVORITES_ALERT = 'SET_FAVORITES_ALERT', SET_FAVORITES_FILTERS = 'SET_FAVORITES_FILTERS', UNSET_FAVORITE_ERROR = 'UNSET_FAVORITE_ERROR', UNSET_FAVORITE_SUCCESS = 'UNSET_FAVORITE_SUCCESS', } export interface GetFavoritesErrorAction { type: FavoritesActionTypes.GET_FAVORITES_ERROR; error: FavoritesError; } export interface GetFavoritesLoadingAction { type: FavoritesActionTypes.GET_FAVORITES_LOADING; loading: boolean; } export interface GetFavoritesSuccessAction { type: FavoritesActionTypes.GET_FAVORITES_SUCCESS; data: Favorite[]; keys: FavoritesKeys; } export interface SetFavoriteErrorAction { type: FavoritesActionTypes.SET_FAVORITE_ERROR; error: FavoritesError; } export interface SetFavoriteSuccessAction { type: FavoritesActionTypes.SET_FAVORITE_SUCCESS; data: Favorite[]; keys: FavoritesKeys; } export interface SetFavoritesFromFavoritesAction { type: FavoritesActionTypes.SET_FAVORITE_FROM_FAVORITE; keys: FavoritesKeys; } export interface SetFavoritesAlertAction { type: FavoritesActionTypes.SET_FAVORITES_ALERT; alert: FavoritesAlert; } export interface SetFavoritesFiltersAction { type: FavoritesActionTypes.SET_FAVORITES_FILTERS; filters: FavoritesFilters; } export interface UnsetFavoriteErrorAction { type: FavoritesActionTypes.UNSET_FAVORITE_ERROR; error: FavoritesError; } export interface UnsetFavoriteSuccessAction { type: FavoritesActionTypes.UNSET_FAVORITE_SUCCESS; data: Favorite[]; keys: FavoritesKeys; } export type FavoritesAction = | GetFavoritesErrorAction | GetFavoritesLoadingAction | GetFavoritesSuccessAction | SetFavoriteErrorAction | SetFavoriteSuccessAction | SetFavoritesFromFavoritesAction | SetFavoritesAlertAction | SetFavoritesFiltersAction | UnsetFavoriteErrorAction | UnsetFavoriteSuccessAction;