import React from 'react';
import { QueryWindowReducer } from "./query/QueryWindow";
import { ArtistWindowReducer } from "./artist/ArtistWindow";
import SearchIcon from '@material-ui/icons/Search';
import PersonIcon from '@material-ui/icons/Person';
import AlbumIcon from '@material-ui/icons/Album';
import LocalOfferIcon from '@material-ui/icons/LocalOffer';
import AudiotrackIcon from '@material-ui/icons/Audiotrack';
import LoyaltyIcon from '@material-ui/icons/Loyalty';
import { SongWindowReducer } from './song/SongWindow';
import { AlbumWindowReducer } from './album/AlbumWindow';
import { TagWindowReducer } from './tag/TagWindow';
import { songGetters } from '../../lib/songGetters';
import { ManageTagsWindowReducer } from './manage_tags/ManageTagsWindow';

export enum WindowType {
    Query = "Query",
    Artist = "Artist",
    Album = "Album",
    Tag = "Tag",
    Song = "Song",
    ManageTags = "ManageTags",
}

export interface WindowState {
    tabLabel: string,
}

export const newWindowReducer = {
    [WindowType.Query]: QueryWindowReducer,
    [WindowType.Artist]: ArtistWindowReducer,
    [WindowType.Album]: AlbumWindowReducer,
    [WindowType.Song]: SongWindowReducer,
    [WindowType.Tag]: TagWindowReducer,
    [WindowType.ManageTags]: ManageTagsWindowReducer,
}

export const newWindowState = {
    [WindowType.Query]: () => {
        return {
            tabLabel: <><SearchIcon/>Query</>,
            editingQuery: false,
            query: null,
            resultsForQuery: null,
        };
    },
    [WindowType.Artist]: () => {
        return {
            tabLabel: <><PersonIcon/>Artist 1</>,
            artistId: 1,
            metadata: null,
            pendingChanges: null,
            songGetters: songGetters,
            songsByArtist: null,
        }
    },
    [WindowType.Album]: () => {
        return {
            tabLabel: <><AlbumIcon/>Album 1</>,
            albumId: 1,
            metadata: null,
            pendingChanges: null,
            songGetters: songGetters,
            songsOnAlbum: null,
        }
    },
    [WindowType.Song]: () => {
        return {
            tabLabel: <><AudiotrackIcon/>Song 1</>,
            songId: 1,
            metadata: null,
            pendingChanges: null,
        }
    },
    [WindowType.Tag]: () => {
        return {
            tabLabel: <><LocalOfferIcon/>Tag 1</>,
            tagId: 1,
            metadata: null,
            pendingChanges: null,
            songGetters: songGetters,
            songsWithTag: null,
        }
    },
    [WindowType.ManageTags]: () => {
        return {
            tabLabel: <><LoyaltyIcon/>Manage Tags</>,
            fetchedTags: null,
            pendingChanges: [],
        }
    }
}