Fix onboarding step reset after company creation
This commit is contained in:
@@ -84,18 +84,23 @@ export function OnboardingWizard() {
|
|||||||
const [createdAgentId, setCreatedAgentId] = useState<string | null>(null);
|
const [createdAgentId, setCreatedAgentId] = useState<string | null>(null);
|
||||||
const [createdIssueRef, setCreatedIssueRef] = useState<string | null>(null);
|
const [createdIssueRef, setCreatedIssueRef] = useState<string | null>(null);
|
||||||
|
|
||||||
// Sync step and company when onboarding opens with options
|
// Sync step and company when onboarding opens with options.
|
||||||
|
// Keep this independent from company-list refreshes so Step 1 completion
|
||||||
|
// doesn't get reset after creating a company.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (onboardingOpen) {
|
if (!onboardingOpen) return;
|
||||||
const cId = onboardingOptions.companyId ?? null;
|
const cId = onboardingOptions.companyId ?? null;
|
||||||
setStep(onboardingOptions.initialStep ?? 1);
|
setStep(onboardingOptions.initialStep ?? 1);
|
||||||
setCreatedCompanyId(cId);
|
setCreatedCompanyId(cId);
|
||||||
if (cId) {
|
setCreatedCompanyPrefix(null);
|
||||||
const company = companies.find((c) => c.id === cId);
|
}, [onboardingOpen, onboardingOptions.companyId, onboardingOptions.initialStep]);
|
||||||
if (company) setCreatedCompanyPrefix(company.issuePrefix);
|
|
||||||
}
|
// Backfill issue prefix for an existing company once companies are loaded.
|
||||||
}
|
useEffect(() => {
|
||||||
}, [onboardingOpen, onboardingOptions, companies]);
|
if (!onboardingOpen || !createdCompanyId || createdCompanyPrefix) return;
|
||||||
|
const company = companies.find((c) => c.id === createdCompanyId);
|
||||||
|
if (company) setCreatedCompanyPrefix(company.issuePrefix);
|
||||||
|
}, [onboardingOpen, createdCompanyId, createdCompanyPrefix, companies]);
|
||||||
|
|
||||||
const { data: adapterModels } = useQuery({
|
const { data: adapterModels } = useQuery({
|
||||||
queryKey: ["adapter-models", adapterType],
|
queryKey: ["adapter-models", adapterType],
|
||||||
|
|||||||
Reference in New Issue
Block a user