using Eis.Application.Public;

namespace Eis.Web.Configuration;

public sealed class PublicSiteConfiguration : IPublicSiteConfiguration
{
    public PublicSiteConfiguration()
    {
        Branding = new PublicSiteBranding(
            new PublicOrganization(
                Read("PUBLIC_SITE_NAME", "考试服务平台"),
                Read("PUBLIC_SITE_CODE", "EXAM-SERVICE"),
                Read("PUBLIC_SITE_PHONE", string.Empty),
                Read("PUBLIC_SITE_ADDRESS", string.Empty),
                Read("PUBLIC_SITE_EMAIL", string.Empty)),
            new PublicSiteCopy(
                Read("PUBLIC_SITE_HERO_EYEBROW", "EXAMINATION SERVICE"),
                Read("PUBLIC_SITE_HERO_TITLE", "一个报名号，"),
                Read("PUBLIC_SITE_HERO_HIGHLIGHT", "贯穿每一次考试。"),
                Read("PUBLIC_SITE_HERO_DESCRIPTION", "使用学校下发的报名号登录，完成密码更新和个人信息核验后，即可办理所有考试事项。"),
                Read("PUBLIC_SITE_FOOTER_NOTICE", string.Empty)));
    }

    public PublicSiteBranding Branding { get; }

    private static string Read(string name, string fallback) =>
        Environment.GetEnvironmentVariable(name) ?? fallback;
}
