Skip to content

Commit

Permalink
Super admin api fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
shlok-manojkumar committed Oct 13, 2022
1 parent 4a34ec0 commit b9c3371
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 7 deletions.
2 changes: 1 addition & 1 deletion backend/.env
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ COOKIE_SECRET=medusa
REDIS_URL=redis://localhost:6379
REDIS_URI=redis://localhost:6379

ADMIN_CORS=http://localhost:7000
ADMIN_CORS=http://localhost:7000,http://localhost:4000
STORE_CORS=http://localhost:8000

MINIO_ENDPOINT=http://localhost:9000
Expand Down
2 changes: 1 addition & 1 deletion super-admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"yup": "^0.32.11"
},
"scripts": {
"start": "react-scripts start",
"start": "set PORT=4000 && react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
Expand Down
11 changes: 11 additions & 0 deletions super-admin/src/hooks/useAuth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { adminAuth } from 'services/planner/plannerAction';

const useAuth = async () => {
let email = '[email protected]';
let password = 'supersecret';

await adminAuth({email, password});

}

export default useAuth;
11 changes: 9 additions & 2 deletions super-admin/src/services/planner/plannerAction.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import * as actionTypes from './plannerConsts';
import { loadPostService } from './plannerService';
import { loadPostService, AuthService } from './plannerService';
import { dispatch } from '../dispatcher';

const loadPost = async () => {
var values = await loadPostService();
console.log(values);
dispatch({ type: actionTypes.GET_WORK_PACKAGE_DATA, data: values.data });
};

const adminAuth = async ({ email, password }) => {
var result = await AuthService({ email, password });
console.log(result)
}


const startLoader = () => {
dispatch({ type: actionTypes.PLANNER_LOADING, isLoading: true });
};
Expand All @@ -15,4 +22,4 @@ const stopLoader = () => {
dispatch({ type: actionTypes.PLANNER_LOADING, isLoading: false });
};

export { loadPost, startLoader, stopLoader };
export { loadPost, startLoader, stopLoader, adminAuth };
18 changes: 15 additions & 3 deletions super-admin/src/services/planner/plannerService.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { headersWithoutToken } from '../configs/headerConfigs';

export const saveData = async (data) => {
const response = await post({
url: URLConfigs.BASE_URL + URLConfigs.GET_Work_Package_URL,
url: URLConfigs.BASE_URL + URLConfigs.GET_STORE,
headers: headersWithoutToken(),
...data
});
Expand All @@ -14,8 +14,20 @@ export const saveData = async (data) => {

export const loadPostService = async () => {
const response = await get({
url: URLConfigs.BASE_URL + URLConfigs.GET_Work_Package_URL,
headers: headersWithoutToken()
url: URLConfigs.BASE_URL + URLConfigs.GET_STORE,
});

return response;
};

export const AuthService = async ({ email, password }) => {
let data = {
email: email,
password: password
};
const response = await post({
url: URLConfigs.BASE_URL + URLConfigs.ADMIN_AUTH,
data
});

return response;
Expand Down
2 changes: 2 additions & 0 deletions super-admin/src/views/pages/page/EmployeePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import NestedModal from './AddPopup';
import { loadPost } from '../../../services/planner/plannerAction';
import { useSelector } from 'react-redux';
import Loader from 'ui-component/Loader';
import useAuth from 'hooks/useAuth';

export default function EmployeePage() {
const data = useSelector((state) => state.planner.data);
Expand All @@ -17,6 +18,7 @@ export default function EmployeePage() {
}, []);

const fetchData = async () => {
await useAuth();
await loadPost();
};

Expand Down

0 comments on commit b9c3371

Please sign in to comment.