2023-02-09 10:58:20 +00:00
|
|
|
import React from "react";
|
2023-06-22 08:32:25 +00:00
|
|
|
import { Text } from "@saleor/macaw-ui/next";
|
2023-02-09 10:58:20 +00:00
|
|
|
|
|
|
|
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.",
|
|
|
|
};
|
|
|
|
|
2023-04-05 18:27:23 +00:00
|
|
|
export function AccessWarning({ cause = "unknown_cause" }: AccessWarningProps) {
|
2023-02-09 10:58:20 +00:00
|
|
|
return (
|
2023-06-22 08:47:39 +00:00
|
|
|
<div>
|
|
|
|
<Text as={"h2"} variant="heading">
|
|
|
|
App can't be accessed outside of the Saleor Dashboard
|
|
|
|
</Text>
|
|
|
|
<Text variant="body" style={{ marginTop: "2rem" }}>
|
2023-02-09 10:58:20 +00:00
|
|
|
❌ {warnings[cause]}
|
2023-06-22 08:32:25 +00:00
|
|
|
</Text>
|
2023-02-09 10:58:20 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|