2023-08-03 00:16:39 +00:00
|
|
|
const searchClientsData = require( './searchClients/searchClients.json' );
|
|
|
|
|
|
|
|
function searchClient( config ) {
|
|
|
|
return {
|
|
|
|
active: null,
|
2023-08-03 02:07:35 +00:00
|
|
|
getData: function ( key, value ) {
|
|
|
|
const data = Object.values( searchClientsData ).find( ( item ) => item[ key ] === value );
|
2023-08-03 00:16:39 +00:00
|
|
|
return data;
|
|
|
|
},
|
|
|
|
setActive: function ( id ) {
|
2023-08-03 02:07:35 +00:00
|
|
|
const data = this.getData( 'id', id );
|
|
|
|
if ( data && data !== this.active ) {
|
2023-12-13 22:10:24 +00:00
|
|
|
const client = require( `./searchClients/${ data.id }.js` );
|
2023-08-03 00:16:39 +00:00
|
|
|
this.active = data;
|
|
|
|
this.active.client = client( config );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @module searchClient */
|
|
|
|
module.exports = searchClient;
|