/*
 * SPDX-License-Identifier: GPL-3.0-or-later
 */
package com.runicgateway.app.core.web

import com.runicgateway.app.core.net.BaseUrlHolder
import javax.inject.Inject
import javax.inject.Singleton

/**
 * Resolves the website's front-end page paths against the configured base URL,
 * for the Custom-Tab hand-offs (PLAN.md §4.2). These are the React SPA routes
 * (mirrored from `website/client` `App.jsx`), not API endpoints. Null before a
 * shard site is configured.
 */
@Singleton
class WebsiteUrls @Inject constructor(
    private val baseUrlHolder: BaseUrlHolder,
) {
    private fun resolve(path: String): String? =
        baseUrlHolder.current?.resolve(path)?.toString()

    /** Create an account on the website. */
    fun register(): String? = resolve(REGISTER)

    /** Forgot / reset password (the flow built on the backend before app work, §8). */
    fun forgotPassword(): String? = resolve(FORGOT)

    private companion object {
        const val REGISTER = "account/register"
        const val FORGOT = "account/forgot"
    }
}
