// QmsPlugin.mm
#import "QmsPlugin.h"
#import "DashboardViewController.h"
#import "DrawerViewController.h"
#import "DrawerController.h"
#import "NetworkManager.h"
#import "UnitViewController.h"
#import "ProjectViewController.h"

@implementation QmsPluginUI

+ (UIViewController *)makeViewController {
    [NetworkManager sharedManager];

    // 1️⃣ Drawer menu
    DrawerViewController *drawer = [[DrawerViewController alloc] init];
    drawer.profileName = @"placeholder";
    drawer.profileEmail = @"placeholder";

    // 2️⃣ Main content UINavigationController (landing page)
    ProjectViewController *project = [[ProjectViewController alloc] init]; // Landing page
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:project];

    // 3️⃣ Create DrawerController with props only
    NSString *clientID = @"clientID_loading";
    NSString *clientCode = @"clientCode_loading";
    NSString *userToken = @"userToken_loading";

    DrawerController *drawerController = [[DrawerController alloc]
        initWithDrawerViewController:drawer
                            clientID:clientID
                          clientCode:clientCode
                           userToken:userToken];

    // 4️⃣ Assign the UINavigationController as mainVC
    [drawerController setValue:nav forKey:@"_mainVC"];

    // 5️⃣ Assign drawerController references to screens
    project.drawerController = drawerController;

    // ✅ Now mainVC topViewController is project, which can receive props via DrawerController
    return drawerController;
}

@end
