"use strict";
var pwa = pwa || {};
/*
Manage notification

Get notification after tomenu was load

from /components/notification
____________________

*/
//--##
pwa.notification = {};

pwa.notification.update = () => {
	logger.info( 'get notification update for a user' );
	axios.get( `https://${pwa.state.data.ctx.urlbackoffice}/notifications/user`, { headers: pwa.state.data.headers } )
		.then( rep => {
			logger.info( "list des notifs", rep.data.payload.data )
			rep.data.payload.data.number = rep.data.payload.data.notifs.length;
			document.getElementById( "topbarmenuright" )
				.innerHTML = Mustache.render( pwa.state.data.tpl.notiflist, rep.data.payload.data ) + document.getElementById( "topbarmenuright" )
				.innerHTML;
		} )
		.catch( err => {
			logger.info( `Err pwa.notification.update data for user into header ${pwa.state.data.headers}`, err );
		} );
};
