<?php
if (session_status() === PHP_SESSION_NONE) {
    session_start();
}

$type = $_GET['type'] ?? 'personal';

if ($type === 'personal') {
    $_SESSION['workspace_type'] = 'personal';
    header("Location: dashboard.php");
    exit;
}

if ($type === 'company') {
    if (isset($_SESSION['active_company_id']) && $_SESSION['active_company_id'] !== '') {
        $_SESSION['workspace_type'] = 'company';
    } else {
        $_SESSION['workspace_type'] = 'personal';
    }

    header("Location: dashboard.php");
    exit;
}

header("Location: dashboard.php");
exit;