/* eslint-disable @typescript-eslint/no-unused-vars */ import { combineStyles } from '@adminjs/design-system' import merge from 'lodash/merge.js' import ViewHelpers from '../backend/utils/view-helpers/view-helpers.js' import { initializeStore } from './store/index.js' import AdminJS from '../adminjs.js' import { CurrentAdmin } from '../current-admin.interface.js' import { getFaviconFromBranding } from '../backend/utils/options-parser/options-parser.js' /** * Renders (SSR) html for given location * * @param {AdminJS} admin * @param {Object} [currentAdmin] * @param {String} currentAdmin.email * @param {String} location='/' * * @private */ const html = async (admin: AdminJS, currentAdmin?: CurrentAdmin, location = '/'): Promise => { const h = new ViewHelpers({ options: admin.options }) const store = await initializeStore(admin, currentAdmin) const reduxState = store.getState() const { branding, assets, locale, theme: selectedTheme } = reduxState const scripts = ((assets?.scripts) || []).map((s) => ``) const styles = ((assets?.styles) || []).map((l) => ``) const theme = combineStyles(branding.theme, selectedTheme?.overrides) const faviconTag = getFaviconFromBranding(branding) return ` ${branding.companyName} ${faviconTag} ${selectedTheme ? `` : ''} ${styles.join('\n')} ${selectedTheme ? `` : ''}
${scripts.join('\n')} ` } export default html