2022-11-02 22:40:14 +03:00
import { prop } from 'ramda' ;
2020-11-25 23:05:27 +03:00
import Bottle from 'bottlejs' ;
import { ConnectDecorator } from '../../container/types' ;
2022-11-03 22:15:28 +03:00
import { domainsListReducerCreator } from '../reducers/domainsList' ;
2020-11-28 11:58:05 +03:00
import { DomainSelector } from '../DomainSelector' ;
2021-08-20 18:30:07 +03:00
import { ManageDomains } from '../ManageDomains' ;
2021-08-21 18:53:06 +03:00
import { editDomainRedirects } from '../reducers/domainRedirects' ;
2020-11-25 23:05:27 +03:00
const provideServices = ( bottle : Bottle , connect : ConnectDecorator ) = > {
// Components
2020-11-28 11:58:05 +03:00
bottle . serviceFactory ( 'DomainSelector' , ( ) = > DomainSelector ) ;
2022-03-26 14:17:42 +03:00
bottle . decorator ( 'DomainSelector' , connect ( [ 'domainsList' ] , [ 'listDomains' ] ) ) ;
2020-11-25 23:05:27 +03:00
2021-08-20 18:30:07 +03:00
bottle . serviceFactory ( 'ManageDomains' , ( ) = > ManageDomains ) ;
2021-08-21 18:53:06 +03:00
bottle . decorator ( 'ManageDomains' , connect (
2022-03-26 14:17:42 +03:00
[ 'domainsList' , 'selectedServer' ] ,
[ 'listDomains' , 'filterDomains' , 'editDomainRedirects' , 'checkDomainHealth' ] ,
2021-08-21 18:53:06 +03:00
) ) ;
2021-08-20 18:30:07 +03:00
2022-11-02 22:40:14 +03:00
// Reducer
2022-11-03 22:15:28 +03:00
bottle . serviceFactory ( 'domainsListReducerCreator' , domainsListReducerCreator , 'buildShlinkApiClient' ) ;
bottle . serviceFactory ( 'domainsListReducer' , prop ( 'reducer' ) , 'domainsListReducerCreator' ) ; // TODO Improve type checks on the prop that gets picked here
2022-11-02 22:40:14 +03:00
2020-11-25 23:05:27 +03:00
// Actions
2022-11-03 22:15:28 +03:00
bottle . serviceFactory ( 'listDomains' , prop ( 'listDomains' ) , 'domainsListReducerCreator' ) ; // TODO Improve type checks on the prop that gets picked here
bottle . serviceFactory ( 'filterDomains' , prop ( 'filterDomains' ) , 'domainsListReducerCreator' ) ; // TODO Improve type checks on the prop that gets picked here
2021-08-21 18:53:06 +03:00
bottle . serviceFactory ( 'editDomainRedirects' , editDomainRedirects , 'buildShlinkApiClient' ) ;
2022-11-03 22:15:28 +03:00
bottle . serviceFactory ( 'checkDomainHealth' , prop ( 'checkDomainHealth' ) , 'domainsListReducerCreator' ) ; // TODO Improve type checks on the prop that gets picked here
2020-11-25 23:05:27 +03:00
} ;
export default provideServices ;