import i18next from "i18next";
import { runInAction } from "mobx";
import isDefined from "../../Core/isDefined";
import ViewState from "../../ReactViewModels/ViewState";
import Collapsible from "../Custom/Collapsible/Collapsible";
import parseCustomMarkdownToReact from "../Custom/parseCustomMarkdownToReact";
import Text, { TextSpan } from "../../Styled/Text";
import { RawButton } from "../../Styled/Button";
import Spacing from "../../Styled/Spacing";
export const shareConvertNotification = (
messages: import("catalog-converter").ShareResult["messages"]
) =>
function shareConvertNotification(viewState: ViewState) {
const messagesForPath: { [path: string]: string[] } = {};
messages?.forEach((message: any) => {
let pathString = message.path?.join(": ");
if (!pathString || pathString === null || pathString === "")
pathString = "root";
if (isDefined(messagesForPath[pathString])) {
messagesForPath[pathString].push(message.message);
} else {
messagesForPath[pathString] = [message.message];
}
});
const rootMessages = messagesForPath["root"];
delete messagesForPath["root"];
const showHelp = () => {
viewState.showHelpPanel();
viewState.selectHelpMenuItem("storymigration");
viewState.terria.notificationState.dismissCurrentNotification();
};
const showFeedback = () => {
runInAction(() => {
viewState.feedbackFormIsVisible = true;
});
viewState.terria.notificationState.dismissCurrentNotification();
};
return (
<>
{parseCustomMarkdownToReact(
i18next.t("share.convertNotificationMessage")
)}
{parseCustomMarkdownToReact(
i18next.t("share.convertNotificationHelp")
)}
{parseCustomMarkdownToReact(
i18next.t("share.convertNotificationFeedback")
)}
{rootMessages && (
<>
{rootMessages.map((message, i) => (
- {message}
))}
>
)}
{Object.entries(messagesForPath).map(([path, messages]) => (
<>
{messages.map((message, i) => (
- {message}
))}
>
))}
>
);
};