import { Controller, Get, Request } from "@nestjs/common"; import { ApiTags, ApiOperation, ApiBearerAuth } from "@nestjs/swagger"; import { InternetCatalogService } from "./services/internet-catalog.service"; import { SimCatalogService } from "./services/sim-catalog.service"; import { VpnCatalogService } from "./services/vpn-catalog.service"; import { InternetPlan, InternetAddon, InternetInstallation, SimPlan, SimActivationFee, SimAddon, VpnPlan, VpnActivationFee, } from "../shared/types/catalog.types"; @ApiTags("catalog") @Controller("catalog") @ApiBearerAuth() export class CatalogController { constructor( private internetCatalog: InternetCatalogService, private simCatalog: SimCatalogService, private vpnCatalog: VpnCatalogService ) {} @Get("internet/plans") @ApiOperation({ summary: "Get Internet plans filtered by customer eligibility" }) async getInternetPlans(@Request() req: { user: { id: string } }): Promise { const userId = req.user?.id; if (!userId) { // Fallback to all plans if no user context return this.internetCatalog.getPlans(); } return this.internetCatalog.getPlansForUser(userId); } @Get("internet/addons") @ApiOperation({ summary: "Get Internet add-ons" }) async getInternetAddons(): Promise { return this.internetCatalog.getAddons(); } @Get("internet/installations") @ApiOperation({ summary: "Get Internet installations" }) async getInternetInstallations(): Promise { return this.internetCatalog.getInstallations(); } @Get("sim/plans") @ApiOperation({ summary: "Get SIM plans filtered by user's existing services" }) async getSimPlans(@Request() req: { user: { id: string } }): Promise { const userId = req.user?.id; if (!userId) { // Fallback to all regular plans if no user context const allPlans = await this.simCatalog.getPlans(); return allPlans.filter(plan => !plan.hasFamilyDiscount); } return this.simCatalog.getPlansForUser(userId); } @Get("sim/activation-fees") @ApiOperation({ summary: "Get SIM activation fees" }) async getSimActivationFees(): Promise { return this.simCatalog.getActivationFees(); } @Get("sim/addons") @ApiOperation({ summary: "Get SIM add-ons" }) async getSimAddons(): Promise { return this.simCatalog.getAddons(); } @Get("vpn/plans") @ApiOperation({ summary: "Get VPN plans" }) async getVpnPlans(): Promise { return this.vpnCatalog.getPlans(); } @Get("vpn/activation-fees") @ApiOperation({ summary: "Get VPN activation fees" }) async getVpnActivationFees(): Promise { return this.vpnCatalog.getActivationFees(); } }