import * as DataEvent from '../tools/events/DataEvent.jsx';
import Animate from '../tools/effects/Animate.jsx';
import * as Ease from '../tools/effects/Animate.jsx';
import TextEffects from '../tools/effects/TextEffects.jsx';
import TaskFipamo from '../tasks/TaskFipamo.jsx';
class DisplayAdminFipamo {
    //--------------------------
    // constructor
    //--------------------------
    constructor() {
        this.start();
    }
    //--------------------------
    // methods
    //--------------------------

    start() {
        document.getElementById("saved-sumbit-btn").addEventListener('click', f => {
            console.log('CLICKED');
            let edit = false;
            if (f.target.getAttribute('data-action') == 'saved-edit')
                edit = true;
            
            new TaskFipamo().submitLink(edit).then((response) => {
                let note = JSON.parse(response['response']['request'].response);
                if(note.message == 'link added' || note.message == 'bookmark updated')
                {
                    switch(note.message)
                    {
                        case 'link added':
                            document.getElementById('saved_text').value = ''
                            break
                        
                        case 'bookmark updated':
                            document.getElementById('saved_text').value = 'updated'

                            break
                    }     
                }else{
                    console.log(note);
                }
            }).catch((err) => {
                //console.log(err) 
            });
        });
    }

    //--------------------------
    // event handlers
    //--------------------------
}

export {
    DisplayAdminFipamo as
    default
}
