Keep JWT login mirrored on the tenant cookie domain, improve e-payment settings UX, and add a storefront link from the customer sidebar. Co-authored-by: Cursor <cursoragent@cursor.com>
34 lines
1019 B
TypeScript
34 lines
1019 B
TypeScript
import { apiRequest } from '../lib/api'
|
|
import { getTenantDomain } from '../lib/config'
|
|
|
|
export interface WebsiteBusinessInfo {
|
|
id: string
|
|
name: string
|
|
nameFa: string
|
|
logoUrl: string | null
|
|
faviconUrl: string | null
|
|
}
|
|
|
|
export async function getWebsiteBusinessInfo(host: string, signal?: AbortSignal) {
|
|
const encodedHost = encodeURIComponent(host)
|
|
return apiRequest<WebsiteBusinessInfo>(`/tenants/${encodedHost}/website/business-info`, {
|
|
signal,
|
|
})
|
|
}
|
|
|
|
/** Public storefront URL for the tenant (e.g. https://sanihome.com). */
|
|
export function getWebsiteUrl(domain = getTenantDomain()) {
|
|
const configured = (import.meta.env.VITE_WEBSITE_ORIGIN as string | undefined)?.replace(
|
|
/\/$/,
|
|
'',
|
|
)
|
|
if (configured) return configured
|
|
|
|
const { protocol, port } = window.location
|
|
// Local customer app is :5175; Sanihome Next storefront runs on :3001
|
|
if (import.meta.env.DEV && (port === '5175' || port === '')) {
|
|
return `${protocol}//${domain}:3001`
|
|
}
|
|
return `${protocol}//${domain}`
|
|
}
|