mirror of
https://github.com/fleetdm/fleet
synced 2026-05-19 15:09:20 +00:00
56 lines
1.5 KiB
TypeScript
56 lines
1.5 KiB
TypeScript
import React, { ReactChild, useContext } from "react";
|
|
import classnames from "classnames";
|
|
import { formatDistanceToNow } from "date-fns";
|
|
|
|
import SandboxExpiryMessage from "components/Sandbox/SandboxExpiryMessage";
|
|
import AppleBMTermsMessage from "components/MDM/AppleBMTermsMessage";
|
|
|
|
import SandboxGate from "components/Sandbox/SandboxGate";
|
|
import { AppContext } from "context/app";
|
|
|
|
interface IMainContentProps {
|
|
children: ReactChild;
|
|
/** An optional classname to pass to the main content component.
|
|
* This can be used to apply styles directly onto the main content div
|
|
*/
|
|
className?: string;
|
|
}
|
|
|
|
const baseClass = "main-content";
|
|
|
|
/**
|
|
* A component that controls the layout and styling of the main content region
|
|
* of the application.
|
|
*/
|
|
const MainContent = ({
|
|
children,
|
|
className,
|
|
}: IMainContentProps): JSX.Element => {
|
|
const classes = classnames(baseClass, className);
|
|
const { sandboxExpiry, config, isSandboxMode, isPremiumTier } = useContext(
|
|
AppContext
|
|
);
|
|
|
|
const isAppleBmTermsExpired = config?.mdm?.apple_bm_terms_expired;
|
|
|
|
const sandboxExpiryTime =
|
|
sandboxExpiry === undefined
|
|
? "..."
|
|
: formatDistanceToNow(new Date(sandboxExpiry));
|
|
|
|
return (
|
|
<div className={classes}>
|
|
{isAppleBmTermsExpired && isPremiumTier && !isSandboxMode && (
|
|
<AppleBMTermsMessage />
|
|
)}
|
|
<SandboxGate
|
|
fallbackComponent={() => (
|
|
<SandboxExpiryMessage expiry={sandboxExpiryTime} />
|
|
)}
|
|
/>
|
|
{children}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default MainContent;
|