// © 2025 Naked People Team. All Rights Reserved.


#include "ForumAppWidget.h"

#include "Components/Button.h"
#include "Components/WidgetSwitcher.h"

namespace
{
	// Switcher page order — must match the child order authored in the BP.
	constexpr int32 CommissionsTabIndex = 0;
	constexpr int32 ProfileTabIndex = 1;
}

void UForumAppWidget::NativeOnInitialized()
{
	Super::NativeOnInitialized();

	if (CommissionsTabButton)
		CommissionsTabButton->OnClicked.AddUniqueDynamic(this, &UForumAppWidget::ShowCommissions);

	if (ProfileTabButton)
		ProfileTabButton->OnClicked.AddUniqueDynamic(this, &UForumAppWidget::ShowProfile);

	// Open on the commission board — it is the forum's primary loop surface (§13).
	ShowCommissions();
}

void UForumAppWidget::ShowCommissions()
{
	if (TabSwitcher)
		TabSwitcher->SetActiveWidgetIndex(CommissionsTabIndex);
}

void UForumAppWidget::ShowProfile()
{
	if (TabSwitcher)
		TabSwitcher->SetActiveWidgetIndex(ProfileTabIndex);
}