saleor-apps-redis_apl/apps/slack/src/components/AccessWarning/AccessWarning.tsx

31 lines
868 B
TypeScript
Raw Normal View History

import React from "react";
2023-06-22 08:32:25 +00:00
import { Text } from "@saleor/macaw-ui/next";
type WarningCause =
| "not_in_iframe"
| "missing_access_token"
| "invalid_access_token"
| "unknown_cause";
interface AccessWarningProps {
cause?: WarningCause;
}
const warnings: Record<WarningCause, string> = {
not_in_iframe: "The view can only be displayed in the iframe.",
missing_access_token: "App doesn't have an access token.",
invalid_access_token: "Access token is invalid.",
unknown_cause: "Something went wrong.",
};
export function AccessWarning({ cause = "unknown_cause" }: AccessWarningProps) {
return (
<div suppressHydrationWarning>
2023-06-22 08:32:25 +00:00
<Text variant="heading">App can&apos;t be accessed outside of the Saleor Dashboard</Text>
<Text variant="heading" style={{ marginTop: "2rem" }}>
{warnings[cause]}
2023-06-22 08:32:25 +00:00
</Text>
</div>
);
}