modules/frontend/Write-Frontend.ps1

param(
    [string]$ProjectName,
    [string]$OrmMode,
    [string]$OutputPath,
    [string[]]$Entities,
    [string]$Language = "tr",
    [string]$Platform = "Web"
)

$ModulesDir = Split-Path -Parent $MyInvocation.MyCommand.Path

# 1. Mobile Frontend generation if selected
if ($Platform -match "Mobile|Both") {
    $mobileParams = @{
        ProjectName  = $ProjectName
        OutputPath   = $OutputPath
        Platform     = $Platform
        Entities     = $Entities
        Language     = $Language
    }
    & "$ModulesDir\Write-Frontend-RN-Config.ps1" @mobileParams
    & "$ModulesDir\Write-Frontend-RN-Navigation.ps1" @mobileParams
    & "$ModulesDir\Write-Frontend-RN-Feature.ps1" @mobileParams
    & "$ModulesDir\Write-Frontend-RN-Auth.ps1" @mobileParams
}

# 2. Web Frontend generation if selected (React Vite + TypeScript only)
if ($Platform -match "Web|Both") {
    $reactParams = @{
        ProjectName  = $ProjectName
        OrmMode      = $OrmMode
        OutputPath   = $OutputPath
        FrontendMode = "ReactTS"
        Entities     = $Entities
        Language     = $Language
        Platform     = $Platform
    }
    & "$ModulesDir\Write-Frontend-React-Config.ps1" @reactParams
    & "$ModulesDir\Write-Frontend-React-Components.ps1" @reactParams
    & "$ModulesDir\Write-Frontend-EntityPages.ps1" @reactParams
}