Skip to content

Commit

Permalink
🔨 fix : 파일 임포트 대소문자 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
ImNM committed Jul 16, 2022
1 parent 985e007 commit c6e2458
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 62 deletions.
18 changes: 9 additions & 9 deletions src/apis/auth/Auth.api.js → src/apis/auth/AuthApi.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
const { default: axios, Axios } = require("axios");
const { default: InstanceSetting } = require("../common/instance.api");
const { default: axios, Axios } = require('axios');
const { default: InstanceSetting } = require('../common/instance.api');

// axios.defaults.baseURL = "https://api.gosrock.band";

class AuthApi extends InstanceSetting {
constructor() {
super("https://api.gosrock.band/v1/auth");
super('https://api.gosrock.band/v1/auth');
}
// {
// "phoneNumber": "string",
// "slackEmail": "string"
// }

requestSlackValidationNumber = async ({ phoneNumber, slackEmail }) => {
return await this.axiosInstance.post("/slack/send", {
return await this.axiosInstance.post('/slack/send', {
phoneNumber,
slackEmail,
slackEmail
});
};

Expand All @@ -28,13 +28,13 @@ class AuthApi extends InstanceSetting {
validationSlackNumber = async ({
phoneNumber,
slackEmail,
validationNumber,
validationNumber
}) => {
return await this.axiosInstance.post("/slack/validation", {
return await this.axiosInstance.post('/slack/validation', {
phoneNumber,
slackEmail,
validationNumber,
validationNumber
});
};
}
module.exports = new AuthApi();
export default new AuthApi();
19 changes: 0 additions & 19 deletions src/apis/tickets/Tickets.api.js

This file was deleted.

19 changes: 19 additions & 0 deletions src/apis/tickets/TicketsApi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const { default: axios } = require('axios');

// axios.defaults.baseURL = "https://api.gosrock.band";
const { default: InstanceSetting } = require('../common/instance.api');

class TicketsApi extends InstanceSetting {
constructor() {
super('https://api.gosrock.band/v1/tickets');
}

// 예시임다
getTickets = async ({ phoneNumber, slackEmail }) => {
await this.axiosInstance.post('/slack/send', {
phoneNumber,
slackEmail
});
};
}
export default new TicketsApi();
18 changes: 9 additions & 9 deletions src/state/actions-creators/logout.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { LOGOUT_USER } from "../action-types/logout";
import axios from "axios";
import history from "../../history";
import ticketsApi from "../../apis/tickets/tickets.api";
import { LOGOUT_USER } from '../action-types/logout';
import axios from 'axios';
import history from '../../history';
import TicketsApi from '../../apis/tickets/TicketsApi';

export const logout = (callback) => async (dispatch) => {
export const logout = callback => async dispatch => {
dispatch({ type: LOGOUT_USER });

localStorage.setItem("accessToken", null);
localStorage.setItem('accessToken', null);
axios.defaults.headers.common.Authorization = null;

// 자동으로 피쳐로 넘어가게끔
history.push("/auth/login");
ticketsApi.expireAccessTokne();
console.log(ticketsApi.axiosInstance.defaults.headers);
history.push('/auth/login');
TicketsApi.expireAccessTokne();
console.log(TicketsApi.axiosInstance.defaults.headers);

callback();
};
24 changes: 12 additions & 12 deletions src/state/actions-creators/slackMessage.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import axios from "axios";
import authApi from "../../apis/auth/auth.api";
import ErrorResponse from "../../apis/common/ErrorResponse";
import axios from 'axios';
import AuthApi from '../../apis/auth/AuthApi';

import ErrorResponse from '../../apis/common/ErrorResponse';

import {
SLACK_MESSAGE_PENDING,
SLACK_MESSAGE_SUCCESS,
SLACK_MESSAGE_FAIL,
} from "../action-types";
SLACK_MESSAGE_FAIL
} from '../action-types';

export const slackMessage =
({ phoneNumber, slackEmail }, callback) =>
async (dispatch) => {
async dispatch => {
try {
dispatch({ type: SLACK_MESSAGE_PENDING });

Expand All @@ -19,9 +20,9 @@ export const slackMessage =
// "slackEmail": "[email protected]"
// }

const response = await authApi.requestSlackValidationNumber({
const response = await AuthApi.requestSlackValidationNumber({
phoneNumber,
slackEmail,
slackEmail
});
// const response = await axios.post(
// "https://api.gosrock.band/v1/auth/slack/send",
Expand All @@ -30,19 +31,18 @@ export const slackMessage =
// slackEmail,
// }
// );

console.log(response);
// console.log(response);

dispatch({
type: SLACK_MESSAGE_SUCCESS,
payload: response.data.data.validationNumber,
payload: response.data.data.validationNumber
});

callback();
} catch (e) {
dispatch({
type: SLACK_MESSAGE_FAIL,
payload: new ErrorResponse(e.response.data.error),
payload: new ErrorResponse(e.response.data.error)
});
}
};
29 changes: 16 additions & 13 deletions src/state/actions-creators/slackValidation.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,39 @@
import axios from "axios";
import authApi from "../../apis/auth/auth.api";
import ErrorResponse from "../../apis/common/ErrorResponse";
import ticketsApi from "../../apis/tickets/tickets.api";
import axios from 'axios';
import AuthApi from '../../apis/auth/AuthApi';

import ErrorResponse from '../../apis/common/ErrorResponse';
import TicketsApi from '../../apis/tickets/TicketsApi';

import {
SLACK_VALIDATION_PENDING,
SLACK_VALIDATION_SUCCESS,
SLACK_VALIDATION_FAIL,
} from "../action-types";
SLACK_VALIDATION_FAIL
} from '../action-types';

export const slackValidation =
({ phoneNumber, slackEmail, validationNumber }, callback) =>
async (dispatch) => {
async dispatch => {
try {
dispatch({ type: SLACK_VALIDATION_PENDING });

const response = await authApi.validationSlackNumber({
const response = await AuthApi.validationSlackNumber({
phoneNumber,
slackEmail,
validationNumber,
validationNumber
});

console.log(response.data.data);
dispatch({
type: SLACK_VALIDATION_SUCCESS,
payload: response.data.data,
payload: response.data.data
});

localStorage.setItem("accessToken", response.data.data.accessToken);
localStorage.setItem('accessToken', response.data.data.accessToken);
axios.defaults.headers.common.Authorization =
response.data.data.accessToken;
// 나중에 api instance 가 늘어났다 이거 설정 해줘야함!!!
ticketsApi.changeInstanceDefaultHeaders(response.data.data.accessToken);

TicketsApi.changeInstanceDefaultHeaders(response.data.data.accessToken);

callback();
} catch (e) {
Expand All @@ -39,7 +42,7 @@ export const slackValidation =
alert(e.response.data.message);
dispatch({
type: SLACK_VALIDATION_FAIL,
payload: new ErrorResponse(e.response.data.error),
payload: new ErrorResponse(e.response.data.error)
});
}
};

0 comments on commit c6e2458

Please sign in to comment.