// widgets/RegisterMessageWidget.ts
import { Widget } from '../components/Widget';
import { createElement, navigateTo } from '../utils/utils';

export class RegisterWidget extends Widget {
    private message: string;

    constructor(message?: string) {
        super();
        this.message = message || "";
    }

    render(): HTMLElement {
        this.container.innerHTML = ''; 

        const header = createElement('h2');
        header.classList.add('widget-header');
        header.textContent = 'Register';

        const messageParagraph = createElement('p');
        messageParagraph.classList.add('widget-body');
        messageParagraph.textContent = this.message;

        const button = createElement('button');
        button.classList.add('btn', 'btn-secondary');
        button.textContent = 'Register';
        
        button.addEventListener('click', () => {
            navigateTo('/register');
        });

        this.container.appendChild(header);
        this.container.appendChild(messageParagraph);
        this.container.appendChild(button);
        return this.container;
    }
}
