define('modules/smart-assistant/views/stream/notes/smart-action', ['views/stream/note'], function (NoteView) {

    return NoteView.extend({

        templateContent: '' +
            '<div class="sa-action-note sa-action-{{status}}" style="padding: 6px 12px; border-radius: 8px; direction: rtl; text-align: right; font-size: 13px;">' +
            '<span class="fas {{icon}}" style="margin-left: 6px;"></span>' +
            '{{{formattedPost}}}' +
            '</div>',

        data: function () {
            var data = NoteView.prototype.data.call(this);
            var noteData = this.model.get('data') || {};
            var status = noteData.status || 'executed';

            data.post = this.model.get('post');
            data.formattedPost = this.getHelper().escapeString(data.post || '');
            data.status = status;

            if (status === 'executed') {
                data.icon = 'fa-check-circle';
            } else if (status === 'rejected') {
                data.icon = 'fa-ban';
            } else {
                data.icon = 'fa-exclamation-triangle';
            }

            return data;
        },

        afterRender: function () {
            NoteView.prototype.afterRender.call(this);

            var noteData = this.model.get('data') || {};
            var status = noteData.status || 'executed';
            var $note = this.$el.find('.sa-action-note');

            if (status === 'executed') {
                $note.css({background: '#e8f5e9', color: '#2e7d32'});
            } else if (status === 'rejected') {
                $note.css({background: '#f5f5f5', color: '#999'});
            } else {
                $note.css({background: '#fce4ec', color: '#c62828'});
            }
        },
    });
});
