Skip to content

Commit

Permalink
Merge pull request #3 from yoosaemsol/fix/api
Browse files Browse the repository at this point in the history
Fix/api
  • Loading branch information
yoosaemsol authored Jul 13, 2021
2 parents 9169e72 + 05ca889 commit 074824f
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 84 deletions.
8 changes: 2 additions & 6 deletions console/src/components/DashboardNavbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ const Zone = () => {
useEffect(() => {
let completed = false;
async function get() {
const result = await axios.get(`${API_SERVER}/inner/groups`, {
withCredentials: true
});
const result = await axios.get(`${API_SERVER}/inner/groups`);
if (!completed) setData(result.data);
dispatch(filterByZone(result.data[0].Id));
}
Expand Down Expand Up @@ -83,9 +81,7 @@ const DashboardNavbar = ({ onMobileNavOpen, ...rest }) => {

const signOutHandler = () => {
async function signOut() {
const result = await axios.get(`${API_SERVER}/console/signout`, {
withCredentials: true
});
const result = await axios.get(`${API_SERVER}/console/signout`);
console.log(result.status === 200);
if (result.status === 200) {
navigate('/login', { replace: true });
Expand Down
1 change: 0 additions & 1 deletion console/src/components/common/authCheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import axios, { Method } from 'axios';
export const baseURL = process.env.REACT_APP_API_URL;

export const request = axios.create({
withCredentials: true,
baseURL
});

Expand Down
10 changes: 2 additions & 8 deletions console/src/components/overview/AgentOverview.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ const AgentList = () => {

async function get() {
const result = await axios.get(
`${API_SERVER}/inner/groups/${currentZone}/agents`,
{
withCredentials: true
}
`${API_SERVER}/inner/groups/${currentZone}/agents`
);
if (!completed) dispatch(getAgentList(result.data));
}
Expand Down Expand Up @@ -112,10 +109,7 @@ const AddAgent = () => {

async function get() {
const result = await axios.get(
`${API_SERVER}/inner/groups/${currentZone}/agents`,
{
withCredentials: true
}
`${API_SERVER}/inner/groups/${currentZone}/agents`
);
dispatch(getAgentList(result.data));

Expand Down
10 changes: 2 additions & 8 deletions console/src/components/overview/TaskOverview.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ const TaskList = () => {

async function get() {
const result = await axios.get(
`${API_SERVER}/inner/tasks?groupID=${currentZone}`,
{
withCredentials: true
}
`${API_SERVER}/inner/tasks?groupID=${currentZone}`
);
if (!completed) setData(result.data);
}
Expand All @@ -46,10 +43,7 @@ const TaskList = () => {

async function get() {
const result = await axios.get(
`${API_SERVER}/inner/tasks?groupID=${currentZone}`,
{
withCredentials: true
}
`${API_SERVER}/inner/tasks?groupID=${currentZone}`
);
if (!completed) setData(result.data);
}
Expand Down
5 changes: 1 addition & 4 deletions console/src/components/settings/SettingsPassword.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ const SettingsPassword = (props) => {
const response = await axios.post(
`${API_SERVER}/console/changepassword`,
form,
{ headers },
{
withCredentials: true
}
{ headers }
);

console.log(response);
Expand Down
10 changes: 2 additions & 8 deletions console/src/components/task/AllTasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ const TaskList = () => {

async function get() {
const result = await axios.get(
`${API_SERVER}/inner/tasks?groupID=${currentZone}`,
{
withCredentials: true
}
`${API_SERVER}/inner/tasks?groupID=${currentZone}`
);
if (!completed) setData(result.data);
}
Expand All @@ -40,10 +37,7 @@ const TaskList = () => {

async function get() {
const result = await axios.get(
`${API_SERVER}/inner/tasks?groupID=${currentZone}`,
{
withCredentials: true
}
`${API_SERVER}/inner/tasks?groupID=${currentZone}`
);
if (!completed) setData(result.data);
}
Expand Down
10 changes: 2 additions & 8 deletions console/src/components/task/OrderList.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ const TaskList = () => {

async function get() {
const result = await axios.get(
`${API_SERVER}/inner/tasks?groupID=${currentZone}`,
{
withCredentials: true
}
`${API_SERVER}/inner/tasks?groupID=${currentZone}`
);
if (!completed) setData(result.data);
}
Expand All @@ -40,10 +37,7 @@ const TaskList = () => {

async function get() {
const result = await axios.get(
`${API_SERVER}/inner/tasks?groupID=${currentZone}`,
{
withCredentials: true
}
`${API_SERVER}/inner/tasks?groupID=${currentZone}`
);
if (!completed) setData(result.data);
}
Expand Down
10 changes: 2 additions & 8 deletions console/src/components/task/SchedulerList.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ const TaskList = () => {

async function get() {
const result = await axios.get(
`${API_SERVER}/inner/tasks?groupID=${currentZone}`,
{
withCredentials: true
}
`${API_SERVER}/inner/tasks?groupID=${currentZone}`
);
if (!completed) setData(result.data);
}
Expand All @@ -40,10 +37,7 @@ const TaskList = () => {

async function get() {
const result = await axios.get(
`${API_SERVER}/inner/tasks?groupID=${currentZone}`,
{
withCredentials: true
}
`${API_SERVER}/inner/tasks?groupID=${currentZone}`
);
if (!completed) setData(result.data);
}
Expand Down
28 changes: 13 additions & 15 deletions console/src/components/zones/AllZones.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ const TaskList = () => {
let completed = false;

async function get() {
const result = await axios.get(`${API_SERVER}/inner/groups`, {
withCredentials: true
});
const result = await axios.get(`${API_SERVER}/inner/groups`);
if (!completed) dispatch(getZoneList(result.data));
}
get();
Expand All @@ -57,18 +55,18 @@ const TaskList = () => {
console.log(`delete zone id ${id}`);

async function deleteZone() {
// const headers = {
// accept: 'application/json',
// 'Content-Type': 'application/json'
// };
// const response = await axios.delete(
// `${API_SERVER}/inner/groups/${id}`,
// { headers },
// {
// withCredentials: true
// }
// );
// console.log(response);
const headers = {
accept: 'application/json',
'Content-Type': 'application/json'
};
const response = await axios.delete(
`${API_SERVER}/inner/groups/${id}`,
{ headers }
);
if (response.status === 200) {
const result = await axios.get(`${API_SERVER}/inner/groups`);
dispatch(getZoneList(result.data));
}
}
deleteZone();
},
Expand Down
5 changes: 1 addition & 4 deletions console/src/pages/Activate.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ const Activate = () => {
const response = await axios.post(
`${API_SERVER}/console/changepassword`,
form,
{ headers },
{
withCredentials: true
}
{ headers }
);

if (response.status === 200) {
Expand Down
9 changes: 2 additions & 7 deletions console/src/pages/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ const Login = () => {

useEffect(() => {
async function check() {
const result = await axios.get(`${API_SERVER}/console/activated/admin`, {
withCredentials: true
});
const result = await axios.get(`${API_SERVER}/console/activated/admin`);

if (result.data.status === 'initialized') {
navigate('/activate', { replace: true });
Expand Down Expand Up @@ -67,10 +65,7 @@ const Login = () => {
const response = await axios.post(
`${API_SERVER}/console/signin`,
form,
{ headers },
{
withCredentials: true
}
{ headers }
);

response.data.token &&
Expand Down
9 changes: 2 additions & 7 deletions console/src/pages/ZoneList.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,13 @@ const Dashboard = () => {
groupName: groupname,
platform: platform
},
{ headers },
{
withCredentials: true
}
{ headers }
);

console.log(response.status === 200);
if (response.status === 200) {
async function get() {
const result = await axios.get(`${API_SERVER}/inner/groups`, {
withCredentials: true
});
const result = await axios.get(`${API_SERVER}/inner/groups`);
dispatch(getZoneList(result.data));
}
get();
Expand Down

0 comments on commit 074824f

Please sign in to comment.