package com.mvrent.carrental.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ModelAttribute;

/**
 * Exposes the configurable currency symbol/code (from application.properties) to
 * every server-rendered view as {@code currencySymbol} / {@code currencyCode}.
 */
@ControllerAdvice
public class CurrencyAdvice {

    private final String symbol;
    private final String code;

    public CurrencyAdvice(@Value("${app.currency.symbol}") String symbol,
                          @Value("${app.currency.code}") String code) {
        this.symbol = symbol;
        this.code = code;
    }

    @ModelAttribute("currencySymbol")
    public String currencySymbol() {
        return symbol;
    }

    @ModelAttribute("currencyCode")
    public String currencyCode() {
        return code;
    }
}
