"use client"; import React, { useState } from "react"; import { FormError, Modal, ModalButtons, useSubmit } from "@/components/ui"; import { post, withWarnings } from "@/components/install/shared"; import type { Customer } from "@/lib/types"; import type { Done } from "./shared"; /** * Hub 2.25.0: make a customer a demo client (a church used for showing Cross Code), or an ordinary * one again. A demo client's installs are all demo sites, Accounts included, and it isn't billed. */ export function DemoClientModal({ c, onClose, onDone }: { c: Customer; onClose: () => void; onDone: Done }) { const [confirmName, setConfirmName] = useState(""); const { busy, error, run } = useSubmit(); const submit = (e: React.FormEvent) => { e.preventDefault(); run(async () => { const r = await post<{ sites: number; warnings?: string[] }>(`/api/admin/customers/${c.id}/demo`, { isDemo: !c.isDemo, confirm: confirmName }); const sites = `${r.sites} install${r.sites === 1 ? "" : "s"}`; onDone({ type: "ok", text: withWarnings(c.isDemo ? `${c.name} is an ordinary customer again: ${sites} no longer demo sites. Billing stays off until you set it up.` : `${c.name} is a demo client: ${sites} marked as demo sites, and it isn't billed.`, r) }); }); }; if (c.isDemo) return (

Its installs stop being demo sites, so no more demo data can be loaded on them. Billing stays "not invoiced" until you set up its schedule.

); return (
setConfirmName(e.target.value)} />
); }