import React from 'react';
import { StoryFn, Meta } from '@storybook/react';
import { PluginRender, PluginRenderType } from './Plugin';

export default {
    title: 'Plugin renderer',
    component: PluginRender,
} as Meta<typeof PluginRender>;

const noop = () => {};

const Template: StoryFn<PluginRenderType> = (args) => <PluginRender {...args} />;

export const WithoutAuth = Template.bind({});
WithoutAuth.args = {
    render: true,
    inline: false,
    type: null,
    modalTitle: 'Test Plugin (No Auth)',
    onRetry: noop,
    useResource: () => ({ data: null, error: null, isLoading: false }),
    source: {
        id: 'source-no-auth',
        type: 'dummy',
        configuration: {},
    },
};

export const WithAuth = Template.bind({});
WithAuth.args = {
    render: true,
    inline: false,
    type: null,
    modalTitle: 'Test Plugin (With Auth)',
    onRetry: noop,
    useResource: () => ({ data: null, error: null, isLoading: false }),
    source: {
        id: 'source-with-auth',
        type: 'dummy',
        configuration: {
            authUrl: 'https://example.com/auth',
            redirectUrl: 'https://example.com/redirect',
            clientId: 'client123',
            scope: 'scope1 scope2',
        },
    },
};

export const InlineWithoutAuth = Template.bind({});
InlineWithoutAuth.args = {
    render: true,
    inline: true,
    inlineType: 'image',
    type: null,
    modalTitle: 'Test Inline Plugin (No Auth)',
    onRetry: noop,
    useResource: () => ({ data: null, error: null, isLoading: false }),
    source: {
        id: 'inline-source-no-auth',
        type: 'dummy',
        configuration: {},
    },
};

export const InlineWithAuth = Template.bind({});
InlineWithAuth.args = {
    render: true,
    inline: true,
    inlineType: 'image',
    type: null,
    modalTitle: 'Test Inline Plugin (With Auth)',
    onRetry: noop,
    useResource: () => ({ data: null, error: null, isLoading: false }),
    source: {
        id: 'inline-source-with-auth',
        type: 'dummy',
        configuration: {
            authUrl: 'https://example.com/auth',
            redirectUrl: 'https://example.com/redirect',
            clientId: 'client123',
            scope: 'scope1 scope2',
        },
    },
};

export const NotRendered = Template.bind({});
NotRendered.args = {
    render: false,
    inline: false,
    type: null,
    modalTitle: 'Should Not Render',
    onRetry: noop,
    source: null,
};
