import { TerminalLinkComponent } from '@app/modules/components/terminal-link/terminal-link.component';
import { TextComponent } from '@toolkit/text/text.component';
import { AirportTerminalPipe } from '@shared/pipes-legacy';
import {
    componentWrapperDecorator,
    Meta,
    moduleMetadata,
    Story,
} from '@storybook/angular';
import { IAirportInfo } from '@typings/airport-info';
import { IFlightLegStation } from '../../../../typings/flight/flight-station';
import { TooltipModule } from 'primeng/tooltip';

import { StationComponent } from './station.component';

export default {
    title: 'Components/Station',
    component: StationComponent,
    decorators: [
        moduleMetadata({
            declarations: [
                TextComponent,
                TerminalLinkComponent,
                AirportTerminalPipe,
            ],
            imports: [TooltipModule],
        }),
        componentWrapperDecorator((story) => {
            return `<div style="width: 185px; background-color: #FFFFFF">${story}</div>`;
        }),
    ],
    argTypes: {
        align: {
            options: ['left', 'right', 'mobile-left', 'mobile-right', 'center'],
            control: {
                type: 'select',
            },
        },
        size: {
            options: ['large', 'medium', 'small', 'extra-small'],
            control: {
                type: 'select',
            },
        },
        withOldCity: {
            control: 'boolean',
        },
        station: {
            control: 'object',
        },
    },
} as Meta;

const Template: Story = (args) => ({
    props: args,
});

const scheduledAirportLong: IAirportInfo = {
    airport: 'Международный аэропорт Хабаровск (Новый) им. Г. И. Невельского',
    airportCode: 'KHV',
    city: 'Хабаровск',
    cityCode: 'KHV',
    countryCode: 'RU',
};

const scheduledAirport: IAirportInfo = {
    city: 'Москва',
    airport: 'Шереметьево',
    countryCode: 'RU',
    cityCode: 'MOW',
    airportCode: 'SVO',
};

const latestAirport: IAirportInfo = {
    airport: 'Елизово',
    airportCode: 'PKC',
    city: 'Петропавловск-Камчатский',
    cityCode: 'PKC',
    countryCode: 'RU',
};

const onlineBoardStation: IFlightLegStation = {
    scheduled: scheduledAirport,
    latest: latestAirport,
};

const scheduleStationLong: IFlightLegStation = {
    scheduled: scheduledAirportLong,
};

const scheduleStation: IFlightLegStation = {
    scheduled: scheduledAirport,
};

export const OnlineBoard = Template.bind({});
OnlineBoard.args = {
    station: onlineBoardStation,
};

export const Schedule = Template.bind({});
Schedule.args = {
    station: scheduleStation,
};

export const ScheduleLong = Template.bind({});
ScheduleLong.args = {
    station: scheduleStationLong,
};
