Skip to content
Merged
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
8 changes: 4 additions & 4 deletions src/features/auth/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { client } from '@/shared/api';
import { api } from '@/shared/api';

const setToken = (token: string, status: number) => {
if (status === 200) {
Expand All @@ -15,7 +15,7 @@ const axiosConfig = {
};

export const loginAsMember = async (account: Account) => {
const { data, status } = await client.post<string>(
const { data, status } = await api.post<string>(
`/user/login`,
account,
axiosConfig,
Expand All @@ -24,14 +24,14 @@ export const loginAsMember = async (account: Account) => {
};

export const loginAsGuest = async () => {
return client
return api
.get<string>('/user/guest', axiosConfig)
.then(({ data, status }) => setToken(data, status))
.catch(() => false);
};

export const checkToken = async () => {
const isTokenValid = await client
const isTokenValid = await api
.get<boolean>('/user/token')
.then(({ data }) => data);

Expand Down
4 changes: 2 additions & 2 deletions src/features/game/api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { client } from '@/shared/api';
import { api } from '@/shared/api';

export const getGameReady = async () => {
return client
return api
.get<GameData>('/ingame/ready')
.then(({ data }) => data)
.catch(() => null);
Expand Down
14 changes: 6 additions & 8 deletions src/features/room-setting/api.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { client } from '@/shared/api';
import { api } from '@/shared/api';

export const createRoom = async (setting: RoomSetting) => {
return client.post<string>('play/friendly', setting).then(({ data }) => data);
return api.post<string>('play/friendly', setting).then(({ data }) => data);
};

export const updateRoom = async (setting: RoomSetting) => {
return client
.post<string>('/play/friendly/renew', setting)
.then(({ data }) => {
console.log('room update:', data);
return '';
});
return api.post<string>('/play/friendly/renew', setting).then(({ data }) => {
console.log('room update:', data);
return '';
});
};
8 changes: 4 additions & 4 deletions src/features/sign-up/api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AxiosError } from 'axios';

import { client } from '@/shared/api';
import { api } from '@/shared/api';

const axiosConfig = {
headers: {
Expand All @@ -10,14 +10,14 @@ const axiosConfig = {

export const checkIdDuplicate = async (id: SignUpForm['id']) => {
// 중복이 안되면 false. true면 오류
return client
return api
.get<boolean>(`/user/dup/${id}`, axiosConfig)
.then(({ data }) => data)
.catch(() => true);
};

export const upgradeToMember = async (formData: SignUpForm) => {
return client
return api
.post<string>('/user/guest', formData)
.then(({ data }) => {
console.debug(data);
Expand All @@ -30,7 +30,7 @@ export const upgradeToMember = async (formData: SignUpForm) => {
};

export const registerMember = async (formData: SignUpForm) => {
return client
return api
.post<string>('/user/signup', formData, axiosConfig)
.then(({ data, status }) => {
localStorage.setItem('token', data);
Expand Down
4 changes: 2 additions & 2 deletions src/models/collection/api.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { COLLECTION_KEY } from './constants';

import { client, queryClient } from '@/shared/api';
import { api, queryClient } from '@/shared/api';

export const getCollection = async () => {
return client.get<Collections>('/collection').then((response) => {
return api.get<Collections>('/collection').then((response) => {
const { data } = response;
console.debug(data);
return data;
Expand Down
4 changes: 2 additions & 2 deletions src/models/room/api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { client } from '@/shared/api';
import { api } from '@/shared/api';

export const leaveRoom = async () => {
return client
return api
.get('/play/friendly/out')
.then(({ data }) => {
console.debug('leave room:', data);
Expand Down
4 changes: 2 additions & 2 deletions src/models/user/api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { client } from '@/shared/api';
import { api } from '@/shared/api';

export const getUser = async () => {
return client.get<User>(`/user`).then((response) => {
return api.get<User>(`/user`).then((response) => {
const { data } = response;
console.debug('user:', data);
return data;
Expand Down
16 changes: 7 additions & 9 deletions src/pages/collection/api.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import { client } from '@/shared/api';
import { api } from '@/shared/api';

export const updateSkin = async (skinId: number) => {
return client
.patch<string>('/collection/skin', { skinId })
.then((response) => {
const { data } = response;
console.debug(data);
return data;
});
return api.patch<string>('/collection/skin', { skinId }).then((response) => {
const { data } = response;
console.debug(data);
return data;
});
};

export const updateLabel = async (labelId: number) => {
return client
return api
.patch<string>('/collection/label', {
labelId,
})
Expand Down
6 changes: 3 additions & 3 deletions src/pages/play/lobby/api.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { client } from '@/shared/api';
import { api } from '@/shared/api';

export const getLobbyInfo = async (roodId: string | undefined) => {
if (!roodId) {
return { masterIndex: -1 } as EnteredRoom;
}

return client
return api
.get<EnteredRoom>(`/play/friendly/lobby/${roodId}`)
.then(({ data }) => data)
.catch((err) => {
Expand All @@ -15,5 +15,5 @@ export const getLobbyInfo = async (roodId: string | undefined) => {
};

export const getReady = async () => {
return client.get<string>('/play/friendly/ready');
return api.get<string>('/play/friendly/ready');
};
6 changes: 3 additions & 3 deletions src/pages/play/mode/api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { client } from '@/shared/api';
import { api } from '@/shared/api';

export const getMatching = async () => {
return client
return api
.get<string>('/play/ranking')
.then((response) => {
return response.status === 200;
Expand All @@ -13,7 +13,7 @@ export const getMatching = async () => {
};

export const deleteMatching = async () => {
return client
return api
.delete<string>('/play/ranking')
.then((response) => {
return response.status === 200;
Expand Down
23 changes: 0 additions & 23 deletions src/pages/play/mode/index.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { COLORED_ICON_BUTTON_SIZE_PIXEL } from '@/components/button/constants';

import { MYRANKINGITEMBOX_HEIGHT } from '@/pages/ranking/constants';

import { flexOptions, sprinkles } from '@/shared/styles';

export const wrapper = style([
{
display: 'grid',
Expand All @@ -26,24 +24,3 @@ export const myRank = style([
gridColumn: '1 / 3',
},
]);

export const matchingModalWrapper = style([
flexOptions({ option: 'columnCenter' }),
]);

export const matchingMessage = style([
flexOptions({ option: 'row' }),
sprinkles({
textSize: '2x',
justifyContent: 'flexStart',
width: 'full',
marginBottom: '1x',
paddingLeft: '4x',
}),
]);

export const matchingImageWrapper = style([
sprinkles({
marginY: '2x',
}),
]);
2 changes: 1 addition & 1 deletion src/pages/play/mode/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useNavigate } from 'react-router-dom';

import { getMatching } from './api';
import * as styles from './index.css';
import Matching from './Matching';
import Matching from './ui/Matching';

import ColoredIconButton from '@/components/button/ColoredIconButton';
import Modal, { useModal } from '@/components/modal';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { useNavigate } from 'react-router-dom';

import { deleteMatching } from './api';
import { deleteMatching } from '../api';
import * as styles from './index.css';
import { MatchingText } from './MatchingText';

import ColoredButton from '@/components/button/ColoredButton';
import RoundCornerImageBox from '@/components/image-box';

import { MatchingText } from '@/pages/play/mode/MatchingText';

import { useWebSocket } from '@/features/websocket';
import { ROUTE } from '@/shared/constants';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useRef, useState } from 'react';

import * as styles from '@/pages/play/mode/index.css';
import * as styles from './index.css';

interface Props {
isModalOpen: boolean;
Expand Down
24 changes: 24 additions & 0 deletions src/pages/play/mode/ui/index.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { style } from '@vanilla-extract/css';

import { flexOptions, sprinkles } from '@/shared/styles';

export const matchingModalWrapper = style([
flexOptions({ option: 'columnCenter' }),
]);

export const matchingMessage = style([
flexOptions({ option: 'row' }),
sprinkles({
textSize: '2x',
justifyContent: 'flexStart',
width: 'full',
marginBottom: '1x',
paddingLeft: '4x',
}),
]);

export const matchingImageWrapper = style([
sprinkles({
marginY: '2x',
}),
]);
4 changes: 2 additions & 2 deletions src/pages/ranking/api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { client } from '@/shared/api';
import { api } from '@/shared/api';

export const getRank = async () => {
return client
return api
.get<{
refreshTime: string;
players: Profile[];
Expand Down
4 changes: 2 additions & 2 deletions src/pages/result/api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { client } from '@/shared/api';
import { api } from '@/shared/api';

export const getGameResult = async () => {
return client.get<GameResult>('/ingame').then(({ data }) => data);
return api.get<GameResult>('/ingame').then(({ data }) => data);
};
10 changes: 5 additions & 5 deletions src/pages/settings/api.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { client } from '@/shared/api';
import { api } from '@/shared/api';

export const patchNicknameChange = async (nickname: string) => {
try {
await client.patch<string>('/user/nickname', { nickname });
await api.patch<string>('/user/nickname', { nickname });
return true;
} catch (e) {
return false;
Expand All @@ -14,7 +14,7 @@ export const patchPasswordChange = async (
newPassword: string,
) => {
try {
await client.patch<string>('/user/password', {
await api.patch<string>('/user/password', {
prePassword,
newPassword,
});
Expand All @@ -26,7 +26,7 @@ export const patchPasswordChange = async (

export const postConfirmPassword = async (password: string) => {
try {
const response = await client.post<boolean>('/user/confirm', { password });
const response = await api.post<boolean>('/user/confirm', { password });
// console.log(response.data);
return response.data;
} catch (e) {
Expand All @@ -35,7 +35,7 @@ export const postConfirmPassword = async (password: string) => {
};

export const deleteUserInfo = async () => {
await client
await api
.delete<string>('/user')
.then(() => {
window.location.href = '/';
Expand Down
Loading