Some checks failed
build-images / web (push) Has been cancelled
vision2026-ci / Python SDK resource tests (push) Has been cancelled
build-images / api (push) Has been cancelled
build-images / worker-gpu (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Has been cancelled
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Has been cancelled
codeql / Analyze (javascript-typescript) (push) Has been cancelled
codeql / Analyze (python) (push) Has been cancelled
perf / API hot-path micro-smoke (budgeted) (push) Has been cancelled
perf / Desktop engine crates (release build check) (push) Has been cancelled
vision2026-ci / API phase modules (ruff + pytest) (push) Has been cancelled
vision2026-ci / Alembic upgrade + drift check (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Has been cancelled
Paid, hosted product at menivor.com, now retired as a company project. Fresh squashed history of the cleaned working tree (secret-scanned, no .env, no customer data, no outreach logs). Built on MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
85 lines
3.0 KiB
TypeScript
85 lines
3.0 KiB
TypeScript
"use client";
|
|
|
|
import * as React from "react";
|
|
|
|
import { ErrorText, useRequestOptions } from "@/src/features/ad-studio/shared";
|
|
import { readableApiError } from "@/src/shared/launch-gate";
|
|
import { getApprovalSettings, updateApprovalSettings, type ApprovalFeedSettings, type AutoSource } from "./api";
|
|
|
|
const HELP: Record<AutoSource, string> = {
|
|
capture_publish: "Each finished capture becomes a pending reel-ad suggestion. Approving it spends credits.",
|
|
catalog_import: "Each newly imported store product becomes a pending Ad Studio suggestion.",
|
|
};
|
|
|
|
/**
|
|
* Opt-in sources for the approvals feed. Off by default: captures and store
|
|
* imports only add suggestions here when the owner turns them on.
|
|
*/
|
|
export function AutoSourcesSettings({ onChanged }: { onChanged: () => void }) {
|
|
const requestOptions = useRequestOptions();
|
|
const [settings, setSettings] = React.useState<ApprovalFeedSettings | null>(null);
|
|
const [saving, setSaving] = React.useState<AutoSource | "">("");
|
|
const [error, setError] = React.useState("");
|
|
|
|
React.useEffect(() => {
|
|
let cancelled = false;
|
|
(async () => {
|
|
try {
|
|
const next = await getApprovalSettings(await requestOptions());
|
|
if (!cancelled) setSettings(next);
|
|
} catch (err) {
|
|
if (!cancelled) setError(readableApiError(err, "Couldn't update this setting. Try again."));
|
|
}
|
|
})();
|
|
return () => {
|
|
cancelled = true;
|
|
};
|
|
}, [requestOptions]);
|
|
|
|
const toggle = async (source: AutoSource, on: boolean) => {
|
|
setSaving(source);
|
|
setError("");
|
|
try {
|
|
setSettings(await updateApprovalSettings({ [source]: on }, await requestOptions()));
|
|
onChanged();
|
|
} catch (err) {
|
|
setError(readableApiError(err, "Couldn't update this setting. Try again."));
|
|
} finally {
|
|
setSaving("");
|
|
}
|
|
};
|
|
|
|
if (!settings && !error) return null;
|
|
|
|
return (
|
|
<details className="rounded-lg border p-3 text-sm">
|
|
<summary className="cursor-pointer font-medium">Automatic suggestions</summary>
|
|
<p className="mt-2 text-xs text-muted-foreground">
|
|
Off unless you turn them on. Turning one off removes its pending suggestions; nothing already approved changes.
|
|
</p>
|
|
{settings ? (
|
|
<ul className="mt-2 space-y-2">
|
|
{(Object.keys(settings.auto_sources) as AutoSource[]).map((source) => (
|
|
<li key={source}>
|
|
<label className="flex items-start gap-2">
|
|
<input
|
|
type="checkbox"
|
|
className="mt-0.5"
|
|
checked={settings.auto_sources[source]}
|
|
disabled={saving !== ""}
|
|
onChange={(event) => void toggle(source, event.target.checked)}
|
|
/>
|
|
<span>
|
|
<span className="block">{settings.labels[source] ?? source}</span>
|
|
<span className="block text-xs text-muted-foreground">{HELP[source]}</span>
|
|
</span>
|
|
</label>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
) : null}
|
|
{error ? <ErrorText message={error} /> : null}
|
|
</details>
|
|
);
|
|
}
|