scandipwa/packages/@scandipwa/version/src/plugin/FooterComponent.plugin.js
Copy import axios from 'axios' ;
import ContentWrapper from 'Component/ContentWrapper' ;
export const VERSION_ROUTE = '/scandipwa/version' ;
const getVersion = (instance) => {
axios .get ( VERSION_ROUTE ) .then ((response) => {
instance .setState ({ version : response .data });
instance .forceUpdate ();
});
};
const state = (original) => ({
... original ,
version : ''
});
const componentDidMount = (args , callback , instance) => {
callback ( ... args);
getVersion (instance);
};
const renderCopyrightContent = (args , callback , instance) => {
const { version } = instance .state;
return (
<>
{ callback ( ... args) }
< ContentWrapper
mix = { { block : 'Footer' , elem : 'CopyrightContentWrapper' } }
wrapperMix = { { block : 'Footer' , elem : 'CopyrightContent' } }
label = ""
>
< span block = "Footer" elem = "Copyright" >
{ version }
</ span >
</ ContentWrapper >
</>
);
};
export default {
'Component/Footer/Component' : {
'member-function' : {
componentDidMount ,
renderCopyrightContent
} ,
'member-property' : {
state
}
}
};