import { html } from 'lit-html'

export default {
    title: 'GES DISC/User Dashboard/List Item',
    component: 'gd-user-dashboard-list-item',
}

function getListItem() {
    return new Promise(resolve => {
        let listItem = document.querySelector('gd-user-dashboard-list-item')

        if (!listItem) {
            setTimeout(async () => resolve(await getListItem()), 500)
            return
        }

        resolve(listItem)
    })
}

export const Example = (args, { loaded: { historyItem } }) => {
    getListItem().then(listItem => {
        // use history items initially

        listItem.item = historyItem
    })

    return html` <gd-user-dashboard-list-item></gd-user-dashboard-list-item> `
}

Example.argTypes = {}

Example.args = {}

Example.loaders = [
    async () => ({
        historyItem: {
            url: 'https://uui-test.gesdisc.eosdis.nasa.gov/datasets?keywords=GLDAS_CLM10_M_001&page=1',
            label: 'GES DISC Search: Showing 1 - 25 of 408 datasets associated with GLDAS_CLM10_M_001',
            serviceType: 'data',
            tags: ['foo', 'bar'],
            favorite: false,
            application: 'GES DISC Website',
            uid: 'jdcarlso',
            created: '2020-10-16T20:44:26.924Z',
            id: '5f8a062a90bb2f00127b68e0',
        },
    }),
]
