Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

코드 리팩토링 #4

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 4 additions & 23 deletions scripts/join.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@ const insertAxios = axios.create({
withCredentials: true,
});

const closePopup = () => {
setTimeout(() => window.close(), 3000);
};

const preventReload = (event) => {
event.preventDefault();
};

const dateFormat = (date) => {
if (!date) return "-";
return dayjs(date).format("H시 m분 s초");
Expand All @@ -27,38 +19,29 @@ const getAccessToken = () => {
return searchParams.get("authorization");
};

const Authorization = getAccessToken();

const getUserCheckIn = async () => {
const Authorization = getAccessToken();
const { data } = await insertAxios.get("/checkIn", {
headers: { Authorization },
});
return data;
};

const getAllCheckIn = async () => {
const Authorization = getAccessToken();
const { data } = await insertAxios.get("checkIn/all", {
headers: { Authorization },
});
return data;
};

const requestCheckIn = async (requestData) => {
const Authorization = getAccessToken();
const { data } = await insertAxios.post(
"/checkIn",
{ ...requestData },
{ headers: { Authorization } }
{ headers: { Authorization } },
);
return data;
};

const createRoom = async (requestData) => {
const Authorization = getAccessToken();
const { data } = await insertAxios.post(
"/room/allocate",
{ ...requestData },
{ headers: { Authorization } }
{ headers: { Authorization } },
);
return data;
};
Expand All @@ -79,8 +62,6 @@ const INFO_BOX = {
BOX: "info--box",
};

const MEMBERS = "members";

const form = element["@id"](INFO_BOX.FORM);
const box = element["@id"](INFO_BOX.BOX);

Expand Down
48 changes: 0 additions & 48 deletions scripts/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ const insertAxios = axios.create({
withCredentials: true,
});

const closePopup = () => {
setTimeout(() => window.close(), 5000);
};

const dateFormat = (date) => {
if (!date) return "-";
return dayjs(date).format("H시 m분 s초");
Expand All @@ -18,55 +14,11 @@ const element = {
"@query": (query) => document.querySelector(query),
};

const getUserCheckIn = async () => {
const Authorization = getAccessToken();
const { data } = await insertAxios.get("/checkIn", {
headers: { Authorization },
});
return data;
};

const getAllCheckIn = async () => {
const { data } = await insertAxios.get("checkIn/all");
return data;
};

const requestCheckIn = async (requestData) => {
const Authorization = getAccessToken();
const { data } = await insertAxios.post(
"/checkIn",
{ ...requestData },
{ headers: { Authorization } }
);
return data;
};

const createRoom = async (requestData) => {
const Authorization = getAccessToken();
const { data } = await insertAxios.post(
"/room/allocate",
{ requestData },
{ headers: { Authorization } }
);
return data;
};

const USER = {
NAME: "user--name",
DORMITORY_TYPE: "user--dormitoryType",
ROOM_NUMBER: "user--roomNumber",
SUB_NAME: "user--subName",
};

const CHECK_IN = {
BUTTON: "checkin--button",
};

const INFO_BOX = {
FORM: "info--form",
BOX: "info--box",
};

const MEMBERS = "members";

(async () => {
Expand Down