mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 12:20:31 +00:00
22 lines
586 B
TypeScript
22 lines
586 B
TypeScript
import React from 'react';
|
|
import { Redirect } from 'react-router-dom';
|
|
import { useOneClickDemoBoot } from './OneClickDemoBoot';
|
|
|
|
interface EnsureOneClickDemoAccountEnabledProps {
|
|
children: React.ReactNode;
|
|
redirectTo?: string;
|
|
}
|
|
|
|
export const EnsureOneClickDemoAccountEnabled = ({
|
|
children,
|
|
redirectTo = '/',
|
|
}: EnsureOneClickDemoAccountEnabledProps) => {
|
|
const { authMeta } = useOneClickDemoBoot();
|
|
const enabled = authMeta?.meta?.one_click_demo?.enable || false;
|
|
|
|
if (!enabled) {
|
|
return <Redirect to={{ pathname: redirectTo }} />;
|
|
}
|
|
return <>{children}</>;
|
|
};
|