Create scandipwa extension using scandipwa-cli, for that navigate to your theme folder, and execute scandipwa extension create scandipwa-socialshare
In your scandipwa theme packages folder you should locate scandipwa-socialshare extension folder
NOTE. In my case ONLY for development purposes extension is located right in Magento module so my scandipwa/package.json file looks like
3. First, let’s create a query that going to query graph that we created in STEP-4create query folder in scandipwa-socialshare/src <- (in future <SOURCE>)and SocialShare.query.js in it
import { showNotification } from 'Store/Notification/Notification.action';
import BrowserDatabase from 'Util/BrowserDatabase';
import { QueryDispatcher } from 'Util/Request';
import { ONE_MONTH_IN_SECONDS } from 'Util/Request/QueryDispatcher';
import SocialShareQuery from '../../query/SocialShare.query';
import { updateSocialShare } from './SocialShare.action';
/** @namespace ScandipwaSocialshare/Store/SocialShare/Dispatcher/SocialShareDispatcher */
export class SocialShareDispatcher extends QueryDispatcher {
__construct() {
super.__construct('SocialShare');
}
onSuccess(data, dispatch) {
if (data) {
BrowserDatabase.setItem(data, 'SocialShare', ONE_MONTH_IN_SECONDS);
dispatch(updateSocialShare(data));
}
}
onError(error, dispatch) {
dispatch(showNotification('error', __('Error fetching SocialShare!'), error));
}
prepareRequest() {
return [
SocialShareQuery.getQuery()
];
}
}
export default new SocialShareDispatcher();
Unfortunately on this step, we can't see any visual outcome, the only thing that you can do, is to restart your frontend and ensure that it is still functional, believe in the next step we will have much more fun)).