import { __, sprintf } from "@wordpress/i18n"; import { ConfigInformationEntityCard } from "./ConfigInformationEntityCard"; import { buildDailySettingsProperties, buildDailyUnitCards, buildHourlyServiceCards, buildHourlySettingsProperties, getConfigProgress, } from "./buildConfigPreview"; import { ConfigInformation, ConfigMode } from "./types"; function getModeLabel(mode: ConfigMode | null): string { if (mode === "hourly") { return __("Hourly services", "webba-booking-lite"); } if (mode === "daily") { return __("Daily services / rentals", "webba-booking-lite"); } return __("Not determined yet", "webba-booking-lite"); } interface ConfigInformationPanelProps { config: ConfigInformation; } export const ConfigInformationPanel = ({ config }: ConfigInformationPanelProps) => { const isDaily = config.mode === "daily"; const { collectedCount, totalFields } = getConfigProgress(config); const entityCards = isDaily ? buildDailyUnitCards(config.daily) : config.mode === "hourly" ? buildHourlyServiceCards(config.hourly) : []; const settingsProperties = isDaily ? buildDailySettingsProperties(config.daily) : config.mode === "hourly" ? buildHourlySettingsProperties(config.hourly) : []; const entitySectionTitle = isDaily ? __("Units", "webba-booking-lite") : __("Services", "webba-booking-lite"); return (

{__("Setup progress", "webba-booking-lite")}

{config.mode ? sprintf(__("%1$d of %2$d collected", "webba-booking-lite"), collectedCount, totalFields) : __("Awaiting mode", "webba-booking-lite")}

{sprintf(__("Booking mode: %s", "webba-booking-lite"), getModeLabel(config.mode))}

{__( "Details you share in the chat are tracked here so you can see what is still needed before setup suggestions are ready.", "webba-booking-lite" )}

{!config.mode ? (

{__( "Send your first message to detect whether setup is for hourly appointments or daily rentals.", "webba-booking-lite" )}

) : ( <> {entityCards.length > 0 ? (

{entitySectionTitle}

{entityCards.map((card) => ( ))}
) : null} {settingsProperties.length > 0 ? (

{__("Settings", "webba-booking-lite")}

) : null} )}
); };