> For the complete documentation index, see [llms.txt](https://docs.scandipwa.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.scandipwa.com/tutorials/scandipwa-social-share/step-5-creating-extension-base-redux-store.md).

# STEP-5 Creating Extension, Base Redux Store

[**STEP-5**](https://github.com/GAkim/SocialShareGraphQl/tree/STEP-5)

{% embed url="<https://www.youtube.com/watch?v=wm8qPqEypd8>" %}

1. Create scandipwa extension using scandipwa-cli, for that navigate to your theme folder, and execute `scandipwa extension create  scandipwa-socialshare`
2. 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**

```javascript
"dependencies": {
   "@scandipwa/scandipwa": "4.4.0",
   "scandipwa-socialshare": "file:../app/code/ScandiPWA/SocialShareGraphQl/scandipwa-socialshare"
},
"scandipwa": {
   "type": "theme",
   "locales": {
       "en_US": true
   },
   "parentTheme": "@scandipwa/scandipwa",
   "extensions": {
       "scandipwa-socialshare": true
   }
},
```

Your file should look like so.

```javascript
"dependencies": {
   "@scandipwa/scandipwa": "4.4.0",
   "scandipwa-socialshare": "file:packages/scandipwa-socialshare"
},
"scandipwa": {
   "type": "theme",
   "locales": {
       "en_US": true
   },
   "parentTheme": "@scandipwa/scandipwa",
   "extensions": {
       "scandipwa-socialshare": true
   }
},
```

&#x20;  3\. First, let’s create a query that going to query graph that we created in STEP-4\
&#x20;   create **query** folder in **scandipwa-socialshare/src** <- (in future **\<SOURCE>**) and **SocialShare.query.js** in it

{% code title="scandipwa-socialshare/src/query/SocialShare.query.js" %}

```javascript
import { Field } from 'Util/Query';

/** @namespace ScandipwaSocialshare/Query/SocialShare/Query/SocialShareQuery */
export class SocialShareQuery {
   getQuery() {
       return new Field('socialShare')
           .addFieldList(['enabled']);
   }
}

export default new SocialShareQuery();
```

{% endcode %}

4\. Now we going to create the SocialShare redux store, create **store** folder in **\<SOURCE>/**  and **SocialShare**  folder in **\<SOURCE>/store/**

5\. In **\<SOURCE>/store/SocialShare** create **SocialShare.action.js**

{% code title="scandipwa-socialshare/src/store/SocialShare/SocialShare.action.js" %}

```javascript
export const UPDATE_SOCIAL_SHARE = 'UPDATE_SOCIAL_SHARE';

/** @namespace Store/SocialShare/Action/updateSocialShare */
export const updateSocialShare = (socialShare) => ({
   type: UPDATE_SOCIAL_SHARE,
   socialShare
});
```

{% endcode %}

6\. In **\<SOURCE>/store/SocialShare** create **SocialShare.reducer.js**

{% code title="scandipwa-socialshare/src/store/SocialShare/SocialShare.reducer.js" %}

```javascript
import { UPDATE_SOCIAL_SHARE } from './SocialShare.action';

/** @namespace ScandipwaSocialshare/Store/SocialShare/Reducer/getInitialState */
export const getInitialState = () => ({
   socialShare: {
       enabled: 'not'
   }
});

/** @namespace ScandipwaSocialshare/Store/SocialShare/Reducer/SocialShareReducer */
export const SocialShareReducer = (
   state = getInitialState(),
   action
) => {
   const {
       type,
       socialShare
   } = action;

   switch (type) {
   case UPDATE_SOCIAL_SHARE:
       return {
           ...state,
           ...socialShare
       };

   default:
       return state;
   }
};

export default SocialShareReducer;
```

{% endcode %}

7\. And finally in **\<SOURCE>/store/SocialShare** create **SocialShare.dispatcher.js**

{% code title="scandipwa-socialshare/src/store/SocialShare/SocialShare.dispatcher.js" %}

```javascript
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();
```

{% endcode %}

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)).<br>
