ui: keep first-run onboarding mounted during company creation
This commit is contained in:
@@ -134,11 +134,17 @@ function boardRoutes() {
|
|||||||
|
|
||||||
function CompanyRootRedirect() {
|
function CompanyRootRedirect() {
|
||||||
const { companies, selectedCompany, loading } = useCompany();
|
const { companies, selectedCompany, loading } = useCompany();
|
||||||
|
const { onboardingOpen } = useDialog();
|
||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
return <div className="mx-auto max-w-xl py-10 text-sm text-muted-foreground">Loading...</div>;
|
return <div className="mx-auto max-w-xl py-10 text-sm text-muted-foreground">Loading...</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Keep the first-run onboarding mounted until it completes.
|
||||||
|
if (onboardingOpen) {
|
||||||
|
return <NoCompaniesStartPage autoOpen={false} />;
|
||||||
|
}
|
||||||
|
|
||||||
const targetCompany = selectedCompany ?? companies[0] ?? null;
|
const targetCompany = selectedCompany ?? companies[0] ?? null;
|
||||||
if (!targetCompany) {
|
if (!targetCompany) {
|
||||||
return <NoCompaniesStartPage />;
|
return <NoCompaniesStartPage />;
|
||||||
@@ -168,15 +174,16 @@ function UnprefixedBoardRedirect() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function NoCompaniesStartPage() {
|
function NoCompaniesStartPage({ autoOpen = true }: { autoOpen?: boolean }) {
|
||||||
const { openOnboarding } = useDialog();
|
const { openOnboarding } = useDialog();
|
||||||
const opened = useRef(false);
|
const opened = useRef(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!autoOpen) return;
|
||||||
if (opened.current) return;
|
if (opened.current) return;
|
||||||
opened.current = true;
|
opened.current = true;
|
||||||
openOnboarding();
|
openOnboarding();
|
||||||
}, [openOnboarding]);
|
}, [autoOpen, openOnboarding]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mx-auto max-w-xl py-10">
|
<div className="mx-auto max-w-xl py-10">
|
||||||
|
|||||||
Reference in New Issue
Block a user