style(frontend): Prettier config + one-time repo-wide format pass
Prettier 3 (pinned), printWidth 100, double quotes — chosen to match the existing hand-formatting and minimise reflow. This commit is ONLY the mechanical format pass (`prettier --write`) plus the config/ignore/scripts, isolated so it never pollutes a feature diff. Verified behaviour-neutral: typecheck, eslint (0 errors), and vitest all green before and after. See .git-blame-ignore-revs — `git blame` skips this sha.
This commit is contained in:
@@ -24,7 +24,10 @@ export default function SetupWizard() {
|
||||
setTokenError(true);
|
||||
return;
|
||||
}
|
||||
api.setupInfo(token).then(setInfo).catch(() => setTokenError(true));
|
||||
api
|
||||
.setupInfo(token)
|
||||
.then(setInfo)
|
||||
.catch(() => setTokenError(true));
|
||||
}, [token]);
|
||||
|
||||
// Step state.
|
||||
@@ -42,8 +45,18 @@ export default function SetupWizard() {
|
||||
const [testTo, setTestTo] = useState("");
|
||||
const [testState, setTestState] = useState<"idle" | "sending" | "ok" | "fail">("idle");
|
||||
|
||||
if (tokenError) return <Centered><TokenError /></Centered>;
|
||||
if (!info) return <Centered><Loader2 className="w-6 h-6 animate-spin text-muted" /></Centered>;
|
||||
if (tokenError)
|
||||
return (
|
||||
<Centered>
|
||||
<TokenError />
|
||||
</Centered>
|
||||
);
|
||||
if (!info)
|
||||
return (
|
||||
<Centered>
|
||||
<Loader2 className="w-6 h-6 animate-spin text-muted" />
|
||||
</Centered>
|
||||
);
|
||||
|
||||
// Steps adapt to the instance: Google + SMTP need encrypted secret storage (TOKEN_ENCRYPTION_KEY).
|
||||
const steps: StepId[] = [
|
||||
@@ -72,7 +85,10 @@ export default function SetupWizard() {
|
||||
await api.setupAdmin(token, email, password);
|
||||
} else if (step === "google" && (gid.trim() || gsecret.trim())) {
|
||||
if (!gid.trim() || !gsecret.trim()) throw { detail: t("setup.google.bothRequired") };
|
||||
await api.setupConfig(token, { google_client_id: gid.trim(), google_client_secret: gsecret.trim() });
|
||||
await api.setupConfig(token, {
|
||||
google_client_id: gid.trim(),
|
||||
google_client_secret: gsecret.trim(),
|
||||
});
|
||||
} else if (step === "smtp" && smtp.host.trim()) {
|
||||
await api.setupConfig(token, {
|
||||
smtp_host: smtp.host.trim(),
|
||||
@@ -166,24 +182,65 @@ export default function SetupWizard() {
|
||||
|
||||
{step === "google" && (
|
||||
<Section title={t("setup.google.title")} desc={t("setup.google.desc")}>
|
||||
<input value={gid} onChange={(e) => setGid(e.target.value)} placeholder={t("setup.google.clientId")} className={inputCls} />
|
||||
<input value={gsecret} onChange={(e) => setGsecret(e.target.value)} placeholder={t("setup.google.clientSecret")} className={inputCls} />
|
||||
<input
|
||||
value={gid}
|
||||
onChange={(e) => setGid(e.target.value)}
|
||||
placeholder={t("setup.google.clientId")}
|
||||
className={inputCls}
|
||||
/>
|
||||
<input
|
||||
value={gsecret}
|
||||
onChange={(e) => setGsecret(e.target.value)}
|
||||
placeholder={t("setup.google.clientSecret")}
|
||||
className={inputCls}
|
||||
/>
|
||||
<p className="text-xs text-muted">{t("setup.google.skipHint")}</p>
|
||||
</Section>
|
||||
)}
|
||||
|
||||
{step === "smtp" && (
|
||||
<Section title={t("setup.smtp.title")} desc={t("setup.smtp.desc")}>
|
||||
<input value={smtp.host} onChange={(e) => setSmtp({ ...smtp, host: e.target.value })} placeholder={t("setup.smtp.host")} className={inputCls} />
|
||||
<input
|
||||
value={smtp.host}
|
||||
onChange={(e) => setSmtp({ ...smtp, host: e.target.value })}
|
||||
placeholder={t("setup.smtp.host")}
|
||||
className={inputCls}
|
||||
/>
|
||||
<div className="flex gap-2">
|
||||
<input value={smtp.port} onChange={(e) => setSmtp({ ...smtp, port: e.target.value })} placeholder={t("setup.smtp.port")} className={`${inputCls} w-24`} />
|
||||
<input value={smtp.user} onChange={(e) => setSmtp({ ...smtp, user: e.target.value })} placeholder={t("setup.smtp.user")} className={inputCls} />
|
||||
<input
|
||||
value={smtp.port}
|
||||
onChange={(e) => setSmtp({ ...smtp, port: e.target.value })}
|
||||
placeholder={t("setup.smtp.port")}
|
||||
className={`${inputCls} w-24`}
|
||||
/>
|
||||
<input
|
||||
value={smtp.user}
|
||||
onChange={(e) => setSmtp({ ...smtp, user: e.target.value })}
|
||||
placeholder={t("setup.smtp.user")}
|
||||
className={inputCls}
|
||||
/>
|
||||
</div>
|
||||
<input value={smtp.from} onChange={(e) => setSmtp({ ...smtp, from: e.target.value })} placeholder={t("setup.smtp.from")} className={inputCls} />
|
||||
<input type="password" value={smtp.password} onChange={(e) => setSmtp({ ...smtp, password: e.target.value })} placeholder={t("setup.smtp.password")} className={inputCls} />
|
||||
<input
|
||||
value={smtp.from}
|
||||
onChange={(e) => setSmtp({ ...smtp, from: e.target.value })}
|
||||
placeholder={t("setup.smtp.from")}
|
||||
className={inputCls}
|
||||
/>
|
||||
<input
|
||||
type="password"
|
||||
value={smtp.password}
|
||||
onChange={(e) => setSmtp({ ...smtp, password: e.target.value })}
|
||||
placeholder={t("setup.smtp.password")}
|
||||
className={inputCls}
|
||||
/>
|
||||
{smtp.host.trim() && (
|
||||
<div className="flex items-center gap-2 pt-1">
|
||||
<input value={testTo} onChange={(e) => setTestTo(e.target.value)} placeholder={t("setup.smtp.testTo")} className={inputCls} />
|
||||
<input
|
||||
value={testTo}
|
||||
onChange={(e) => setTestTo(e.target.value)}
|
||||
placeholder={t("setup.smtp.testTo")}
|
||||
className={inputCls}
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
onClick={sendTest}
|
||||
@@ -195,8 +252,12 @@ export default function SetupWizard() {
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
{testState === "ok" && <p className="text-xs text-emerald-500">{t("setup.smtp.testOk")}</p>}
|
||||
{testState === "fail" && <p className="text-xs text-red-400">{t("setup.smtp.testFail")}</p>}
|
||||
{testState === "ok" && (
|
||||
<p className="text-xs text-emerald-500">{t("setup.smtp.testOk")}</p>
|
||||
)}
|
||||
{testState === "fail" && (
|
||||
<p className="text-xs text-red-400">{t("setup.smtp.testFail")}</p>
|
||||
)}
|
||||
<p className="text-xs text-muted">{t("setup.smtp.skipHint")}</p>
|
||||
</Section>
|
||||
)}
|
||||
@@ -237,9 +298,7 @@ export default function SetupWizard() {
|
||||
}
|
||||
|
||||
function Centered({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<div className="min-h-screen bg-bg text-fg grid place-items-center p-4">{children}</div>
|
||||
);
|
||||
return <div className="min-h-screen bg-bg text-fg grid place-items-center p-4">{children}</div>;
|
||||
}
|
||||
|
||||
function Section({
|
||||
|
||||
Reference in New Issue
Block a user