2024-05-31 13:20:30 +00:00
|
|
|
import React, { useContext } from "react";
|
2023-09-11 11:52:24 +00:00
|
|
|
|
2024-05-31 13:20:30 +00:00
|
|
|
import { AppContext } from "context/app";
|
2023-09-11 11:52:24 +00:00
|
|
|
import EmptyTable from "components/EmptyTable";
|
|
|
|
|
import Button from "components/buttons/Button";
|
|
|
|
|
import { InjectedRouter } from "react-router";
|
|
|
|
|
|
2025-12-02 12:11:10 +00:00
|
|
|
const baseClass = "generic-msg-with-nav-button";
|
2023-09-11 11:52:24 +00:00
|
|
|
|
2025-12-02 12:11:10 +00:00
|
|
|
interface IGenericMsgWithNavButtonProps {
|
2023-09-11 11:52:24 +00:00
|
|
|
router: InjectedRouter;
|
2025-12-02 12:11:10 +00:00
|
|
|
header: string;
|
|
|
|
|
info: string;
|
|
|
|
|
/** The path to navigate the user to when they press the button. */
|
|
|
|
|
path: string;
|
|
|
|
|
buttonText: string;
|
2023-09-11 11:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
2025-12-02 12:11:10 +00:00
|
|
|
/** This is a generic component that renders a message with a header, info, and button that will navigate to a path
|
|
|
|
|
* for global admins
|
|
|
|
|
*
|
|
|
|
|
* TODO: consider removing isGlobalAdmin check in here and pushing up to parent */
|
|
|
|
|
const GenericMsgWithNavButton = ({
|
2024-10-21 11:28:44 +00:00
|
|
|
router,
|
|
|
|
|
header,
|
|
|
|
|
info,
|
2025-12-02 12:11:10 +00:00
|
|
|
path,
|
|
|
|
|
buttonText,
|
|
|
|
|
}: IGenericMsgWithNavButtonProps) => {
|
2024-05-31 13:20:30 +00:00
|
|
|
const { isGlobalAdmin } = useContext(AppContext);
|
|
|
|
|
|
2023-09-11 11:52:24 +00:00
|
|
|
const onConnectClick = () => {
|
2025-12-02 12:11:10 +00:00
|
|
|
router.push(path);
|
2023-09-11 11:52:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const renderConnectButton = () => {
|
2024-05-31 13:20:30 +00:00
|
|
|
return isGlobalAdmin ? (
|
2023-09-11 11:52:24 +00:00
|
|
|
<Button
|
|
|
|
|
onClick={onConnectClick}
|
|
|
|
|
className={`${baseClass}__connectAPC-button`}
|
|
|
|
|
>
|
2024-10-21 11:28:44 +00:00
|
|
|
{buttonText}
|
2023-09-11 11:52:24 +00:00
|
|
|
</Button>
|
2024-05-31 13:20:30 +00:00
|
|
|
) : (
|
|
|
|
|
<></>
|
2023-09-11 11:52:24 +00:00
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<EmptyTable
|
2024-10-21 11:28:44 +00:00
|
|
|
className={baseClass}
|
2025-12-02 12:11:10 +00:00
|
|
|
header={header}
|
|
|
|
|
info={info}
|
2023-09-11 11:52:24 +00:00
|
|
|
primaryButton={renderConnectButton()}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2025-12-02 12:11:10 +00:00
|
|
|
export default GenericMsgWithNavButton;
|