import React from 'react';
import ReactDOMServer from 'react-dom/server';
import { sprintf } from 'jed';
import helpers from '../../move_to_foreman/common/helpers';
import { notify } from '../../move_to_foreman/foreman_toast_notifications';
const getErrors = task => (
{task.humanized.errors.map(error => (
- {error}
))}
);
export const renderTaskStartedToast = (task) => {
const message = (
{sprintf('Task %s has started.', task.humanized.action)}
{' '}
{__('Click here to go to the tasks page for the task.')}
);
notify({
message: ReactDOMServer.renderToStaticMarkup(message),
type: 'info',
});
};
export const renderTaskFinishedToast = (task) => {
const message = (
{`${__(`Task ${task.humanized.action} completed with a result of ${task.result}.`)}`}
{' '}
{task.errors ? getErrors(task) : ''}
{__('Click here to go to the tasks page for the task.')}
);
notify({
message: ReactDOMServer.renderToStaticMarkup(message),
type: task.result,
});
};