feat: add governed assisted form intake
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Link2, RefreshCw } from "lucide-react";
|
||||
import { Link2, RefreshCw, UserRoundPlus } from "lucide-react";
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import { ActionToolbar,
|
||||
Button,
|
||||
@@ -21,6 +21,7 @@ import { ActionToolbar,
|
||||
import { listFormInstances, type FormInstance } from "../../api/formsRuntime";
|
||||
import { FORMS_RUNTIME_DOCUMENTATION, FORMS_RUNTIME_I18N } from "./interfacePatterns";
|
||||
import IntakeProfilesDialog from "./IntakeProfilesDialog";
|
||||
import AssistedIntakeDialog from "./AssistedIntakeDialog";
|
||||
|
||||
|
||||
const OPEN_STATUSES = ["started", "draft", "submitted", "validated", "needs_review"];
|
||||
@@ -34,7 +35,10 @@ export default function FormsRuntimePage({ settings, auth }: PlatformRouteContex
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState("");
|
||||
const [intakeOpen, setIntakeOpen] = useState(false);
|
||||
const [assistedOpen, setAssistedOpen] = useState(false);
|
||||
const canAdmin = hasScope(auth, "forms_runtime:workspace:admin");
|
||||
const canAssist = hasScope(auth, "forms_runtime:submission:assist")
|
||||
|| hasScope(auth, "forms_runtime:workspace:write");
|
||||
|
||||
const load = useCallback((signal?: AbortSignal) => {
|
||||
setLoading(true);
|
||||
@@ -74,6 +78,12 @@ export default function FormsRuntimePage({ settings, auth }: PlatformRouteContex
|
||||
Public intake
|
||||
</Button>
|
||||
}
|
||||
{canAssist &&
|
||||
<Button onClick={() => setAssistedOpen(true)}>
|
||||
<UserRoundPlus size={16} aria-hidden="true" />
|
||||
Assisted intake
|
||||
</Button>
|
||||
}
|
||||
<label>
|
||||
<span>Status</span>
|
||||
<select value={status} onChange={(event) => setStatus(event.target.value)}>
|
||||
@@ -117,6 +127,16 @@ export default function FormsRuntimePage({ settings, auth }: PlatformRouteContex
|
||||
</PageScrollViewport>
|
||||
</WorkspaceFrame>
|
||||
<IntakeProfilesDialog open={intakeOpen} settings={settings} onClose={() => setIntakeOpen(false)} />
|
||||
<AssistedIntakeDialog
|
||||
open={assistedOpen}
|
||||
settings={settings}
|
||||
language={language}
|
||||
onClose={() => setAssistedOpen(false)}
|
||||
onStarted={(instanceId) => {
|
||||
setAssistedOpen(false);
|
||||
navigate(`/forms-runtime/${encodeURIComponent(instanceId)}`);
|
||||
}}
|
||||
/>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user