0

Is there a way to replace {{session_id}}, and {{skill_name}} in enum (share.tsx) with data from api. Below is my attempt:

Shared.tsx    

----------
export enum NotificationMessage{
    ASSIGNED_ALERT ="session {{session_id}} is now assigned to you.",
    OFFERED_ALERT ="You have received session {{session_id}} on skill \"{{skill_name}}\"",
    ASSIGN_CONFIRM_MESSAGE= "You have received session {{session_id}} on skill \"{{skill_name}}\"",

}

File B.tsx
-----------

import {NotificationMessage} from "../../shared";

// data from api
switch (data){
    case A : 
      // Is there a way to replace {{session_id}}, and/or {{skill_name}} in enum (share.tsx) with data from api.
      //My attempt to replace {{session_id}} with data.session_id
      stringA = 'NotificationMessage.ASSIGNED_ALERT%s', data.session_id;
    case B : 
      //My attempt to replace {{session_id}} and {{skill_name}} with data.session_id and data.skill_name
      stringB = NotificationMessage.OFFERED_ALERT, data.session_id, data.skill_name;
    case C : 
      //My attempt to replace {{session_id}} and {{skill_name}} with data.session_id and data.skill_name
      stringC = NotificationMessage.ASSIGN_CONFIRM_MESSAGE, data.session_id, data.skill_name;
 }
user21
  • 1,261
  • 5
  • 20
  • 41

1 Answers1

0

Look to possible solution here https://stackoverflow.com/a/4256130/7141073

You should change regexp a little as your string is slightly different.

Fyodor Yemelyanenko
  • 11,264
  • 1
  • 30
  • 38