import Ember from 'ember';
const { getOwner } = Ember;

export default Ember.Service.extend({
  i18n: Ember.inject.service(),

  convert: function(values) {
    var offerId = values.offer.id;
    var msg = values.body;
    var url_with_text = msg.slice(msg.indexOf("[") + 1, msg.indexOf("]"));
    var url_text_begin = url_with_text.indexOf("|");
    var url_text = url_with_text.slice(0, url_text_begin);
    var url_for = url_with_text.slice(url_text_begin + 1);

    if(url_for === 'transport_page'){
      values.body = msg.replace("["+url_with_text+"]", `<a href='/offers/${offerId}/plan_delivery'>${url_text}</a>`);
    }
  }
});

@@ -15,15 +15,15 @@
 rom 
-'
+%22
 ember
-'
+%22
 ;%0Aco
@@ -465,16 +465,17 @@
 %0A%0A    if
+ 
 (url_for
@@ -479,17 +479,17 @@
 for === 
-'
+%22
 transpor
@@ -498,10 +498,11 @@
 page
-')
+%22) 
 %7B%0A  
@@ -535,12 +535,23 @@
 ace(
-%22%5B%22+
+%0A        %22%5B%22 + 
 url_
@@ -563,13 +563,23 @@
 text
-+
+ + 
 %22%5D%22,
+%0A       
  %60%3Ca
@@ -635,16 +635,270 @@
 xt%7D%3C/a%3E%60
+%0A      );%0A    %7D%0A%0A    if (url_for === %22feedback_form%22) %7B%0A      values.body = msg.replace(%0A        %22%5B%22 + url_with_text + %22%5D%22,%0A        %60%3Ca href=' https://crossroads-foundation.formstack.com/forms/goodcity_feedback?OfferId=$%7BofferId%7D'%3E$%7Burl_text%7D%3C/a%3E%60%0A      
 );%0A    %7D

Add general text message for feedback form